Update auto-generated bindings to latest upstream
[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.2", strlen("v0.0.99.2"));
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 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
736         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
737         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
740         CVec_u8Z_free(ret_var);
741         return ret_arr;
742 }
743
744 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
745         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
746         int64_t ret_val = TxOut_get_value(thing_conv);
747         return ret_val;
748 }
749
750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
751         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
752 }
753 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
754         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
755         CHECK(val->result_ok);
756         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
757         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
758         return res_arr;
759 }
760 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
761         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
762         CHECK(!val->result_ok);
763         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
764         return err_conv;
765 }
766 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
767         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
768 }
769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
770         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
771         CHECK(val->result_ok);
772         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
773         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
774         return res_arr;
775 }
776 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
777         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
778         CHECK(!val->result_ok);
779         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
780         return err_conv;
781 }
782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
783         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
784 }
785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
786         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
787         CHECK(val->result_ok);
788         LDKTxCreationKeys res_var = (*val->contents.result);
789         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
790         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
791         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
792         return res_ref;
793 }
794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
795         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
796         CHECK(!val->result_ok);
797         LDKDecodeError err_var = (*val->contents.err);
798         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
801         return err_ref;
802 }
803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
804         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
805 }
806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
807         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
808         CHECK(val->result_ok);
809         LDKChannelPublicKeys res_var = (*val->contents.result);
810         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
811         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
812         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
813         return res_ref;
814 }
815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
816         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
817         CHECK(!val->result_ok);
818         LDKDecodeError err_var = (*val->contents.err);
819         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
820         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
821         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
822         return err_ref;
823 }
824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
825         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
826 }
827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
828         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
829         CHECK(val->result_ok);
830         LDKTxCreationKeys res_var = (*val->contents.result);
831         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
832         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
833         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
834         return res_ref;
835 }
836 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
837         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
838         CHECK(!val->result_ok);
839         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
840         return err_conv;
841 }
842 static jclass LDKCOption_u32Z_Some_class = NULL;
843 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
844 static jclass LDKCOption_u32Z_None_class = NULL;
845 static jmethodID LDKCOption_u32Z_None_meth = NULL;
846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
847         LDKCOption_u32Z_Some_class =
848                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
849         CHECK(LDKCOption_u32Z_Some_class != NULL);
850         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
851         CHECK(LDKCOption_u32Z_Some_meth != NULL);
852         LDKCOption_u32Z_None_class =
853                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
854         CHECK(LDKCOption_u32Z_None_class != NULL);
855         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
856         CHECK(LDKCOption_u32Z_None_meth != NULL);
857 }
858 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
859         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
860         switch(obj->tag) {
861                 case LDKCOption_u32Z_Some: {
862                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
863                 }
864                 case LDKCOption_u32Z_None: {
865                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
866                 }
867                 default: abort();
868         }
869 }
870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
871         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
872 }
873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
874         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
875         CHECK(val->result_ok);
876         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
877         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
878         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
879         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
880         return res_ref;
881 }
882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
883         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
884         CHECK(!val->result_ok);
885         LDKDecodeError err_var = (*val->contents.err);
886         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
887         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
888         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
889         return err_ref;
890 }
891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
892         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
893 }
894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
895         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
896         CHECK(val->result_ok);
897         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
898         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
899         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
900         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
901         return res_ref;
902 }
903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
904         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
905         CHECK(!val->result_ok);
906         LDKDecodeError err_var = (*val->contents.err);
907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
909         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
910         return err_ref;
911 }
912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
913         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
914 }
915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
916         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
917         CHECK(val->result_ok);
918         LDKChannelTransactionParameters res_var = (*val->contents.result);
919         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
920         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
921         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
922         return res_ref;
923 }
924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
925         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
926         CHECK(!val->result_ok);
927         LDKDecodeError err_var = (*val->contents.err);
928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
931         return err_ref;
932 }
933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
934         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
935 }
936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
937         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
938         CHECK(val->result_ok);
939         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
940         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
941         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
942         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
943         return res_ref;
944 }
945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
946         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
947         CHECK(!val->result_ok);
948         LDKDecodeError err_var = (*val->contents.err);
949         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
950         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
951         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
952         return err_ref;
953 }
954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
955         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
956 }
957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
958         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
959         CHECK(val->result_ok);
960         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
963         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
964         return res_ref;
965 }
966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
967         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
968         CHECK(!val->result_ok);
969         LDKDecodeError err_var = (*val->contents.err);
970         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
971         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
972         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
973         return err_ref;
974 }
975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
976         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
977 }
978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
979         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
980         CHECK(val->result_ok);
981         LDKCommitmentTransaction res_var = (*val->contents.result);
982         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
985         return res_ref;
986 }
987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
988         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
989         CHECK(!val->result_ok);
990         LDKDecodeError err_var = (*val->contents.err);
991         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
992         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
993         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
994         return err_ref;
995 }
996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
997         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
998 }
999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1000         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1001         CHECK(val->result_ok);
1002         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1003         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1004         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1005         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1006         return res_ref;
1007 }
1008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1009         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1010         CHECK(!val->result_ok);
1011         return *val->contents.err;
1012 }
1013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1014         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1015 }
1016 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1017         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1018         CHECK(val->result_ok);
1019         LDKCVec_SignatureZ res_var = (*val->contents.result);
1020         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1021         ;
1022         for (size_t i = 0; i < res_var.datalen; i++) {
1023                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1024                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1025                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1026         }
1027         return res_arr;
1028 }
1029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1030         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1031         CHECK(!val->result_ok);
1032         return *val->contents.err;
1033 }
1034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1035         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1036 }
1037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1038         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1039         CHECK(val->result_ok);
1040         return *val->contents.result;
1041 }
1042 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1043         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1044         CHECK(!val->result_ok);
1045         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1046         return err_conv;
1047 }
1048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1049         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1050 }
1051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1052         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1053         CHECK(val->result_ok);
1054         LDKRouteHop res_var = (*val->contents.result);
1055         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1056         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1057         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1058         return res_ref;
1059 }
1060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1061         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1062         CHECK(!val->result_ok);
1063         LDKDecodeError err_var = (*val->contents.err);
1064         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1065         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1066         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1067         return err_ref;
1068 }
1069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1070         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1071         ret->datalen = (*env)->GetArrayLength(env, elems);
1072         if (ret->datalen == 0) {
1073                 ret->data = NULL;
1074         } else {
1075                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1076                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1077                 for (size_t i = 0; i < ret->datalen; i++) {
1078                         int64_t arr_elem = java_elems[i];
1079                         LDKRouteHop arr_elem_conv;
1080                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1081                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1082                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1083                         ret->data[i] = arr_elem_conv;
1084                 }
1085                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1086         }
1087         return (uint64_t)ret;
1088 }
1089 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1090         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1091         for (size_t i = 0; i < ret.datalen; i++) {
1092                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1093         }
1094         return ret;
1095 }
1096 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1097         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1098         for (size_t i = 0; i < ret.datalen; i++) {
1099                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1100         }
1101         return ret;
1102 }
1103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1104         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1105 }
1106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1107         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1108         CHECK(val->result_ok);
1109         LDKRoute res_var = (*val->contents.result);
1110         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1113         return res_ref;
1114 }
1115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1116         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1117         CHECK(!val->result_ok);
1118         LDKDecodeError err_var = (*val->contents.err);
1119         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1120         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1121         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1122         return err_ref;
1123 }
1124 static jclass LDKCOption_u64Z_Some_class = NULL;
1125 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1126 static jclass LDKCOption_u64Z_None_class = NULL;
1127 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1129         LDKCOption_u64Z_Some_class =
1130                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1131         CHECK(LDKCOption_u64Z_Some_class != NULL);
1132         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1133         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1134         LDKCOption_u64Z_None_class =
1135                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1136         CHECK(LDKCOption_u64Z_None_class != NULL);
1137         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1138         CHECK(LDKCOption_u64Z_None_meth != NULL);
1139 }
1140 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1141         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1142         switch(obj->tag) {
1143                 case LDKCOption_u64Z_Some: {
1144                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1145                 }
1146                 case LDKCOption_u64Z_None: {
1147                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1148                 }
1149                 default: abort();
1150         }
1151 }
1152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1153         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1154         ret->datalen = (*env)->GetArrayLength(env, elems);
1155         if (ret->datalen == 0) {
1156                 ret->data = NULL;
1157         } else {
1158                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1159                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1160                 for (size_t i = 0; i < ret->datalen; i++) {
1161                         int64_t arr_elem = java_elems[i];
1162                         LDKChannelDetails arr_elem_conv;
1163                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1164                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1165                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1166                         ret->data[i] = arr_elem_conv;
1167                 }
1168                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1169         }
1170         return (uint64_t)ret;
1171 }
1172 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1173         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1174         for (size_t i = 0; i < ret.datalen; i++) {
1175                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1176         }
1177         return ret;
1178 }
1179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1180         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1181         ret->datalen = (*env)->GetArrayLength(env, elems);
1182         if (ret->datalen == 0) {
1183                 ret->data = NULL;
1184         } else {
1185                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1186                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1187                 for (size_t i = 0; i < ret->datalen; i++) {
1188                         int64_t arr_elem = java_elems[i];
1189                         LDKRouteHint arr_elem_conv;
1190                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1191                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1192                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1193                         ret->data[i] = arr_elem_conv;
1194                 }
1195                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1196         }
1197         return (uint64_t)ret;
1198 }
1199 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1200         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1201         for (size_t i = 0; i < ret.datalen; i++) {
1202                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1203         }
1204         return ret;
1205 }
1206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1207         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1208 }
1209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1210         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1211         CHECK(val->result_ok);
1212         LDKRoute res_var = (*val->contents.result);
1213         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1214         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1215         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1216         return res_ref;
1217 }
1218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1219         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1220         CHECK(!val->result_ok);
1221         LDKLightningError err_var = (*val->contents.err);
1222         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1223         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1224         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1225         return err_ref;
1226 }
1227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1228         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1229 }
1230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1231         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1232         CHECK(val->result_ok);
1233         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1234         return (uint64_t)res_ref;
1235 }
1236 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1237         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1238         CHECK(!val->result_ok);
1239         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1240         return err_conv;
1241 }
1242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1243         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1244         ret->a = a;
1245         LDKTransaction b_ref;
1246         b_ref.datalen = (*env)->GetArrayLength(env, b);
1247         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1248         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1249         b_ref.data_is_owned = false;
1250         ret->b = b_ref;
1251         return (uint64_t)ret;
1252 }
1253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1254         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1255         return tuple->a;
1256 }
1257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1258         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1259         LDKTransaction b_var = tuple->b;
1260         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1261         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1262         return b_arr;
1263 }
1264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1265         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1266         ret->datalen = (*env)->GetArrayLength(env, elems);
1267         if (ret->datalen == 0) {
1268                 ret->data = NULL;
1269         } else {
1270                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1271                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1272                 for (size_t i = 0; i < ret->datalen; i++) {
1273                         int64_t arr_elem = java_elems[i];
1274                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1275                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1276                         ret->data[i] = arr_elem_conv;
1277                 }
1278                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1279         }
1280         return (uint64_t)ret;
1281 }
1282 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1283         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1284         for (size_t i = 0; i < ret.datalen; i++) {
1285                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1286         }
1287         return ret;
1288 }
1289 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1290         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1291         for (size_t i = 0; i < ret.datalen; i++) {
1292                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1293         }
1294         return ret;
1295 }
1296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1297         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1298 }
1299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1300         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1301         CHECK(val->result_ok);
1302         return *val->contents.result;
1303 }
1304 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1305         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1306         CHECK(!val->result_ok);
1307         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1308         return err_conv;
1309 }
1310 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1311 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1312 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1313 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1315         LDKMonitorEvent_HTLCEvent_class =
1316                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1317         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1318         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1319         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1320         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1321                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1322         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1323         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1324         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1325 }
1326 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1327         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1328         switch(obj->tag) {
1329                 case LDKMonitorEvent_HTLCEvent: {
1330                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1331                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1332                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1333                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1334                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1335                 }
1336                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1337                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1338                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1339                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1340                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1341                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1342                 }
1343                 default: abort();
1344         }
1345 }
1346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1347         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1348         ret->datalen = (*env)->GetArrayLength(env, elems);
1349         if (ret->datalen == 0) {
1350                 ret->data = NULL;
1351         } else {
1352                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1353                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1354                 for (size_t i = 0; i < ret->datalen; i++) {
1355                         int64_t arr_elem = java_elems[i];
1356                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1357                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1358                         ret->data[i] = arr_elem_conv;
1359                 }
1360                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1361         }
1362         return (uint64_t)ret;
1363 }
1364 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1365         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1366         for (size_t i = 0; i < ret.datalen; i++) {
1367                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1368         }
1369         return ret;
1370 }
1371 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1372 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1373 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1374 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1376         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1377                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1378         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1379         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1380         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1381         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1383         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1384         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1385         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1386 }
1387 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1388         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1389         switch(obj->tag) {
1390                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1391                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1392                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1393                 }
1394                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1395                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1396                 }
1397                 default: abort();
1398         }
1399 }
1400 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1401 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1402 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1403 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1404 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1405 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1407         LDKSpendableOutputDescriptor_StaticOutput_class =
1408                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1409         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1410         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1411         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1412         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1413                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1414         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1415         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1416         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1417         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1418                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1419         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1420         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1421         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1422 }
1423 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1424         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1425         switch(obj->tag) {
1426                 case LDKSpendableOutputDescriptor_StaticOutput: {
1427                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1428                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1429                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1430                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1431                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1432                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1433                 }
1434                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1435                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1436                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1439                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1440                 }
1441                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1442                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1443                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1444                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1445                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1446                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1447                 }
1448                 default: abort();
1449         }
1450 }
1451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1452         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1453         ret->datalen = (*env)->GetArrayLength(env, elems);
1454         if (ret->datalen == 0) {
1455                 ret->data = NULL;
1456         } else {
1457                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1458                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1459                 for (size_t i = 0; i < ret->datalen; i++) {
1460                         int64_t arr_elem = java_elems[i];
1461                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1462                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1463                         ret->data[i] = arr_elem_conv;
1464                 }
1465                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1466         }
1467         return (uint64_t)ret;
1468 }
1469 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1470         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1471         for (size_t i = 0; i < ret.datalen; i++) {
1472                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1473         }
1474         return ret;
1475 }
1476 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1477 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1478 static jclass LDKErrorAction_IgnoreError_class = NULL;
1479 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1480 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1481 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1482 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1483 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1485         LDKErrorAction_DisconnectPeer_class =
1486                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1487         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1488         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1489         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1490         LDKErrorAction_IgnoreError_class =
1491                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1492         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1493         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1494         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1495         LDKErrorAction_IgnoreAndLog_class =
1496                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1497         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1498         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1499         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1500         LDKErrorAction_SendErrorMessage_class =
1501                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1502         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1503         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1504         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1505 }
1506 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1507         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1508         switch(obj->tag) {
1509                 case LDKErrorAction_DisconnectPeer: {
1510                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1511                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1512                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1513                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1514                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1515                 }
1516                 case LDKErrorAction_IgnoreError: {
1517                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1518                 }
1519                 case LDKErrorAction_IgnoreAndLog: {
1520                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1521                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1522                 }
1523                 case LDKErrorAction_SendErrorMessage: {
1524                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1525                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1526                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1527                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1528                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1529                 }
1530                 default: abort();
1531         }
1532 }
1533 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1534 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1535 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1536 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1537 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1538 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1540         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1542         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1543         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1544         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1545         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1546                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1547         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1548         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1549         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1550         LDKHTLCFailChannelUpdate_NodeFailure_class =
1551                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1552         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1553         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1554         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1555 }
1556 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1557         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1558         switch(obj->tag) {
1559                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1560                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1561                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1562                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1563                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1564                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1565                 }
1566                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1567                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1568                 }
1569                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1570                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1571                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1572                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1573                 }
1574                 default: abort();
1575         }
1576 }
1577 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1578 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1579 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1580 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1581 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1582 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1583 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1584 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1585 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1586 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1587 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1588 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1589 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1590 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1591 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1592 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1593 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1594 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1595 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1596 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1597 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1598 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1599 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1600 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1601 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1602 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1603 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1604 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1605 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1606 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1607 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1608 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1609 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1610 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1611 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1612 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1613 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1614 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1615 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1616 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1618         LDKMessageSendEvent_SendAcceptChannel_class =
1619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1620         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1621         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1622         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1623         LDKMessageSendEvent_SendOpenChannel_class =
1624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1625         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1626         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1627         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1628         LDKMessageSendEvent_SendFundingCreated_class =
1629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1630         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1631         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1632         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1633         LDKMessageSendEvent_SendFundingSigned_class =
1634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1635         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1636         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1637         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1638         LDKMessageSendEvent_SendFundingLocked_class =
1639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1640         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1641         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1642         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1643         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1645         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1646         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1647         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1648         LDKMessageSendEvent_UpdateHTLCs_class =
1649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1650         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1651         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1652         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1653         LDKMessageSendEvent_SendRevokeAndACK_class =
1654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1655         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1656         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1657         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1658         LDKMessageSendEvent_SendClosingSigned_class =
1659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1660         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1661         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1662         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1663         LDKMessageSendEvent_SendShutdown_class =
1664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1665         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1666         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1667         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1668         LDKMessageSendEvent_SendChannelReestablish_class =
1669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1670         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1671         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1672         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1673         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1675         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1676         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1677         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1678         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1680         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1681         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1682         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1683         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1685         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1686         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1687         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1688         LDKMessageSendEvent_SendChannelUpdate_class =
1689                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1690         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1691         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1692         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1693         LDKMessageSendEvent_HandleError_class =
1694                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1695         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1696         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1697         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1698         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1699                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1700         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1701         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1702         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1703         LDKMessageSendEvent_SendChannelRangeQuery_class =
1704                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1705         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1706         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1707         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1708         LDKMessageSendEvent_SendShortIdsQuery_class =
1709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1710         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1711         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1712         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1713         LDKMessageSendEvent_SendReplyChannelRange_class =
1714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1715         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1716         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1717         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1718 }
1719 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1720         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1721         switch(obj->tag) {
1722                 case LDKMessageSendEvent_SendAcceptChannel: {
1723                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1724                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1725                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1726                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1727                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1728                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1729                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1730                 }
1731                 case LDKMessageSendEvent_SendOpenChannel: {
1732                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1733                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1734                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1735                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1736                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1737                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1738                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1739                 }
1740                 case LDKMessageSendEvent_SendFundingCreated: {
1741                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1742                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1743                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1744                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1745                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1746                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1747                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1748                 }
1749                 case LDKMessageSendEvent_SendFundingSigned: {
1750                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1751                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1752                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1753                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1754                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1755                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1756                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1757                 }
1758                 case LDKMessageSendEvent_SendFundingLocked: {
1759                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1760                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1761                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1762                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1763                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1764                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1765                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1766                 }
1767                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1768                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1769                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1770                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1771                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1772                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1773                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1774                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1775                 }
1776                 case LDKMessageSendEvent_UpdateHTLCs: {
1777                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1778                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1779                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1780                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1781                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1782                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1783                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1784                 }
1785                 case LDKMessageSendEvent_SendRevokeAndACK: {
1786                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1787                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1788                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1789                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1790                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1791                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1792                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1793                 }
1794                 case LDKMessageSendEvent_SendClosingSigned: {
1795                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1796                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1797                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1798                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1799                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1800                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1801                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1802                 }
1803                 case LDKMessageSendEvent_SendShutdown: {
1804                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1805                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1806                         LDKShutdown msg_var = obj->send_shutdown.msg;
1807                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1808                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1809                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1810                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1811                 }
1812                 case LDKMessageSendEvent_SendChannelReestablish: {
1813                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1814                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1815                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1816                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1817                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1818                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1819                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1820                 }
1821                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1822                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1823                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1824                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1825                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1826                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1827                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1828                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1829                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1830                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1831                 }
1832                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1833                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1834                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1835                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1836                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1837                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1838                 }
1839                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1840                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1841                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1842                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1843                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1844                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1845                 }
1846                 case LDKMessageSendEvent_SendChannelUpdate: {
1847                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1848                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1849                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1850                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1851                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1852                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1853                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1854                 }
1855                 case LDKMessageSendEvent_HandleError: {
1856                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1857                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1858                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1859                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1860                 }
1861                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1862                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1863                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1864                 }
1865                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1866                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1867                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1868                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1869                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1870                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1871                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1872                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1873                 }
1874                 case LDKMessageSendEvent_SendShortIdsQuery: {
1875                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1876                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1877                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1878                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1879                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1880                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1881                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1882                 }
1883                 case LDKMessageSendEvent_SendReplyChannelRange: {
1884                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1885                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1886                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1887                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1888                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1889                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1890                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1891                 }
1892                 default: abort();
1893         }
1894 }
1895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1896         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1897         ret->datalen = (*env)->GetArrayLength(env, elems);
1898         if (ret->datalen == 0) {
1899                 ret->data = NULL;
1900         } else {
1901                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1902                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1903                 for (size_t i = 0; i < ret->datalen; i++) {
1904                         int64_t arr_elem = java_elems[i];
1905                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1906                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1907                         ret->data[i] = arr_elem_conv;
1908                 }
1909                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1910         }
1911         return (uint64_t)ret;
1912 }
1913 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1914         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1915         for (size_t i = 0; i < ret.datalen; i++) {
1916                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1917         }
1918         return ret;
1919 }
1920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1921         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1922 }
1923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1924         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1925         CHECK(val->result_ok);
1926         LDKInitFeatures res_var = (*val->contents.result);
1927         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1928         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1929         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1930         return res_ref;
1931 }
1932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1933         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1934         CHECK(!val->result_ok);
1935         LDKDecodeError err_var = (*val->contents.err);
1936         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1937         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1938         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1939         return err_ref;
1940 }
1941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1942         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1943 }
1944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1945         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1946         CHECK(val->result_ok);
1947         LDKNodeFeatures res_var = (*val->contents.result);
1948         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1949         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1950         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1951         return res_ref;
1952 }
1953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1954         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1955         CHECK(!val->result_ok);
1956         LDKDecodeError err_var = (*val->contents.err);
1957         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1958         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1959         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1960         return err_ref;
1961 }
1962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1963         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1964 }
1965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1966         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1967         CHECK(val->result_ok);
1968         LDKChannelFeatures res_var = (*val->contents.result);
1969         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1970         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1971         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1972         return res_ref;
1973 }
1974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1975         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1976         CHECK(!val->result_ok);
1977         LDKDecodeError err_var = (*val->contents.err);
1978         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1979         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1980         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1981         return err_ref;
1982 }
1983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1984         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1985 }
1986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1987         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1988         CHECK(val->result_ok);
1989         LDKInvoiceFeatures res_var = (*val->contents.result);
1990         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1991         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1992         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1993         return res_ref;
1994 }
1995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1996         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1997         CHECK(!val->result_ok);
1998         LDKDecodeError err_var = (*val->contents.err);
1999         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2000         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2001         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2002         return err_ref;
2003 }
2004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2005         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2006 }
2007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2008         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2009         CHECK(val->result_ok);
2010         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2011         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2012         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2013         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2014         return res_ref;
2015 }
2016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2017         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2018         CHECK(!val->result_ok);
2019         LDKDecodeError err_var = (*val->contents.err);
2020         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2021         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2022         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2023         return err_ref;
2024 }
2025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2026         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2027 }
2028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2029         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2030         CHECK(val->result_ok);
2031         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2032         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2033         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2034         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2035         return res_ref;
2036 }
2037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2038         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2039         CHECK(!val->result_ok);
2040         LDKDecodeError err_var = (*val->contents.err);
2041         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2042         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2043         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2044         return err_ref;
2045 }
2046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2047         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2048 }
2049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2050         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2051         CHECK(val->result_ok);
2052         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2053         return res_ref;
2054 }
2055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2056         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2057         CHECK(!val->result_ok);
2058         LDKDecodeError err_var = (*val->contents.err);
2059         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2060         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2061         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2062         return err_ref;
2063 }
2064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2065         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2066         LDKSignature a_ref;
2067         CHECK((*env)->GetArrayLength(env, a) == 64);
2068         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2069         ret->a = a_ref;
2070         LDKCVec_SignatureZ b_constr;
2071         b_constr.datalen = (*env)->GetArrayLength(env, b);
2072         if (b_constr.datalen > 0)
2073                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2074         else
2075                 b_constr.data = NULL;
2076         for (size_t i = 0; i < b_constr.datalen; i++) {
2077                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2078                 LDKSignature b_conv_8_ref;
2079                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2080                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2081                 b_constr.data[i] = b_conv_8_ref;
2082         }
2083         ret->b = b_constr;
2084         return (uint64_t)ret;
2085 }
2086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2087         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2088         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2089         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2090         return a_arr;
2091 }
2092 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2093         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2094         LDKCVec_SignatureZ b_var = tuple->b;
2095         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2096         ;
2097         for (size_t i = 0; i < b_var.datalen; i++) {
2098                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2099                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2100                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2101         }
2102         return b_arr;
2103 }
2104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2105         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2106 }
2107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2108         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2109         CHECK(val->result_ok);
2110         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2111         return res_ref;
2112 }
2113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2114         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2115         CHECK(!val->result_ok);
2116         return *val->contents.err;
2117 }
2118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2119         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2120 }
2121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2122         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2123         CHECK(val->result_ok);
2124         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2125         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2126         return res_arr;
2127 }
2128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2129         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2130         CHECK(!val->result_ok);
2131         return *val->contents.err;
2132 }
2133 typedef struct LDKBaseSign_JCalls {
2134         atomic_size_t refcnt;
2135         JavaVM *vm;
2136         jweak o;
2137         jmethodID get_per_commitment_point_meth;
2138         jmethodID release_commitment_secret_meth;
2139         jmethodID channel_keys_id_meth;
2140         jmethodID sign_counterparty_commitment_meth;
2141         jmethodID sign_holder_commitment_and_htlcs_meth;
2142         jmethodID sign_justice_revoked_output_meth;
2143         jmethodID sign_justice_revoked_htlc_meth;
2144         jmethodID sign_counterparty_htlc_transaction_meth;
2145         jmethodID sign_closing_transaction_meth;
2146         jmethodID sign_channel_announcement_meth;
2147         jmethodID ready_channel_meth;
2148 } LDKBaseSign_JCalls;
2149 static void LDKBaseSign_JCalls_free(void* this_arg) {
2150         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2151         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2152                 JNIEnv *env;
2153                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2154                 if (get_jenv_res == JNI_EDETACHED) {
2155                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2156                 } else {
2157                         DO_ASSERT(get_jenv_res == JNI_OK);
2158                 }
2159                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2160                 if (get_jenv_res == JNI_EDETACHED) {
2161                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2162                 }
2163                 FREE(j_calls);
2164         }
2165 }
2166 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2167         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2168         JNIEnv *env;
2169         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2170         if (get_jenv_res == JNI_EDETACHED) {
2171                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2172         } else {
2173                 DO_ASSERT(get_jenv_res == JNI_OK);
2174         }
2175         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2176         CHECK(obj != NULL);
2177         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2178         if ((*env)->ExceptionCheck(env)) {
2179                 (*env)->ExceptionDescribe(env);
2180                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2181         }
2182         LDKPublicKey ret_ref;
2183         CHECK((*env)->GetArrayLength(env, ret) == 33);
2184         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2185         if (get_jenv_res == JNI_EDETACHED) {
2186                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2187         }
2188         return ret_ref;
2189 }
2190 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2191         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2192         JNIEnv *env;
2193         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2194         if (get_jenv_res == JNI_EDETACHED) {
2195                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2196         } else {
2197                 DO_ASSERT(get_jenv_res == JNI_OK);
2198         }
2199         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2200         CHECK(obj != NULL);
2201         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2202         if ((*env)->ExceptionCheck(env)) {
2203                 (*env)->ExceptionDescribe(env);
2204                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2205         }
2206         LDKThirtyTwoBytes ret_ref;
2207         CHECK((*env)->GetArrayLength(env, ret) == 32);
2208         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2209         if (get_jenv_res == JNI_EDETACHED) {
2210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2211         }
2212         return ret_ref;
2213 }
2214 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2215         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2216         JNIEnv *env;
2217         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2218         if (get_jenv_res == JNI_EDETACHED) {
2219                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2220         } else {
2221                 DO_ASSERT(get_jenv_res == JNI_OK);
2222         }
2223         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2224         CHECK(obj != NULL);
2225         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2226         if ((*env)->ExceptionCheck(env)) {
2227                 (*env)->ExceptionDescribe(env);
2228                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2229         }
2230         LDKThirtyTwoBytes ret_ref;
2231         CHECK((*env)->GetArrayLength(env, ret) == 32);
2232         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2233         if (get_jenv_res == JNI_EDETACHED) {
2234                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2235         }
2236         return ret_ref;
2237 }
2238 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2239         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2240         JNIEnv *env;
2241         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2242         if (get_jenv_res == JNI_EDETACHED) {
2243                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2244         } else {
2245                 DO_ASSERT(get_jenv_res == JNI_OK);
2246         }
2247         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2248         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2249         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2250         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2251         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2252         if (commitment_tx_var.is_owned) {
2253                 commitment_tx_ref |= 1;
2254         }
2255         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2256         CHECK(obj != NULL);
2257         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2258         if ((*env)->ExceptionCheck(env)) {
2259                 (*env)->ExceptionDescribe(env);
2260                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2261         }
2262         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2263         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2264         if (get_jenv_res == JNI_EDETACHED) {
2265                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2266         }
2267         return ret_conv;
2268 }
2269 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2270         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2271         JNIEnv *env;
2272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2273         if (get_jenv_res == JNI_EDETACHED) {
2274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2275         } else {
2276                 DO_ASSERT(get_jenv_res == JNI_OK);
2277         }
2278         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2279         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2280         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2281         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2282         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2283         if (commitment_tx_var.is_owned) {
2284                 commitment_tx_ref |= 1;
2285         }
2286         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2287         CHECK(obj != NULL);
2288         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2289         if ((*env)->ExceptionCheck(env)) {
2290                 (*env)->ExceptionDescribe(env);
2291                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2292         }
2293         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2294         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2295         if (get_jenv_res == JNI_EDETACHED) {
2296                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2297         }
2298         return ret_conv;
2299 }
2300 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]) {
2301         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2302         JNIEnv *env;
2303         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2304         if (get_jenv_res == JNI_EDETACHED) {
2305                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2306         } else {
2307                 DO_ASSERT(get_jenv_res == JNI_OK);
2308         }
2309         LDKTransaction justice_tx_var = justice_tx;
2310         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2311         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2312         Transaction_free(justice_tx_var);
2313         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2314         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2315         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2316         CHECK(obj != NULL);
2317         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);
2318         if ((*env)->ExceptionCheck(env)) {
2319                 (*env)->ExceptionDescribe(env);
2320                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2321         }
2322         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2323         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2324         if (get_jenv_res == JNI_EDETACHED) {
2325                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2326         }
2327         return ret_conv;
2328 }
2329 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) {
2330         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2331         JNIEnv *env;
2332         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2333         if (get_jenv_res == JNI_EDETACHED) {
2334                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2335         } else {
2336                 DO_ASSERT(get_jenv_res == JNI_OK);
2337         }
2338         LDKTransaction justice_tx_var = justice_tx;
2339         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2340         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2341         Transaction_free(justice_tx_var);
2342         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2343         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2344         LDKHTLCOutputInCommitment htlc_var = *htlc;
2345         htlc_var = HTLCOutputInCommitment_clone(htlc);
2346         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2347         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2348         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2349         if (htlc_var.is_owned) {
2350                 htlc_ref |= 1;
2351         }
2352         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2353         CHECK(obj != NULL);
2354         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);
2355         if ((*env)->ExceptionCheck(env)) {
2356                 (*env)->ExceptionDescribe(env);
2357                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2358         }
2359         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2360         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2361         if (get_jenv_res == JNI_EDETACHED) {
2362                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2363         }
2364         return ret_conv;
2365 }
2366 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) {
2367         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2368         JNIEnv *env;
2369         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2370         if (get_jenv_res == JNI_EDETACHED) {
2371                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2372         } else {
2373                 DO_ASSERT(get_jenv_res == JNI_OK);
2374         }
2375         LDKTransaction htlc_tx_var = htlc_tx;
2376         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2377         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2378         Transaction_free(htlc_tx_var);
2379         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2380         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2381         LDKHTLCOutputInCommitment htlc_var = *htlc;
2382         htlc_var = HTLCOutputInCommitment_clone(htlc);
2383         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2384         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2385         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2386         if (htlc_var.is_owned) {
2387                 htlc_ref |= 1;
2388         }
2389         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2390         CHECK(obj != NULL);
2391         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);
2392         if ((*env)->ExceptionCheck(env)) {
2393                 (*env)->ExceptionDescribe(env);
2394                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2395         }
2396         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2397         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2398         if (get_jenv_res == JNI_EDETACHED) {
2399                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2400         }
2401         return ret_conv;
2402 }
2403 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2404         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2405         JNIEnv *env;
2406         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2407         if (get_jenv_res == JNI_EDETACHED) {
2408                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2409         } else {
2410                 DO_ASSERT(get_jenv_res == JNI_OK);
2411         }
2412         LDKTransaction closing_tx_var = closing_tx;
2413         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2414         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2415         Transaction_free(closing_tx_var);
2416         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2417         CHECK(obj != NULL);
2418         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2419         if ((*env)->ExceptionCheck(env)) {
2420                 (*env)->ExceptionDescribe(env);
2421                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2422         }
2423         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2424         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2425         if (get_jenv_res == JNI_EDETACHED) {
2426                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2427         }
2428         return ret_conv;
2429 }
2430 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2431         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2432         JNIEnv *env;
2433         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2434         if (get_jenv_res == JNI_EDETACHED) {
2435                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2436         } else {
2437                 DO_ASSERT(get_jenv_res == JNI_OK);
2438         }
2439         LDKUnsignedChannelAnnouncement msg_var = *msg;
2440         msg_var = UnsignedChannelAnnouncement_clone(msg);
2441         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2442         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2443         uint64_t msg_ref = (uint64_t)msg_var.inner;
2444         if (msg_var.is_owned) {
2445                 msg_ref |= 1;
2446         }
2447         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2448         CHECK(obj != NULL);
2449         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2450         if ((*env)->ExceptionCheck(env)) {
2451                 (*env)->ExceptionDescribe(env);
2452                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2453         }
2454         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2455         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2456         if (get_jenv_res == JNI_EDETACHED) {
2457                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2458         }
2459         return ret_conv;
2460 }
2461 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2462         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2463         JNIEnv *env;
2464         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2465         if (get_jenv_res == JNI_EDETACHED) {
2466                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2467         } else {
2468                 DO_ASSERT(get_jenv_res == JNI_OK);
2469         }
2470         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2471         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2472         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2473         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2474         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2475         if (channel_parameters_var.is_owned) {
2476                 channel_parameters_ref |= 1;
2477         }
2478         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2479         CHECK(obj != NULL);
2480         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2481         if ((*env)->ExceptionCheck(env)) {
2482                 (*env)->ExceptionDescribe(env);
2483                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2484         }
2485         if (get_jenv_res == JNI_EDETACHED) {
2486                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2487         }
2488 }
2489 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2490         jclass c = (*env)->GetObjectClass(env, o);
2491         CHECK(c != NULL);
2492         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2493         atomic_init(&calls->refcnt, 1);
2494         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2495         calls->o = (*env)->NewWeakGlobalRef(env, o);
2496         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2497         CHECK(calls->get_per_commitment_point_meth != NULL);
2498         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2499         CHECK(calls->release_commitment_secret_meth != NULL);
2500         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2501         CHECK(calls->channel_keys_id_meth != NULL);
2502         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2503         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2504         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2505         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2506         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2507         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2508         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2509         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2510         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2511         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2512         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2513         CHECK(calls->sign_closing_transaction_meth != NULL);
2514         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2515         CHECK(calls->sign_channel_announcement_meth != NULL);
2516         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2517         CHECK(calls->ready_channel_meth != NULL);
2518
2519         LDKChannelPublicKeys pubkeys_conv;
2520         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2521         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2522         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2523
2524         LDKBaseSign ret = {
2525                 .this_arg = (void*) calls,
2526                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2527                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2528                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2529                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2530                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2531                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2532                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2533                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2534                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2535                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2536                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2537                 .free = LDKBaseSign_JCalls_free,
2538                 .pubkeys = pubkeys_conv,
2539                 .set_pubkeys = NULL,
2540         };
2541         return ret;
2542 }
2543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2544         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2545         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2546         return (uint64_t)res_ptr;
2547 }
2548 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) {
2549         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2550         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2552         return ret_arr;
2553 }
2554
2555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2556         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2557         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2559         return ret_arr;
2560 }
2561
2562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2563         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2564         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2565         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2566         return ret_arr;
2567 }
2568
2569 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) {
2570         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2571         LDKCommitmentTransaction 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_counterparty_commitment)(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_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
2580         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2581         LDKHolderCommitmentTransaction commitment_tx_conv;
2582         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2583         commitment_tx_conv.is_owned = false;
2584         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2585         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2586         return (uint64_t)ret_conv;
2587 }
2588
2589 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) {
2590         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2591         LDKTransaction justice_tx_ref;
2592         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2593         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2594         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2595         justice_tx_ref.data_is_owned = true;
2596         unsigned char per_commitment_key_arr[32];
2597         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2598         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2599         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2600         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2601         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2602         return (uint64_t)ret_conv;
2603 }
2604
2605 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) {
2606         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2607         LDKTransaction justice_tx_ref;
2608         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2609         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2610         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2611         justice_tx_ref.data_is_owned = true;
2612         unsigned char per_commitment_key_arr[32];
2613         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2614         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2615         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2616         LDKHTLCOutputInCommitment htlc_conv;
2617         htlc_conv.inner = (void*)(htlc & (~1));
2618         htlc_conv.is_owned = false;
2619         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2620         *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);
2621         return (uint64_t)ret_conv;
2622 }
2623
2624 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) {
2625         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2626         LDKTransaction htlc_tx_ref;
2627         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2628         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2629         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2630         htlc_tx_ref.data_is_owned = true;
2631         LDKPublicKey per_commitment_point_ref;
2632         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2633         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2634         LDKHTLCOutputInCommitment htlc_conv;
2635         htlc_conv.inner = (void*)(htlc & (~1));
2636         htlc_conv.is_owned = false;
2637         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2638         *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);
2639         return (uint64_t)ret_conv;
2640 }
2641
2642 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) {
2643         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2644         LDKTransaction closing_tx_ref;
2645         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2646         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2647         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2648         closing_tx_ref.data_is_owned = true;
2649         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2650         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2651         return (uint64_t)ret_conv;
2652 }
2653
2654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2655         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2656         LDKUnsignedChannelAnnouncement msg_conv;
2657         msg_conv.inner = (void*)(msg & (~1));
2658         msg_conv.is_owned = false;
2659         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2660         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2661         return (uint64_t)ret_conv;
2662 }
2663
2664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2665         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2666         LDKChannelTransactionParameters channel_parameters_conv;
2667         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2668         channel_parameters_conv.is_owned = false;
2669         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2670 }
2671
2672 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2673         if (this_arg->set_pubkeys != NULL)
2674                 this_arg->set_pubkeys(this_arg);
2675         return this_arg->pubkeys;
2676 }
2677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2678         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2679         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2682         uint64_t ret_ref = (uint64_t)ret_var.inner;
2683         if (ret_var.is_owned) {
2684                 ret_ref |= 1;
2685         }
2686         return ret_ref;
2687 }
2688
2689 typedef struct LDKSign_JCalls {
2690         atomic_size_t refcnt;
2691         JavaVM *vm;
2692         jweak o;
2693         LDKBaseSign_JCalls* BaseSign;
2694         jmethodID write_meth;
2695 } LDKSign_JCalls;
2696 static void LDKSign_JCalls_free(void* this_arg) {
2697         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2698         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2699                 JNIEnv *env;
2700                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2701                 if (get_jenv_res == JNI_EDETACHED) {
2702                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2703                 } else {
2704                         DO_ASSERT(get_jenv_res == JNI_OK);
2705                 }
2706                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2707                 if (get_jenv_res == JNI_EDETACHED) {
2708                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2709                 }
2710                 FREE(j_calls);
2711         }
2712 }
2713 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2714         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2715         JNIEnv *env;
2716         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2717         if (get_jenv_res == JNI_EDETACHED) {
2718                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2719         } else {
2720                 DO_ASSERT(get_jenv_res == JNI_OK);
2721         }
2722         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2723         CHECK(obj != NULL);
2724         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2725         if ((*env)->ExceptionCheck(env)) {
2726                 (*env)->ExceptionDescribe(env);
2727                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2728         }
2729         LDKCVec_u8Z ret_ref;
2730         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2731         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2732         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2733         if (get_jenv_res == JNI_EDETACHED) {
2734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2735         }
2736         return ret_ref;
2737 }
2738 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2739         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2740         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2741         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2742 }
2743 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2744         jclass c = (*env)->GetObjectClass(env, o);
2745         CHECK(c != NULL);
2746         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2747         atomic_init(&calls->refcnt, 1);
2748         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2749         calls->o = (*env)->NewWeakGlobalRef(env, o);
2750         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2751         CHECK(calls->write_meth != NULL);
2752
2753         LDKChannelPublicKeys pubkeys_conv;
2754         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2755         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2756         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2757
2758         LDKSign ret = {
2759                 .this_arg = (void*) calls,
2760                 .write = write_LDKSign_jcall,
2761                 .cloned = LDKSign_JCalls_cloned,
2762                 .free = LDKSign_JCalls_free,
2763                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2764         };
2765         calls->BaseSign = ret.BaseSign.this_arg;
2766         return ret;
2767 }
2768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2769         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2770         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2771         return (uint64_t)res_ptr;
2772 }
2773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2774         LDKSign *inp = (LDKSign *)(arg & ~1);
2775         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2776         DO_ASSERT((res_ptr & 1) == 0);
2777         return (int64_t)(res_ptr | 1);
2778 }
2779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2780         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2781         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2782         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2783         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2784         CVec_u8Z_free(ret_var);
2785         return ret_arr;
2786 }
2787
2788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2789         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2790 }
2791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2792         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2793         CHECK(val->result_ok);
2794         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2795         *ret = Sign_clone(&(*val->contents.result));
2796         return (uint64_t)ret;
2797 }
2798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2799         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2800         CHECK(!val->result_ok);
2801         LDKDecodeError err_var = (*val->contents.err);
2802         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2803         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2804         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2805         return err_ref;
2806 }
2807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2808         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2809 }
2810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2811         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2812         CHECK(val->result_ok);
2813         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2814         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2815         return es_arr;
2816 }
2817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2818         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2819         CHECK(!val->result_ok);
2820         return *val->contents.err;
2821 }
2822 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2823         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2824         for (size_t i = 0; i < ret.datalen; i++) {
2825                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2826         }
2827         return ret;
2828 }
2829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2830         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2831 }
2832 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2833         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2834         CHECK(val->result_ok);
2835         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2836         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2837         ;
2838         for (size_t i = 0; i < res_var.datalen; i++) {
2839                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2840                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2841                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2842                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2843         }
2844         return res_arr;
2845 }
2846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2847         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2848         CHECK(!val->result_ok);
2849         return *val->contents.err;
2850 }
2851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2852         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2853 }
2854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2855         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2856         CHECK(val->result_ok);
2857         LDKInMemorySigner res_var = (*val->contents.result);
2858         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2859         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2860         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2861         return res_ref;
2862 }
2863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2864         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2865         CHECK(!val->result_ok);
2866         LDKDecodeError err_var = (*val->contents.err);
2867         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2868         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2869         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2870         return err_ref;
2871 }
2872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2873         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2874         ret->datalen = (*env)->GetArrayLength(env, elems);
2875         if (ret->datalen == 0) {
2876                 ret->data = NULL;
2877         } else {
2878                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2879                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2880                 for (size_t i = 0; i < ret->datalen; i++) {
2881                         int64_t arr_elem = java_elems[i];
2882                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2883                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2884                         ret->data[i] = arr_elem_conv;
2885                 }
2886                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2887         }
2888         return (uint64_t)ret;
2889 }
2890 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2891         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2892         for (size_t i = 0; i < ret.datalen; i++) {
2893                 ret.data[i] = TxOut_clone(&orig->data[i]);
2894         }
2895         return ret;
2896 }
2897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2898         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2899 }
2900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2901         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2902         CHECK(val->result_ok);
2903         LDKTransaction res_var = (*val->contents.result);
2904         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2905         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2906         return res_arr;
2907 }
2908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2909         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2910         CHECK(!val->result_ok);
2911         return *val->contents.err;
2912 }
2913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2914         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2915         LDKThirtyTwoBytes a_ref;
2916         CHECK((*env)->GetArrayLength(env, a) == 32);
2917         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2918         ret->a = a_ref;
2919         LDKChannelMonitor b_conv;
2920         b_conv.inner = (void*)(b & (~1));
2921         b_conv.is_owned = (b & 1) || (b == 0);
2922         b_conv = ChannelMonitor_clone(&b_conv);
2923         ret->b = b_conv;
2924         return (uint64_t)ret;
2925 }
2926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2927         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2928         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2929         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2930         return a_arr;
2931 }
2932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2933         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2934         LDKChannelMonitor b_var = tuple->b;
2935         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2936         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2937         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2938         return b_ref;
2939 }
2940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2941         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2942         ret->datalen = (*env)->GetArrayLength(env, elems);
2943         if (ret->datalen == 0) {
2944                 ret->data = NULL;
2945         } else {
2946                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2947                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2948                 for (size_t i = 0; i < ret->datalen; i++) {
2949                         int64_t arr_elem = java_elems[i];
2950                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2951                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2952                         ret->data[i] = arr_elem_conv;
2953                 }
2954                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2955         }
2956         return (uint64_t)ret;
2957 }
2958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2959         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2960 }
2961 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2962         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2963         CHECK(val->result_ok);
2964         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2965         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2966         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2967         for (size_t i = 0; i < res_var.datalen; i++) {
2968                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2969                 res_arr_ptr[i] = res_conv_34_ref;
2970         }
2971         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2972         return res_arr;
2973 }
2974 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2975         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2976         CHECK(!val->result_ok);
2977         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2978         return err_conv;
2979 }
2980 static jclass LDKCOption_u16Z_Some_class = NULL;
2981 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
2982 static jclass LDKCOption_u16Z_None_class = NULL;
2983 static jmethodID LDKCOption_u16Z_None_meth = NULL;
2984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
2985         LDKCOption_u16Z_Some_class =
2986                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
2987         CHECK(LDKCOption_u16Z_Some_class != NULL);
2988         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
2989         CHECK(LDKCOption_u16Z_Some_meth != NULL);
2990         LDKCOption_u16Z_None_class =
2991                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
2992         CHECK(LDKCOption_u16Z_None_class != NULL);
2993         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
2994         CHECK(LDKCOption_u16Z_None_meth != NULL);
2995 }
2996 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2997         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2998         switch(obj->tag) {
2999                 case LDKCOption_u16Z_Some: {
3000                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3001                 }
3002                 case LDKCOption_u16Z_None: {
3003                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3004                 }
3005                 default: abort();
3006         }
3007 }
3008 static jclass LDKAPIError_APIMisuseError_class = NULL;
3009 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3010 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3011 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3012 static jclass LDKAPIError_RouteError_class = NULL;
3013 static jmethodID LDKAPIError_RouteError_meth = NULL;
3014 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3015 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3016 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3017 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3019         LDKAPIError_APIMisuseError_class =
3020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3021         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3022         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3023         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3024         LDKAPIError_FeeRateTooHigh_class =
3025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3026         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3027         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3028         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3029         LDKAPIError_RouteError_class =
3030                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3031         CHECK(LDKAPIError_RouteError_class != NULL);
3032         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3033         CHECK(LDKAPIError_RouteError_meth != NULL);
3034         LDKAPIError_ChannelUnavailable_class =
3035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3036         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3037         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3038         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3039         LDKAPIError_MonitorUpdateFailed_class =
3040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3041         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3042         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3043         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3044 }
3045 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3046         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3047         switch(obj->tag) {
3048                 case LDKAPIError_APIMisuseError: {
3049                         LDKStr err_str = obj->api_misuse_error.err;
3050                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3051                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3052                 }
3053                 case LDKAPIError_FeeRateTooHigh: {
3054                         LDKStr err_str = obj->fee_rate_too_high.err;
3055                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3056                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3057                 }
3058                 case LDKAPIError_RouteError: {
3059                         LDKStr err_str = obj->route_error.err;
3060                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3061                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3062                 }
3063                 case LDKAPIError_ChannelUnavailable: {
3064                         LDKStr err_str = obj->channel_unavailable.err;
3065                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3066                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3067                 }
3068                 case LDKAPIError_MonitorUpdateFailed: {
3069                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3070                 }
3071                 default: abort();
3072         }
3073 }
3074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3075         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3076 }
3077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3078         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3079         CHECK(val->result_ok);
3080         return *val->contents.result;
3081 }
3082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3083         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3084         CHECK(!val->result_ok);
3085         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3086         return err_ref;
3087 }
3088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3089         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3090         ret->datalen = (*env)->GetArrayLength(env, elems);
3091         if (ret->datalen == 0) {
3092                 ret->data = NULL;
3093         } else {
3094                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3095                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3096                 for (size_t i = 0; i < ret->datalen; i++) {
3097                         int64_t arr_elem = java_elems[i];
3098                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3099                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3100                         ret->data[i] = arr_elem_conv;
3101                 }
3102                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3103         }
3104         return (uint64_t)ret;
3105 }
3106 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3107         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3108         for (size_t i = 0; i < ret.datalen; i++) {
3109                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3110         }
3111         return ret;
3112 }
3113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3114         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3115         ret->datalen = (*env)->GetArrayLength(env, elems);
3116         if (ret->datalen == 0) {
3117                 ret->data = NULL;
3118         } else {
3119                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3120                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3121                 for (size_t i = 0; i < ret->datalen; i++) {
3122                         int64_t arr_elem = java_elems[i];
3123                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3124                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3125                         ret->data[i] = arr_elem_conv;
3126                 }
3127                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3128         }
3129         return (uint64_t)ret;
3130 }
3131 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3132         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3133         for (size_t i = 0; i < ret.datalen; i++) {
3134                 ret.data[i] = APIError_clone(&orig->data[i]);
3135         }
3136         return ret;
3137 }
3138 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3139 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3140 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3141 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3142 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3143 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3144 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3145 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3147         LDKPaymentSendFailure_ParameterError_class =
3148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3149         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3150         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3151         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3152         LDKPaymentSendFailure_PathParameterError_class =
3153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3154         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3155         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3156         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3157         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3159         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3160         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3161         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3162         LDKPaymentSendFailure_PartialFailure_class =
3163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3164         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3165         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3166         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3167 }
3168 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3169         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3170         switch(obj->tag) {
3171                 case LDKPaymentSendFailure_ParameterError: {
3172                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3173                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3174                 }
3175                 case LDKPaymentSendFailure_PathParameterError: {
3176                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3177                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3178                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3179                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3180                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3181                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3182                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3183                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3184                         }
3185                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3186                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3187                 }
3188                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3189                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3190                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3191                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3192                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3193                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3194                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3195                         }
3196                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3197                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3198                 }
3199                 case LDKPaymentSendFailure_PartialFailure: {
3200                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3201                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3202                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3203                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3204                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3205                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3206                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3207                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3208                         }
3209                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3210                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3211                 }
3212                 default: abort();
3213         }
3214 }
3215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3216         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3217 }
3218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3219         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3220         CHECK(val->result_ok);
3221         return *val->contents.result;
3222 }
3223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3224         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3225         CHECK(!val->result_ok);
3226         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3227         return err_ref;
3228 }
3229 static jclass LDKNetAddress_IPv4_class = NULL;
3230 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3231 static jclass LDKNetAddress_IPv6_class = NULL;
3232 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3233 static jclass LDKNetAddress_OnionV2_class = NULL;
3234 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3235 static jclass LDKNetAddress_OnionV3_class = NULL;
3236 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3238         LDKNetAddress_IPv4_class =
3239                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3240         CHECK(LDKNetAddress_IPv4_class != NULL);
3241         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3242         CHECK(LDKNetAddress_IPv4_meth != NULL);
3243         LDKNetAddress_IPv6_class =
3244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3245         CHECK(LDKNetAddress_IPv6_class != NULL);
3246         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3247         CHECK(LDKNetAddress_IPv6_meth != NULL);
3248         LDKNetAddress_OnionV2_class =
3249                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3250         CHECK(LDKNetAddress_OnionV2_class != NULL);
3251         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3252         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3253         LDKNetAddress_OnionV3_class =
3254                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3255         CHECK(LDKNetAddress_OnionV3_class != NULL);
3256         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3257         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3258 }
3259 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3260         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3261         switch(obj->tag) {
3262                 case LDKNetAddress_IPv4: {
3263                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3264                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3265                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3266                 }
3267                 case LDKNetAddress_IPv6: {
3268                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3269                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3270                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3271                 }
3272                 case LDKNetAddress_OnionV2: {
3273                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3274                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3275                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3276                 }
3277                 case LDKNetAddress_OnionV3: {
3278                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3279                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3280                         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);
3281                 }
3282                 default: abort();
3283         }
3284 }
3285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3286         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3287         ret->datalen = (*env)->GetArrayLength(env, elems);
3288         if (ret->datalen == 0) {
3289                 ret->data = NULL;
3290         } else {
3291                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3292                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3293                 for (size_t i = 0; i < ret->datalen; i++) {
3294                         int64_t arr_elem = java_elems[i];
3295                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3296                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3297                         ret->data[i] = arr_elem_conv;
3298                 }
3299                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3300         }
3301         return (uint64_t)ret;
3302 }
3303 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3304         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3305         for (size_t i = 0; i < ret.datalen; i++) {
3306                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3307         }
3308         return ret;
3309 }
3310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3311         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3312         LDKThirtyTwoBytes a_ref;
3313         CHECK((*env)->GetArrayLength(env, a) == 32);
3314         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3315         ret->a = a_ref;
3316         LDKThirtyTwoBytes b_ref;
3317         CHECK((*env)->GetArrayLength(env, b) == 32);
3318         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3319         ret->b = b_ref;
3320         return (uint64_t)ret;
3321 }
3322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3323         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3324         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3325         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3326         return a_arr;
3327 }
3328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3329         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3330         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3331         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3332         return b_arr;
3333 }
3334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3335         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3336 }
3337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3338         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3339         CHECK(val->result_ok);
3340         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3341         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3342         return res_arr;
3343 }
3344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3345         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3346         CHECK(!val->result_ok);
3347         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3348         return err_ref;
3349 }
3350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3351         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3352         ret->datalen = (*env)->GetArrayLength(env, elems);
3353         if (ret->datalen == 0) {
3354                 ret->data = NULL;
3355         } else {
3356                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3357                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3358                 for (size_t i = 0; i < ret->datalen; i++) {
3359                         int64_t arr_elem = java_elems[i];
3360                         LDKChannelMonitor arr_elem_conv;
3361                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3362                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3363                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3364                         ret->data[i] = arr_elem_conv;
3365                 }
3366                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3367         }
3368         return (uint64_t)ret;
3369 }
3370 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3371         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3372         for (size_t i = 0; i < ret.datalen; i++) {
3373                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3374         }
3375         return ret;
3376 }
3377 typedef struct LDKWatch_JCalls {
3378         atomic_size_t refcnt;
3379         JavaVM *vm;
3380         jweak o;
3381         jmethodID watch_channel_meth;
3382         jmethodID update_channel_meth;
3383         jmethodID release_pending_monitor_events_meth;
3384 } LDKWatch_JCalls;
3385 static void LDKWatch_JCalls_free(void* this_arg) {
3386         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3387         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3388                 JNIEnv *env;
3389                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3390                 if (get_jenv_res == JNI_EDETACHED) {
3391                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3392                 } else {
3393                         DO_ASSERT(get_jenv_res == JNI_OK);
3394                 }
3395                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3396                 if (get_jenv_res == JNI_EDETACHED) {
3397                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3398                 }
3399                 FREE(j_calls);
3400         }
3401 }
3402 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3403         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3404         JNIEnv *env;
3405         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3406         if (get_jenv_res == JNI_EDETACHED) {
3407                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3408         } else {
3409                 DO_ASSERT(get_jenv_res == JNI_OK);
3410         }
3411         LDKOutPoint funding_txo_var = funding_txo;
3412         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3413         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3414         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3415         if (funding_txo_var.is_owned) {
3416                 funding_txo_ref |= 1;
3417         }
3418         LDKChannelMonitor monitor_var = monitor;
3419         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3420         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3421         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3422         if (monitor_var.is_owned) {
3423                 monitor_ref |= 1;
3424         }
3425         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3426         CHECK(obj != NULL);
3427         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3428         if ((*env)->ExceptionCheck(env)) {
3429                 (*env)->ExceptionDescribe(env);
3430                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3431         }
3432         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3433         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3434         if (get_jenv_res == JNI_EDETACHED) {
3435                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3436         }
3437         return ret_conv;
3438 }
3439 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3440         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3441         JNIEnv *env;
3442         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3443         if (get_jenv_res == JNI_EDETACHED) {
3444                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3445         } else {
3446                 DO_ASSERT(get_jenv_res == JNI_OK);
3447         }
3448         LDKOutPoint funding_txo_var = funding_txo;
3449         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3450         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3451         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3452         if (funding_txo_var.is_owned) {
3453                 funding_txo_ref |= 1;
3454         }
3455         LDKChannelMonitorUpdate update_var = update;
3456         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3457         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3458         uint64_t update_ref = (uint64_t)update_var.inner;
3459         if (update_var.is_owned) {
3460                 update_ref |= 1;
3461         }
3462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3463         CHECK(obj != NULL);
3464         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3465         if ((*env)->ExceptionCheck(env)) {
3466                 (*env)->ExceptionDescribe(env);
3467                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3468         }
3469         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3470         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3471         if (get_jenv_res == JNI_EDETACHED) {
3472                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3473         }
3474         return ret_conv;
3475 }
3476 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3477         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3478         JNIEnv *env;
3479         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3480         if (get_jenv_res == JNI_EDETACHED) {
3481                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3482         } else {
3483                 DO_ASSERT(get_jenv_res == JNI_OK);
3484         }
3485         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3486         CHECK(obj != NULL);
3487         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3488         if ((*env)->ExceptionCheck(env)) {
3489                 (*env)->ExceptionDescribe(env);
3490                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3491         }
3492         LDKCVec_MonitorEventZ ret_constr;
3493         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3494         if (ret_constr.datalen > 0)
3495                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3496         else
3497                 ret_constr.data = NULL;
3498         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3499         for (size_t o = 0; o < ret_constr.datalen; o++) {
3500                 int64_t ret_conv_14 = ret_vals[o];
3501                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3502                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3503                 ret_constr.data[o] = ret_conv_14_conv;
3504         }
3505         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3506         if (get_jenv_res == JNI_EDETACHED) {
3507                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3508         }
3509         return ret_constr;
3510 }
3511 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3512         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3513         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3514 }
3515 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3516         jclass c = (*env)->GetObjectClass(env, o);
3517         CHECK(c != NULL);
3518         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3519         atomic_init(&calls->refcnt, 1);
3520         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3521         calls->o = (*env)->NewWeakGlobalRef(env, o);
3522         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3523         CHECK(calls->watch_channel_meth != NULL);
3524         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3525         CHECK(calls->update_channel_meth != NULL);
3526         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3527         CHECK(calls->release_pending_monitor_events_meth != NULL);
3528
3529         LDKWatch ret = {
3530                 .this_arg = (void*) calls,
3531                 .watch_channel = watch_channel_LDKWatch_jcall,
3532                 .update_channel = update_channel_LDKWatch_jcall,
3533                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3534                 .free = LDKWatch_JCalls_free,
3535         };
3536         return ret;
3537 }
3538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3539         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3540         *res_ptr = LDKWatch_init(env, clz, o);
3541         return (uint64_t)res_ptr;
3542 }
3543 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) {
3544         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3545         LDKOutPoint funding_txo_conv;
3546         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3547         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3548         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3549         LDKChannelMonitor monitor_conv;
3550         monitor_conv.inner = (void*)(monitor & (~1));
3551         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3552         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3553         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3554         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3555         return (uint64_t)ret_conv;
3556 }
3557
3558 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) {
3559         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3560         LDKOutPoint funding_txo_conv;
3561         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3562         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3563         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3564         LDKChannelMonitorUpdate update_conv;
3565         update_conv.inner = (void*)(update & (~1));
3566         update_conv.is_owned = (update & 1) || (update == 0);
3567         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3568         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3569         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3570         return (uint64_t)ret_conv;
3571 }
3572
3573 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3574         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3575         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3576         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3577         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3578         for (size_t o = 0; o < ret_var.datalen; o++) {
3579                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3580                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3581                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3582                 ret_arr_ptr[o] = ret_conv_14_ref;
3583         }
3584         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3585         FREE(ret_var.data);
3586         return ret_arr;
3587 }
3588
3589 typedef struct LDKBroadcasterInterface_JCalls {
3590         atomic_size_t refcnt;
3591         JavaVM *vm;
3592         jweak o;
3593         jmethodID broadcast_transaction_meth;
3594 } LDKBroadcasterInterface_JCalls;
3595 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3596         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3597         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3598                 JNIEnv *env;
3599                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3600                 if (get_jenv_res == JNI_EDETACHED) {
3601                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3602                 } else {
3603                         DO_ASSERT(get_jenv_res == JNI_OK);
3604                 }
3605                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3606                 if (get_jenv_res == JNI_EDETACHED) {
3607                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3608                 }
3609                 FREE(j_calls);
3610         }
3611 }
3612 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3613         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3614         JNIEnv *env;
3615         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3616         if (get_jenv_res == JNI_EDETACHED) {
3617                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3618         } else {
3619                 DO_ASSERT(get_jenv_res == JNI_OK);
3620         }
3621         LDKTransaction tx_var = tx;
3622         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3623         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3624         Transaction_free(tx_var);
3625         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3626         CHECK(obj != NULL);
3627         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3628         if ((*env)->ExceptionCheck(env)) {
3629                 (*env)->ExceptionDescribe(env);
3630                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3631         }
3632         if (get_jenv_res == JNI_EDETACHED) {
3633                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3634         }
3635 }
3636 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3637         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3638         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3639 }
3640 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3641         jclass c = (*env)->GetObjectClass(env, o);
3642         CHECK(c != NULL);
3643         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3644         atomic_init(&calls->refcnt, 1);
3645         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3646         calls->o = (*env)->NewWeakGlobalRef(env, o);
3647         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3648         CHECK(calls->broadcast_transaction_meth != NULL);
3649
3650         LDKBroadcasterInterface ret = {
3651                 .this_arg = (void*) calls,
3652                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3653                 .free = LDKBroadcasterInterface_JCalls_free,
3654         };
3655         return ret;
3656 }
3657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3658         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3659         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3660         return (uint64_t)res_ptr;
3661 }
3662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3663         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3664         LDKTransaction tx_ref;
3665         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3666         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3667         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3668         tx_ref.data_is_owned = true;
3669         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3670 }
3671
3672 typedef struct LDKKeysInterface_JCalls {
3673         atomic_size_t refcnt;
3674         JavaVM *vm;
3675         jweak o;
3676         jmethodID get_node_secret_meth;
3677         jmethodID get_destination_script_meth;
3678         jmethodID get_shutdown_pubkey_meth;
3679         jmethodID get_channel_signer_meth;
3680         jmethodID get_secure_random_bytes_meth;
3681         jmethodID read_chan_signer_meth;
3682         jmethodID sign_invoice_meth;
3683 } LDKKeysInterface_JCalls;
3684 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3685         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3686         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3687                 JNIEnv *env;
3688                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3689                 if (get_jenv_res == JNI_EDETACHED) {
3690                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3691                 } else {
3692                         DO_ASSERT(get_jenv_res == JNI_OK);
3693                 }
3694                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3695                 if (get_jenv_res == JNI_EDETACHED) {
3696                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3697                 }
3698                 FREE(j_calls);
3699         }
3700 }
3701 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3702         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3703         JNIEnv *env;
3704         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3705         if (get_jenv_res == JNI_EDETACHED) {
3706                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3707         } else {
3708                 DO_ASSERT(get_jenv_res == JNI_OK);
3709         }
3710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3711         CHECK(obj != NULL);
3712         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3713         if ((*env)->ExceptionCheck(env)) {
3714                 (*env)->ExceptionDescribe(env);
3715                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3716         }
3717         LDKSecretKey ret_ref;
3718         CHECK((*env)->GetArrayLength(env, ret) == 32);
3719         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3720         if (get_jenv_res == JNI_EDETACHED) {
3721                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3722         }
3723         return ret_ref;
3724 }
3725 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3726         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3727         JNIEnv *env;
3728         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3729         if (get_jenv_res == JNI_EDETACHED) {
3730                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3731         } else {
3732                 DO_ASSERT(get_jenv_res == JNI_OK);
3733         }
3734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3735         CHECK(obj != NULL);
3736         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3737         if ((*env)->ExceptionCheck(env)) {
3738                 (*env)->ExceptionDescribe(env);
3739                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3740         }
3741         LDKCVec_u8Z ret_ref;
3742         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3743         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3744         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3745         if (get_jenv_res == JNI_EDETACHED) {
3746                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3747         }
3748         return ret_ref;
3749 }
3750 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3751         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3752         JNIEnv *env;
3753         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3754         if (get_jenv_res == JNI_EDETACHED) {
3755                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3756         } else {
3757                 DO_ASSERT(get_jenv_res == JNI_OK);
3758         }
3759         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3760         CHECK(obj != NULL);
3761         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3762         if ((*env)->ExceptionCheck(env)) {
3763                 (*env)->ExceptionDescribe(env);
3764                 (*env)->FatalError(env, "A call to get_shutdown_pubkey in LDKKeysInterface from rust threw an exception.");
3765         }
3766         LDKPublicKey ret_ref;
3767         CHECK((*env)->GetArrayLength(env, ret) == 33);
3768         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3769         if (get_jenv_res == JNI_EDETACHED) {
3770                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3771         }
3772         return ret_ref;
3773 }
3774 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3775         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3776         JNIEnv *env;
3777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3778         if (get_jenv_res == JNI_EDETACHED) {
3779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3780         } else {
3781                 DO_ASSERT(get_jenv_res == JNI_OK);
3782         }
3783         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3784         CHECK(obj != NULL);
3785         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3786         if ((*env)->ExceptionCheck(env)) {
3787                 (*env)->ExceptionDescribe(env);
3788                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3789         }
3790         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3791         ret_conv = Sign_clone(ret);
3792         if (get_jenv_res == JNI_EDETACHED) {
3793                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3794         }
3795         return ret_conv;
3796 }
3797 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3798         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3799         JNIEnv *env;
3800         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3801         if (get_jenv_res == JNI_EDETACHED) {
3802                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3803         } else {
3804                 DO_ASSERT(get_jenv_res == JNI_OK);
3805         }
3806         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3807         CHECK(obj != NULL);
3808         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3809         if ((*env)->ExceptionCheck(env)) {
3810                 (*env)->ExceptionDescribe(env);
3811                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3812         }
3813         LDKThirtyTwoBytes ret_ref;
3814         CHECK((*env)->GetArrayLength(env, ret) == 32);
3815         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3816         if (get_jenv_res == JNI_EDETACHED) {
3817                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3818         }
3819         return ret_ref;
3820 }
3821 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3822         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3823         JNIEnv *env;
3824         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3825         if (get_jenv_res == JNI_EDETACHED) {
3826                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3827         } else {
3828                 DO_ASSERT(get_jenv_res == JNI_OK);
3829         }
3830         LDKu8slice reader_var = reader;
3831         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3832         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3834         CHECK(obj != NULL);
3835         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3836         if ((*env)->ExceptionCheck(env)) {
3837                 (*env)->ExceptionDescribe(env);
3838                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3839         }
3840         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3841         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3842         if (get_jenv_res == JNI_EDETACHED) {
3843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3844         }
3845         return ret_conv;
3846 }
3847 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3848         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3849         JNIEnv *env;
3850         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3851         if (get_jenv_res == JNI_EDETACHED) {
3852                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3853         } else {
3854                 DO_ASSERT(get_jenv_res == JNI_OK);
3855         }
3856         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3857         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3858         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3859         CVec_u8Z_free(invoice_preimage_var);
3860         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3861         CHECK(obj != NULL);
3862         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3863         if ((*env)->ExceptionCheck(env)) {
3864                 (*env)->ExceptionDescribe(env);
3865                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3866         }
3867         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3868         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3869         if (get_jenv_res == JNI_EDETACHED) {
3870                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3871         }
3872         return ret_conv;
3873 }
3874 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3875         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3876         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3877 }
3878 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3879         jclass c = (*env)->GetObjectClass(env, o);
3880         CHECK(c != NULL);
3881         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3882         atomic_init(&calls->refcnt, 1);
3883         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3884         calls->o = (*env)->NewWeakGlobalRef(env, o);
3885         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3886         CHECK(calls->get_node_secret_meth != NULL);
3887         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3888         CHECK(calls->get_destination_script_meth != NULL);
3889         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3890         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3891         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3892         CHECK(calls->get_channel_signer_meth != NULL);
3893         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3894         CHECK(calls->get_secure_random_bytes_meth != NULL);
3895         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3896         CHECK(calls->read_chan_signer_meth != NULL);
3897         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3898         CHECK(calls->sign_invoice_meth != NULL);
3899
3900         LDKKeysInterface ret = {
3901                 .this_arg = (void*) calls,
3902                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3903                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3904                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3905                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3906                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3907                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3908                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3909                 .free = LDKKeysInterface_JCalls_free,
3910         };
3911         return ret;
3912 }
3913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3914         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3915         *res_ptr = LDKKeysInterface_init(env, clz, o);
3916         return (uint64_t)res_ptr;
3917 }
3918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3919         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3920         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3922         return ret_arr;
3923 }
3924
3925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3926         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3927         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3928         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3929         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3930         CVec_u8Z_free(ret_var);
3931         return ret_arr;
3932 }
3933
3934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3935         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3936         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3938         return ret_arr;
3939 }
3940
3941 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) {
3942         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3943         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3944         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3945         return (uint64_t)ret;
3946 }
3947
3948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3949         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3950         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3951         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3952         return ret_arr;
3953 }
3954
3955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3956         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3957         LDKu8slice reader_ref;
3958         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3959         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3960         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3961         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3962         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3963         return (uint64_t)ret_conv;
3964 }
3965
3966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3967         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3968         LDKCVec_u8Z invoice_preimage_ref;
3969         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3970         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3971         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3972         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3973         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3974         return (uint64_t)ret_conv;
3975 }
3976
3977 typedef struct LDKFeeEstimator_JCalls {
3978         atomic_size_t refcnt;
3979         JavaVM *vm;
3980         jweak o;
3981         jmethodID get_est_sat_per_1000_weight_meth;
3982 } LDKFeeEstimator_JCalls;
3983 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3984         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3985         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3986                 JNIEnv *env;
3987                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3988                 if (get_jenv_res == JNI_EDETACHED) {
3989                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3990                 } else {
3991                         DO_ASSERT(get_jenv_res == JNI_OK);
3992                 }
3993                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3994                 if (get_jenv_res == JNI_EDETACHED) {
3995                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3996                 }
3997                 FREE(j_calls);
3998         }
3999 }
4000 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4001         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4002         JNIEnv *env;
4003         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4004         if (get_jenv_res == JNI_EDETACHED) {
4005                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4006         } else {
4007                 DO_ASSERT(get_jenv_res == JNI_OK);
4008         }
4009         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4010         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4011         CHECK(obj != NULL);
4012         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4013         if ((*env)->ExceptionCheck(env)) {
4014                 (*env)->ExceptionDescribe(env);
4015                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4016         }
4017         if (get_jenv_res == JNI_EDETACHED) {
4018                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4019         }
4020         return ret;
4021 }
4022 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4023         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4024         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4025 }
4026 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4027         jclass c = (*env)->GetObjectClass(env, o);
4028         CHECK(c != NULL);
4029         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4030         atomic_init(&calls->refcnt, 1);
4031         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4032         calls->o = (*env)->NewWeakGlobalRef(env, o);
4033         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4034         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4035
4036         LDKFeeEstimator ret = {
4037                 .this_arg = (void*) calls,
4038                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4039                 .free = LDKFeeEstimator_JCalls_free,
4040         };
4041         return ret;
4042 }
4043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4044         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4045         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4046         return (uint64_t)res_ptr;
4047 }
4048 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) {
4049         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4050         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4051         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4052         return ret_val;
4053 }
4054
4055 typedef struct LDKLogger_JCalls {
4056         atomic_size_t refcnt;
4057         JavaVM *vm;
4058         jweak o;
4059         jmethodID log_meth;
4060 } LDKLogger_JCalls;
4061 static void LDKLogger_JCalls_free(void* this_arg) {
4062         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4063         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4064                 JNIEnv *env;
4065                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4066                 if (get_jenv_res == JNI_EDETACHED) {
4067                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4068                 } else {
4069                         DO_ASSERT(get_jenv_res == JNI_OK);
4070                 }
4071                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4072                 if (get_jenv_res == JNI_EDETACHED) {
4073                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4074                 }
4075                 FREE(j_calls);
4076         }
4077 }
4078 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4079         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4080         JNIEnv *env;
4081         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4082         if (get_jenv_res == JNI_EDETACHED) {
4083                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4084         } else {
4085                 DO_ASSERT(get_jenv_res == JNI_OK);
4086         }
4087         const char* record_str = record;
4088         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4089         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4090         CHECK(obj != NULL);
4091         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4092         if ((*env)->ExceptionCheck(env)) {
4093                 (*env)->ExceptionDescribe(env);
4094                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4095         }
4096         if (get_jenv_res == JNI_EDETACHED) {
4097                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4098         }
4099 }
4100 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4101         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4102         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4103 }
4104 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4105         jclass c = (*env)->GetObjectClass(env, o);
4106         CHECK(c != NULL);
4107         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4108         atomic_init(&calls->refcnt, 1);
4109         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4110         calls->o = (*env)->NewWeakGlobalRef(env, o);
4111         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4112         CHECK(calls->log_meth != NULL);
4113
4114         LDKLogger ret = {
4115                 .this_arg = (void*) calls,
4116                 .log = log_LDKLogger_jcall,
4117                 .free = LDKLogger_JCalls_free,
4118         };
4119         return ret;
4120 }
4121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4122         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4123         *res_ptr = LDKLogger_init(env, clz, o);
4124         return (uint64_t)res_ptr;
4125 }
4126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4127         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4128         LDKThirtyTwoBytes a_ref;
4129         CHECK((*env)->GetArrayLength(env, a) == 32);
4130         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4131         ret->a = a_ref;
4132         LDKChannelManager b_conv;
4133         b_conv.inner = (void*)(b & (~1));
4134         b_conv.is_owned = (b & 1) || (b == 0);
4135         // Warning: we need a move here but no clone is available for LDKChannelManager
4136         ret->b = b_conv;
4137         return (uint64_t)ret;
4138 }
4139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4140         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4141         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4142         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4143         return a_arr;
4144 }
4145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4146         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4147         LDKChannelManager b_var = tuple->b;
4148         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4149         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4150         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4151         return b_ref;
4152 }
4153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4154         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4155 }
4156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4157         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4158         CHECK(val->result_ok);
4159         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4160         return res_ref;
4161 }
4162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4163         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4164         CHECK(!val->result_ok);
4165         LDKDecodeError err_var = (*val->contents.err);
4166         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4167         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4168         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4169         return err_ref;
4170 }
4171 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4172         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4173 }
4174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4175         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4176         CHECK(val->result_ok);
4177         LDKChannelConfig res_var = (*val->contents.result);
4178         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4179         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4180         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4181         return res_ref;
4182 }
4183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4184         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4185         CHECK(!val->result_ok);
4186         LDKDecodeError err_var = (*val->contents.err);
4187         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4188         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4189         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4190         return err_ref;
4191 }
4192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4193         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4194 }
4195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4196         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4197         CHECK(val->result_ok);
4198         LDKOutPoint res_var = (*val->contents.result);
4199         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4200         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4201         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4202         return res_ref;
4203 }
4204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4205         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4206         CHECK(!val->result_ok);
4207         LDKDecodeError err_var = (*val->contents.err);
4208         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4209         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4210         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4211         return err_ref;
4212 }
4213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4214         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4215 }
4216 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4217         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4218         CHECK(val->result_ok);
4219         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4220         return res_conv;
4221 }
4222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4223         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4224         CHECK(!val->result_ok);
4225         return *val->contents.err;
4226 }
4227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4228         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4229 }
4230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4231         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4232         CHECK(val->result_ok);
4233         LDKInvoice res_var = (*val->contents.result);
4234         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4235         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4236         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4237         return res_ref;
4238 }
4239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4240         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4241         CHECK(!val->result_ok);
4242         return *val->contents.err;
4243 }
4244 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4245         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4246 }
4247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4248         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4249         CHECK(val->result_ok);
4250         LDKSignedRawInvoice res_var = (*val->contents.result);
4251         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4252         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4253         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4254         return res_ref;
4255 }
4256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4257         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4258         CHECK(!val->result_ok);
4259         return *val->contents.err;
4260 }
4261 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) {
4262         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4263         LDKRawInvoice a_conv;
4264         a_conv.inner = (void*)(a & (~1));
4265         a_conv.is_owned = (a & 1) || (a == 0);
4266         a_conv = RawInvoice_clone(&a_conv);
4267         ret->a = a_conv;
4268         LDKThirtyTwoBytes b_ref;
4269         CHECK((*env)->GetArrayLength(env, b) == 32);
4270         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4271         ret->b = b_ref;
4272         LDKInvoiceSignature c_conv;
4273         c_conv.inner = (void*)(c & (~1));
4274         c_conv.is_owned = (c & 1) || (c == 0);
4275         c_conv = InvoiceSignature_clone(&c_conv);
4276         ret->c = c_conv;
4277         return (uint64_t)ret;
4278 }
4279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4280         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4281         LDKRawInvoice a_var = tuple->a;
4282         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4283         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4284         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4285         return a_ref;
4286 }
4287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4288         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4289         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4290         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4291         return b_arr;
4292 }
4293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4294         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4295         LDKInvoiceSignature c_var = tuple->c;
4296         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4297         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4298         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4299         return c_ref;
4300 }
4301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4302         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4303 }
4304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4305         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4306         CHECK(val->result_ok);
4307         LDKPayeePubKey res_var = (*val->contents.result);
4308         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4309         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4310         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4311         return res_ref;
4312 }
4313 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4314         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4315         CHECK(!val->result_ok);
4316         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4317         return err_conv;
4318 }
4319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4320         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4321         ret->datalen = (*env)->GetArrayLength(env, elems);
4322         if (ret->datalen == 0) {
4323                 ret->data = NULL;
4324         } else {
4325                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4326                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4327                 for (size_t i = 0; i < ret->datalen; i++) {
4328                         int64_t arr_elem = java_elems[i];
4329                         LDKPrivateRoute arr_elem_conv;
4330                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4331                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4332                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4333                         ret->data[i] = arr_elem_conv;
4334                 }
4335                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4336         }
4337         return (uint64_t)ret;
4338 }
4339 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4340         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4341         for (size_t i = 0; i < ret.datalen; i++) {
4342                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4343         }
4344         return ret;
4345 }
4346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4347         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4348 }
4349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4350         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4351         CHECK(val->result_ok);
4352         LDKPositiveTimestamp res_var = (*val->contents.result);
4353         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4354         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4355         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4356         return res_ref;
4357 }
4358 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4359         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4360         CHECK(!val->result_ok);
4361         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4362         return err_conv;
4363 }
4364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4365         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4366 }
4367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4368         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4369         CHECK(val->result_ok);
4370         return *val->contents.result;
4371 }
4372 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4373         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4374         CHECK(!val->result_ok);
4375         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4376         return err_conv;
4377 }
4378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4379         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4380 }
4381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4382         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4383         CHECK(val->result_ok);
4384         LDKInvoice res_var = (*val->contents.result);
4385         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4386         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4387         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4388         return res_ref;
4389 }
4390 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4391         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4392         CHECK(!val->result_ok);
4393         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4394         return err_conv;
4395 }
4396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4397         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4398 }
4399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4400         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4401         CHECK(val->result_ok);
4402         LDKDescription res_var = (*val->contents.result);
4403         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4404         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4405         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4406         return res_ref;
4407 }
4408 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4409         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4410         CHECK(!val->result_ok);
4411         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4412         return err_conv;
4413 }
4414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4415         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4416 }
4417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4418         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4419         CHECK(val->result_ok);
4420         LDKExpiryTime res_var = (*val->contents.result);
4421         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4422         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4423         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4424         return res_ref;
4425 }
4426 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4427         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4428         CHECK(!val->result_ok);
4429         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4430         return err_conv;
4431 }
4432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4433         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4434 }
4435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4436         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4437         CHECK(val->result_ok);
4438         LDKPrivateRoute res_var = (*val->contents.result);
4439         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4440         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4441         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4442         return res_ref;
4443 }
4444 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4445         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4446         CHECK(!val->result_ok);
4447         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4448         return err_conv;
4449 }
4450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4451         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4452 }
4453 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4454         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4455         CHECK(val->result_ok);
4456         LDKStr res_str = (*val->contents.result);
4457         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4458         return res_conv;
4459 }
4460 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4461         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4462         CHECK(!val->result_ok);
4463         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4464         return err_conv;
4465 }
4466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4467         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4468 }
4469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4470         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4471         CHECK(val->result_ok);
4472         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4473         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4474         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4475         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4476         return res_ref;
4477 }
4478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4479         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4480         CHECK(!val->result_ok);
4481         LDKDecodeError err_var = (*val->contents.err);
4482         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4483         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4484         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4485         return err_ref;
4486 }
4487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4488         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4489 }
4490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4491         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4492         CHECK(val->result_ok);
4493         LDKHTLCUpdate res_var = (*val->contents.result);
4494         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4495         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4496         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4497         return res_ref;
4498 }
4499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4500         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4501         CHECK(!val->result_ok);
4502         LDKDecodeError err_var = (*val->contents.err);
4503         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4504         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4505         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4506         return err_ref;
4507 }
4508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4509         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4510 }
4511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4512         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4513         CHECK(val->result_ok);
4514         return *val->contents.result;
4515 }
4516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4517         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4518         CHECK(!val->result_ok);
4519         LDKMonitorUpdateError err_var = (*val->contents.err);
4520         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4521         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4522         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4523         return err_ref;
4524 }
4525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4526         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4527         LDKOutPoint a_conv;
4528         a_conv.inner = (void*)(a & (~1));
4529         a_conv.is_owned = (a & 1) || (a == 0);
4530         a_conv = OutPoint_clone(&a_conv);
4531         ret->a = a_conv;
4532         LDKCVec_u8Z b_ref;
4533         b_ref.datalen = (*env)->GetArrayLength(env, b);
4534         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4535         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4536         ret->b = b_ref;
4537         return (uint64_t)ret;
4538 }
4539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4540         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4541         LDKOutPoint a_var = tuple->a;
4542         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4543         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4544         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4545         return a_ref;
4546 }
4547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4548         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4549         LDKCVec_u8Z b_var = tuple->b;
4550         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4551         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4552         return b_arr;
4553 }
4554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4555         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4556         ret->a = a;
4557         LDKCVec_u8Z b_ref;
4558         b_ref.datalen = (*env)->GetArrayLength(env, b);
4559         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4560         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4561         ret->b = b_ref;
4562         return (uint64_t)ret;
4563 }
4564 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4565         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4566         return tuple->a;
4567 }
4568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4569         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4570         LDKCVec_u8Z b_var = tuple->b;
4571         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4572         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4573         return b_arr;
4574 }
4575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4576         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4577         ret->datalen = (*env)->GetArrayLength(env, elems);
4578         if (ret->datalen == 0) {
4579                 ret->data = NULL;
4580         } else {
4581                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4582                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4583                 for (size_t i = 0; i < ret->datalen; i++) {
4584                         int64_t arr_elem = java_elems[i];
4585                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4586                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4587                         ret->data[i] = arr_elem_conv;
4588                 }
4589                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4590         }
4591         return (uint64_t)ret;
4592 }
4593 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4594         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4595         for (size_t i = 0; i < ret.datalen; i++) {
4596                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4597         }
4598         return ret;
4599 }
4600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4601         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4602         LDKThirtyTwoBytes a_ref;
4603         CHECK((*env)->GetArrayLength(env, a) == 32);
4604         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4605         ret->a = a_ref;
4606         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4607         b_constr.datalen = (*env)->GetArrayLength(env, b);
4608         if (b_constr.datalen > 0)
4609                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4610         else
4611                 b_constr.data = NULL;
4612         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4613         for (size_t b = 0; b < b_constr.datalen; b++) {
4614                 int64_t b_conv_27 = b_vals[b];
4615                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4616                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4617                 b_constr.data[b] = b_conv_27_conv;
4618         }
4619         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4620         ret->b = b_constr;
4621         return (uint64_t)ret;
4622 }
4623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4624         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4625         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4626         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4627         return a_arr;
4628 }
4629 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4630         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4631         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4632         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4633         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4634         for (size_t b = 0; b < b_var.datalen; b++) {
4635                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4636                 b_arr_ptr[b] = b_conv_27_ref;
4637         }
4638         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4639         return b_arr;
4640 }
4641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4642         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4643         ret->datalen = (*env)->GetArrayLength(env, elems);
4644         if (ret->datalen == 0) {
4645                 ret->data = NULL;
4646         } else {
4647                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4648                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4649                 for (size_t i = 0; i < ret->datalen; i++) {
4650                         int64_t arr_elem = java_elems[i];
4651                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4652                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4653                         ret->data[i] = arr_elem_conv;
4654                 }
4655                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4656         }
4657         return (uint64_t)ret;
4658 }
4659 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4660         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 };
4661         for (size_t i = 0; i < ret.datalen; i++) {
4662                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4663         }
4664         return ret;
4665 }
4666 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4667 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4668 static jclass LDKEvent_PaymentReceived_class = NULL;
4669 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4670 static jclass LDKEvent_PaymentSent_class = NULL;
4671 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4672 static jclass LDKEvent_PaymentFailed_class = NULL;
4673 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4674 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4675 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4676 static jclass LDKEvent_SpendableOutputs_class = NULL;
4677 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4679         LDKEvent_FundingGenerationReady_class =
4680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4681         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4682         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4683         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4684         LDKEvent_PaymentReceived_class =
4685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4686         CHECK(LDKEvent_PaymentReceived_class != NULL);
4687         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4688         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4689         LDKEvent_PaymentSent_class =
4690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4691         CHECK(LDKEvent_PaymentSent_class != NULL);
4692         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4693         CHECK(LDKEvent_PaymentSent_meth != NULL);
4694         LDKEvent_PaymentFailed_class =
4695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4696         CHECK(LDKEvent_PaymentFailed_class != NULL);
4697         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4698         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4699         LDKEvent_PendingHTLCsForwardable_class =
4700                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4701         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4702         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4703         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4704         LDKEvent_SpendableOutputs_class =
4705                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4706         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4707         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4708         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4709 }
4710 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4711         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4712         switch(obj->tag) {
4713                 case LDKEvent_FundingGenerationReady: {
4714                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4715                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4716                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4717                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4718                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4719                         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);
4720                 }
4721                 case LDKEvent_PaymentReceived: {
4722                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4723                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4724                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4725                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4726                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4727                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4728                         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);
4729                 }
4730                 case LDKEvent_PaymentSent: {
4731                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4732                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4733                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4734                 }
4735                 case LDKEvent_PaymentFailed: {
4736                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4737                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4738                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4739                 }
4740                 case LDKEvent_PendingHTLCsForwardable: {
4741                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4742                 }
4743                 case LDKEvent_SpendableOutputs: {
4744                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4745                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4746                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4747                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4748                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4749                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4750                         }
4751                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4752                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4753                 }
4754                 default: abort();
4755         }
4756 }
4757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4758         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4759         ret->datalen = (*env)->GetArrayLength(env, elems);
4760         if (ret->datalen == 0) {
4761                 ret->data = NULL;
4762         } else {
4763                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4764                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4765                 for (size_t i = 0; i < ret->datalen; i++) {
4766                         int64_t arr_elem = java_elems[i];
4767                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4768                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4769                         ret->data[i] = arr_elem_conv;
4770                 }
4771                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4772         }
4773         return (uint64_t)ret;
4774 }
4775 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4776         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4777         for (size_t i = 0; i < ret.datalen; i++) {
4778                 ret.data[i] = Event_clone(&orig->data[i]);
4779         }
4780         return ret;
4781 }
4782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4783         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4784         ret->a = a;
4785         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4786         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4787         ret->b = b_conv;
4788         return (uint64_t)ret;
4789 }
4790 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4791         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4792         return tuple->a;
4793 }
4794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4795         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4796         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4797         return (uint64_t)b_ref;
4798 }
4799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4800         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4801         ret->datalen = (*env)->GetArrayLength(env, elems);
4802         if (ret->datalen == 0) {
4803                 ret->data = NULL;
4804         } else {
4805                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4806                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4807                 for (size_t i = 0; i < ret->datalen; i++) {
4808                         int64_t arr_elem = java_elems[i];
4809                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4810                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4811                         ret->data[i] = arr_elem_conv;
4812                 }
4813                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4814         }
4815         return (uint64_t)ret;
4816 }
4817 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4818         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4819         for (size_t i = 0; i < ret.datalen; i++) {
4820                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4821         }
4822         return ret;
4823 }
4824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4825         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4826         LDKThirtyTwoBytes a_ref;
4827         CHECK((*env)->GetArrayLength(env, a) == 32);
4828         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4829         ret->a = a_ref;
4830         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4831         b_constr.datalen = (*env)->GetArrayLength(env, b);
4832         if (b_constr.datalen > 0)
4833                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4834         else
4835                 b_constr.data = NULL;
4836         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4837         for (size_t a = 0; a < b_constr.datalen; a++) {
4838                 int64_t b_conv_26 = b_vals[a];
4839                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4840                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4841                 b_constr.data[a] = b_conv_26_conv;
4842         }
4843         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4844         ret->b = b_constr;
4845         return (uint64_t)ret;
4846 }
4847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4848         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4849         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4850         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4851         return a_arr;
4852 }
4853 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4854         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4855         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4856         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4857         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4858         for (size_t a = 0; a < b_var.datalen; a++) {
4859                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4860                 b_arr_ptr[a] = b_conv_26_ref;
4861         }
4862         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4863         return b_arr;
4864 }
4865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4866         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4867         ret->datalen = (*env)->GetArrayLength(env, elems);
4868         if (ret->datalen == 0) {
4869                 ret->data = NULL;
4870         } else {
4871                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4872                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4873                 for (size_t i = 0; i < ret->datalen; i++) {
4874                         int64_t arr_elem = java_elems[i];
4875                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4876                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4877                         ret->data[i] = arr_elem_conv;
4878                 }
4879                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4880         }
4881         return (uint64_t)ret;
4882 }
4883 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4884         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 };
4885         for (size_t i = 0; i < ret.datalen; i++) {
4886                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4887         }
4888         return ret;
4889 }
4890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4891         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4892 }
4893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4894         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4895         CHECK(val->result_ok);
4896         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4897         return res_ref;
4898 }
4899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4900         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4901         CHECK(!val->result_ok);
4902         LDKDecodeError err_var = (*val->contents.err);
4903         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4904         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4905         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4906         return err_ref;
4907 }
4908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4909         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4910 }
4911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4912         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4913         CHECK(val->result_ok);
4914         return *val->contents.result;
4915 }
4916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4917         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4918         CHECK(!val->result_ok);
4919         LDKLightningError err_var = (*val->contents.err);
4920         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4921         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4922         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4923         return err_ref;
4924 }
4925 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) {
4926         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4927         LDKChannelAnnouncement a_conv;
4928         a_conv.inner = (void*)(a & (~1));
4929         a_conv.is_owned = (a & 1) || (a == 0);
4930         a_conv = ChannelAnnouncement_clone(&a_conv);
4931         ret->a = a_conv;
4932         LDKChannelUpdate b_conv;
4933         b_conv.inner = (void*)(b & (~1));
4934         b_conv.is_owned = (b & 1) || (b == 0);
4935         b_conv = ChannelUpdate_clone(&b_conv);
4936         ret->b = b_conv;
4937         LDKChannelUpdate c_conv;
4938         c_conv.inner = (void*)(c & (~1));
4939         c_conv.is_owned = (c & 1) || (c == 0);
4940         c_conv = ChannelUpdate_clone(&c_conv);
4941         ret->c = c_conv;
4942         return (uint64_t)ret;
4943 }
4944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4945         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4946         LDKChannelAnnouncement a_var = tuple->a;
4947         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4948         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4949         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4950         return a_ref;
4951 }
4952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4953         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4954         LDKChannelUpdate b_var = tuple->b;
4955         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4956         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4957         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4958         return b_ref;
4959 }
4960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4961         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4962         LDKChannelUpdate c_var = tuple->c;
4963         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4964         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4965         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4966         return c_ref;
4967 }
4968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4969         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4970         ret->datalen = (*env)->GetArrayLength(env, elems);
4971         if (ret->datalen == 0) {
4972                 ret->data = NULL;
4973         } else {
4974                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4975                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4976                 for (size_t i = 0; i < ret->datalen; i++) {
4977                         int64_t arr_elem = java_elems[i];
4978                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4979                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4980                         ret->data[i] = arr_elem_conv;
4981                 }
4982                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4983         }
4984         return (uint64_t)ret;
4985 }
4986 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4987         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4988         for (size_t i = 0; i < ret.datalen; i++) {
4989                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4990         }
4991         return ret;
4992 }
4993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4994         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4995         ret->datalen = (*env)->GetArrayLength(env, elems);
4996         if (ret->datalen == 0) {
4997                 ret->data = NULL;
4998         } else {
4999                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5000                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5001                 for (size_t i = 0; i < ret->datalen; i++) {
5002                         int64_t arr_elem = java_elems[i];
5003                         LDKNodeAnnouncement arr_elem_conv;
5004                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5005                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5006                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5007                         ret->data[i] = arr_elem_conv;
5008                 }
5009                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5010         }
5011         return (uint64_t)ret;
5012 }
5013 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5014         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5015         for (size_t i = 0; i < ret.datalen; i++) {
5016                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5017         }
5018         return ret;
5019 }
5020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5021         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5022 }
5023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5024         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5025         CHECK(val->result_ok);
5026         return *val->contents.result;
5027 }
5028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5029         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5030         CHECK(!val->result_ok);
5031         LDKLightningError err_var = (*val->contents.err);
5032         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5033         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5034         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5035         return err_ref;
5036 }
5037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5038         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5039 }
5040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5041         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5042         CHECK(val->result_ok);
5043         LDKCVec_u8Z res_var = (*val->contents.result);
5044         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5045         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5046         return res_arr;
5047 }
5048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5049         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5050         CHECK(!val->result_ok);
5051         LDKPeerHandleError err_var = (*val->contents.err);
5052         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5053         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5054         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5055         return err_ref;
5056 }
5057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5058         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5059 }
5060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5061         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5062         CHECK(val->result_ok);
5063         return *val->contents.result;
5064 }
5065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5066         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5067         CHECK(!val->result_ok);
5068         LDKPeerHandleError err_var = (*val->contents.err);
5069         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5070         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5071         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5072         return err_ref;
5073 }
5074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5075         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5076 }
5077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5078         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5079         CHECK(val->result_ok);
5080         return *val->contents.result;
5081 }
5082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5083         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5084         CHECK(!val->result_ok);
5085         LDKPeerHandleError err_var = (*val->contents.err);
5086         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5087         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5088         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5089         return err_ref;
5090 }
5091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5092         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5093 }
5094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5095         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5096         CHECK(val->result_ok);
5097         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5098         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5099         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5100         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5101         return res_ref;
5102 }
5103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5104         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5105         CHECK(!val->result_ok);
5106         LDKDecodeError err_var = (*val->contents.err);
5107         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5108         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5109         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5110         return err_ref;
5111 }
5112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5113         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5114 }
5115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5116         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5117         CHECK(val->result_ok);
5118         LDKChannelInfo res_var = (*val->contents.result);
5119         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5120         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5121         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5122         return res_ref;
5123 }
5124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5125         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5126         CHECK(!val->result_ok);
5127         LDKDecodeError err_var = (*val->contents.err);
5128         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5129         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5130         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5131         return err_ref;
5132 }
5133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5134         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5135 }
5136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5137         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5138         CHECK(val->result_ok);
5139         LDKRoutingFees res_var = (*val->contents.result);
5140         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5141         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5142         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5143         return res_ref;
5144 }
5145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5146         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5147         CHECK(!val->result_ok);
5148         LDKDecodeError err_var = (*val->contents.err);
5149         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5150         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5151         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5152         return err_ref;
5153 }
5154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5155         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5156 }
5157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5158         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5159         CHECK(val->result_ok);
5160         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5161         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5162         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5163         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5164         return res_ref;
5165 }
5166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5167         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5168         CHECK(!val->result_ok);
5169         LDKDecodeError err_var = (*val->contents.err);
5170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5172         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5173         return err_ref;
5174 }
5175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5176         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5177         ret->datalen = (*env)->GetArrayLength(env, elems);
5178         if (ret->datalen == 0) {
5179                 ret->data = NULL;
5180         } else {
5181                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5182                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5183                 for (size_t i = 0; i < ret->datalen; i++) {
5184                         ret->data[i] = java_elems[i];
5185                 }
5186                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5187         }
5188         return (uint64_t)ret;
5189 }
5190 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5191         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5192         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5193         return ret;
5194 }
5195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5196         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5197 }
5198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5199         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5200         CHECK(val->result_ok);
5201         LDKNodeInfo res_var = (*val->contents.result);
5202         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5203         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5204         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5205         return res_ref;
5206 }
5207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5208         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5209         CHECK(!val->result_ok);
5210         LDKDecodeError err_var = (*val->contents.err);
5211         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5212         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5213         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5214         return err_ref;
5215 }
5216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5217         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5218 }
5219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5220         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5221         CHECK(val->result_ok);
5222         LDKNetworkGraph res_var = (*val->contents.result);
5223         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5224         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5225         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5226         return res_ref;
5227 }
5228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5229         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5230         CHECK(!val->result_ok);
5231         LDKDecodeError err_var = (*val->contents.err);
5232         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5233         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5234         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5235         return err_ref;
5236 }
5237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5238         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5239 }
5240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5241         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5242         CHECK(val->result_ok);
5243         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5244         return res_ref;
5245 }
5246 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5247         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5248         CHECK(!val->result_ok);
5249         return *val->contents.err;
5250 }
5251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5252         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5253 }
5254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5255         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5256         CHECK(val->result_ok);
5257         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5258         *res_conv = (*val->contents.result);
5259         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5260         return (uint64_t)res_conv;
5261 }
5262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5263         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5264         CHECK(!val->result_ok);
5265         LDKDecodeError err_var = (*val->contents.err);
5266         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5267         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5268         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5269         return err_ref;
5270 }
5271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5272         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5273 }
5274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5275         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5276         CHECK(val->result_ok);
5277         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5278         return res_ref;
5279 }
5280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5281         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5282         CHECK(!val->result_ok);
5283         LDKDecodeError err_var = (*val->contents.err);
5284         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5287         return err_ref;
5288 }
5289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5290         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5291         ret->datalen = (*env)->GetArrayLength(env, elems);
5292         if (ret->datalen == 0) {
5293                 ret->data = NULL;
5294         } else {
5295                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5296                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5297                 for (size_t i = 0; i < ret->datalen; i++) {
5298                         int64_t arr_elem = java_elems[i];
5299                         LDKUpdateAddHTLC arr_elem_conv;
5300                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5301                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5302                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5303                         ret->data[i] = arr_elem_conv;
5304                 }
5305                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5306         }
5307         return (uint64_t)ret;
5308 }
5309 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5310         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5311         for (size_t i = 0; i < ret.datalen; i++) {
5312                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5313         }
5314         return ret;
5315 }
5316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5317         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5318         ret->datalen = (*env)->GetArrayLength(env, elems);
5319         if (ret->datalen == 0) {
5320                 ret->data = NULL;
5321         } else {
5322                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5323                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5324                 for (size_t i = 0; i < ret->datalen; i++) {
5325                         int64_t arr_elem = java_elems[i];
5326                         LDKUpdateFulfillHTLC arr_elem_conv;
5327                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5328                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5329                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5330                         ret->data[i] = arr_elem_conv;
5331                 }
5332                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5333         }
5334         return (uint64_t)ret;
5335 }
5336 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5337         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5338         for (size_t i = 0; i < ret.datalen; i++) {
5339                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5340         }
5341         return ret;
5342 }
5343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5344         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5345         ret->datalen = (*env)->GetArrayLength(env, elems);
5346         if (ret->datalen == 0) {
5347                 ret->data = NULL;
5348         } else {
5349                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5350                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5351                 for (size_t i = 0; i < ret->datalen; i++) {
5352                         int64_t arr_elem = java_elems[i];
5353                         LDKUpdateFailHTLC arr_elem_conv;
5354                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5355                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5356                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5357                         ret->data[i] = arr_elem_conv;
5358                 }
5359                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5360         }
5361         return (uint64_t)ret;
5362 }
5363 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5364         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5365         for (size_t i = 0; i < ret.datalen; i++) {
5366                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5367         }
5368         return ret;
5369 }
5370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5371         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5372         ret->datalen = (*env)->GetArrayLength(env, elems);
5373         if (ret->datalen == 0) {
5374                 ret->data = NULL;
5375         } else {
5376                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5377                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5378                 for (size_t i = 0; i < ret->datalen; i++) {
5379                         int64_t arr_elem = java_elems[i];
5380                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5381                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5382                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5383                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5384                         ret->data[i] = arr_elem_conv;
5385                 }
5386                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5387         }
5388         return (uint64_t)ret;
5389 }
5390 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5391         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5392         for (size_t i = 0; i < ret.datalen; i++) {
5393                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5394         }
5395         return ret;
5396 }
5397 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5398         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5399 }
5400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5401         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5402         CHECK(val->result_ok);
5403         LDKAcceptChannel res_var = (*val->contents.result);
5404         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5405         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5406         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5407         return res_ref;
5408 }
5409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5410         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5411         CHECK(!val->result_ok);
5412         LDKDecodeError err_var = (*val->contents.err);
5413         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5414         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5415         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5416         return err_ref;
5417 }
5418 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5419         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5420 }
5421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5422         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5423         CHECK(val->result_ok);
5424         LDKAnnouncementSignatures res_var = (*val->contents.result);
5425         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5426         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5427         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5428         return res_ref;
5429 }
5430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5431         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5432         CHECK(!val->result_ok);
5433         LDKDecodeError err_var = (*val->contents.err);
5434         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5435         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5436         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5437         return err_ref;
5438 }
5439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5440         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5441 }
5442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5443         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5444         CHECK(val->result_ok);
5445         LDKChannelReestablish res_var = (*val->contents.result);
5446         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5447         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5448         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5449         return res_ref;
5450 }
5451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5452         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5453         CHECK(!val->result_ok);
5454         LDKDecodeError err_var = (*val->contents.err);
5455         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5456         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5457         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5458         return err_ref;
5459 }
5460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5461         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5462 }
5463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5464         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5465         CHECK(val->result_ok);
5466         LDKClosingSigned res_var = (*val->contents.result);
5467         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5468         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5469         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5470         return res_ref;
5471 }
5472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5473         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5474         CHECK(!val->result_ok);
5475         LDKDecodeError err_var = (*val->contents.err);
5476         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5477         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5478         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5479         return err_ref;
5480 }
5481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5482         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5483 }
5484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5485         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5486         CHECK(val->result_ok);
5487         LDKCommitmentSigned res_var = (*val->contents.result);
5488         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5489         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5490         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5491         return res_ref;
5492 }
5493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5494         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5495         CHECK(!val->result_ok);
5496         LDKDecodeError err_var = (*val->contents.err);
5497         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5498         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5499         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5500         return err_ref;
5501 }
5502 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5503         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5504 }
5505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5506         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5507         CHECK(val->result_ok);
5508         LDKFundingCreated res_var = (*val->contents.result);
5509         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5510         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5511         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5512         return res_ref;
5513 }
5514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5515         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5516         CHECK(!val->result_ok);
5517         LDKDecodeError err_var = (*val->contents.err);
5518         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5519         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5520         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5521         return err_ref;
5522 }
5523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5524         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5525 }
5526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5527         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5528         CHECK(val->result_ok);
5529         LDKFundingSigned res_var = (*val->contents.result);
5530         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5531         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5532         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5533         return res_ref;
5534 }
5535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5536         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5537         CHECK(!val->result_ok);
5538         LDKDecodeError err_var = (*val->contents.err);
5539         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5540         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5541         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5542         return err_ref;
5543 }
5544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5545         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5546 }
5547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5548         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5549         CHECK(val->result_ok);
5550         LDKFundingLocked res_var = (*val->contents.result);
5551         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5552         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5553         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5554         return res_ref;
5555 }
5556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5557         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5558         CHECK(!val->result_ok);
5559         LDKDecodeError err_var = (*val->contents.err);
5560         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5561         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5562         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5563         return err_ref;
5564 }
5565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5566         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5567 }
5568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5569         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5570         CHECK(val->result_ok);
5571         LDKInit res_var = (*val->contents.result);
5572         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5573         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5574         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5575         return res_ref;
5576 }
5577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5578         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5579         CHECK(!val->result_ok);
5580         LDKDecodeError err_var = (*val->contents.err);
5581         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5582         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5583         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5584         return err_ref;
5585 }
5586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5587         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5588 }
5589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5590         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5591         CHECK(val->result_ok);
5592         LDKOpenChannel res_var = (*val->contents.result);
5593         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5594         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5595         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5596         return res_ref;
5597 }
5598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5599         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5600         CHECK(!val->result_ok);
5601         LDKDecodeError err_var = (*val->contents.err);
5602         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5603         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5604         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5605         return err_ref;
5606 }
5607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5608         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5609 }
5610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5611         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5612         CHECK(val->result_ok);
5613         LDKRevokeAndACK res_var = (*val->contents.result);
5614         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5615         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5616         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5617         return res_ref;
5618 }
5619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5620         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5621         CHECK(!val->result_ok);
5622         LDKDecodeError err_var = (*val->contents.err);
5623         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5624         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5625         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5626         return err_ref;
5627 }
5628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5629         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5630 }
5631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5632         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5633         CHECK(val->result_ok);
5634         LDKShutdown res_var = (*val->contents.result);
5635         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5636         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5637         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5638         return res_ref;
5639 }
5640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5641         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5642         CHECK(!val->result_ok);
5643         LDKDecodeError err_var = (*val->contents.err);
5644         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5647         return err_ref;
5648 }
5649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5650         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5651 }
5652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5653         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5654         CHECK(val->result_ok);
5655         LDKUpdateFailHTLC res_var = (*val->contents.result);
5656         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5657         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5658         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5659         return res_ref;
5660 }
5661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5662         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5663         CHECK(!val->result_ok);
5664         LDKDecodeError err_var = (*val->contents.err);
5665         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5666         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5667         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5668         return err_ref;
5669 }
5670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5671         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5672 }
5673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5674         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5675         CHECK(val->result_ok);
5676         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5677         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5678         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5679         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5680         return res_ref;
5681 }
5682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5683         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5684         CHECK(!val->result_ok);
5685         LDKDecodeError err_var = (*val->contents.err);
5686         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5687         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5688         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5689         return err_ref;
5690 }
5691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5692         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5693 }
5694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5695         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5696         CHECK(val->result_ok);
5697         LDKUpdateFee res_var = (*val->contents.result);
5698         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5699         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5700         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5701         return res_ref;
5702 }
5703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5704         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5705         CHECK(!val->result_ok);
5706         LDKDecodeError err_var = (*val->contents.err);
5707         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5708         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5709         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5710         return err_ref;
5711 }
5712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5713         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5714 }
5715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5716         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5717         CHECK(val->result_ok);
5718         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5719         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5720         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5721         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5722         return res_ref;
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5725         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5726         CHECK(!val->result_ok);
5727         LDKDecodeError err_var = (*val->contents.err);
5728         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5729         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5730         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5731         return err_ref;
5732 }
5733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5734         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5735 }
5736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5737         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5738         CHECK(val->result_ok);
5739         LDKUpdateAddHTLC res_var = (*val->contents.result);
5740         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5741         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5742         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5743         return res_ref;
5744 }
5745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5746         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5747         CHECK(!val->result_ok);
5748         LDKDecodeError err_var = (*val->contents.err);
5749         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5750         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5751         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5752         return err_ref;
5753 }
5754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5755         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5756 }
5757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5758         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5759         CHECK(val->result_ok);
5760         LDKPing res_var = (*val->contents.result);
5761         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5762         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5763         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5764         return res_ref;
5765 }
5766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5767         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5768         CHECK(!val->result_ok);
5769         LDKDecodeError err_var = (*val->contents.err);
5770         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5771         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5772         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5773         return err_ref;
5774 }
5775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5776         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5777 }
5778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5779         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5780         CHECK(val->result_ok);
5781         LDKPong res_var = (*val->contents.result);
5782         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5783         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5784         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5785         return res_ref;
5786 }
5787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5788         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5789         CHECK(!val->result_ok);
5790         LDKDecodeError err_var = (*val->contents.err);
5791         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5792         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5793         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5794         return err_ref;
5795 }
5796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5797         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5798 }
5799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5800         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5801         CHECK(val->result_ok);
5802         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5803         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5804         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5805         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5806         return res_ref;
5807 }
5808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5809         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5810         CHECK(!val->result_ok);
5811         LDKDecodeError err_var = (*val->contents.err);
5812         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5813         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5814         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5815         return err_ref;
5816 }
5817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5818         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5819 }
5820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5821         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5822         CHECK(val->result_ok);
5823         LDKChannelAnnouncement res_var = (*val->contents.result);
5824         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5825         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5826         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5827         return res_ref;
5828 }
5829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5830         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5831         CHECK(!val->result_ok);
5832         LDKDecodeError err_var = (*val->contents.err);
5833         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5834         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5835         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5836         return err_ref;
5837 }
5838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5839         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5840 }
5841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5842         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5843         CHECK(val->result_ok);
5844         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5845         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5846         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5847         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5848         return res_ref;
5849 }
5850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5851         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5852         CHECK(!val->result_ok);
5853         LDKDecodeError err_var = (*val->contents.err);
5854         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5855         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5856         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5857         return err_ref;
5858 }
5859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5860         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5861 }
5862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5863         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5864         CHECK(val->result_ok);
5865         LDKChannelUpdate res_var = (*val->contents.result);
5866         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5867         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5868         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5869         return res_ref;
5870 }
5871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5872         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5873         CHECK(!val->result_ok);
5874         LDKDecodeError err_var = (*val->contents.err);
5875         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5876         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5877         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5878         return err_ref;
5879 }
5880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5881         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5882 }
5883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5884         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5885         CHECK(val->result_ok);
5886         LDKErrorMessage res_var = (*val->contents.result);
5887         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5888         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5889         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5890         return res_ref;
5891 }
5892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5893         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5894         CHECK(!val->result_ok);
5895         LDKDecodeError err_var = (*val->contents.err);
5896         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5897         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5898         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5899         return err_ref;
5900 }
5901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5902         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5903 }
5904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5905         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5906         CHECK(val->result_ok);
5907         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5908         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5909         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5910         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5911         return res_ref;
5912 }
5913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5914         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5915         CHECK(!val->result_ok);
5916         LDKDecodeError err_var = (*val->contents.err);
5917         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5918         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5919         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5920         return err_ref;
5921 }
5922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5923         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5924 }
5925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5926         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5927         CHECK(val->result_ok);
5928         LDKNodeAnnouncement res_var = (*val->contents.result);
5929         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5930         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5931         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5932         return res_ref;
5933 }
5934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5935         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5936         CHECK(!val->result_ok);
5937         LDKDecodeError err_var = (*val->contents.err);
5938         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5939         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5940         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5941         return err_ref;
5942 }
5943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5944         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5945 }
5946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5947         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5948         CHECK(val->result_ok);
5949         LDKQueryShortChannelIds res_var = (*val->contents.result);
5950         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5951         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5952         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5953         return res_ref;
5954 }
5955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5956         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5957         CHECK(!val->result_ok);
5958         LDKDecodeError err_var = (*val->contents.err);
5959         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5960         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5961         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5962         return err_ref;
5963 }
5964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5965         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5966 }
5967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5968         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5969         CHECK(val->result_ok);
5970         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5971         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5972         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5973         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5974         return res_ref;
5975 }
5976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5977         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5978         CHECK(!val->result_ok);
5979         LDKDecodeError err_var = (*val->contents.err);
5980         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5981         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5982         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5983         return err_ref;
5984 }
5985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5986         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5987 }
5988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5989         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5990         CHECK(val->result_ok);
5991         LDKQueryChannelRange res_var = (*val->contents.result);
5992         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5993         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5994         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5995         return res_ref;
5996 }
5997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5998         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5999         CHECK(!val->result_ok);
6000         LDKDecodeError err_var = (*val->contents.err);
6001         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6004         return err_ref;
6005 }
6006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6007         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
6008 }
6009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6010         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6011         CHECK(val->result_ok);
6012         LDKReplyChannelRange res_var = (*val->contents.result);
6013         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6014         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6015         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6016         return res_ref;
6017 }
6018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6019         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6020         CHECK(!val->result_ok);
6021         LDKDecodeError err_var = (*val->contents.err);
6022         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6023         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6024         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6025         return err_ref;
6026 }
6027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6028         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6029 }
6030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6031         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6032         CHECK(val->result_ok);
6033         LDKGossipTimestampFilter res_var = (*val->contents.result);
6034         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6035         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6036         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6037         return res_ref;
6038 }
6039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6040         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6041         CHECK(!val->result_ok);
6042         LDKDecodeError err_var = (*val->contents.err);
6043         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6044         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6045         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6046         return err_ref;
6047 }
6048 static jclass LDKSignOrCreationError_SignError_class = NULL;
6049 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6050 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6051 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6053         LDKSignOrCreationError_SignError_class =
6054                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6055         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6056         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6057         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6058         LDKSignOrCreationError_CreationError_class =
6059                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6060         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6061         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6062         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6063 }
6064 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6065         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6066         switch(obj->tag) {
6067                 case LDKSignOrCreationError_SignError: {
6068                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6069                 }
6070                 case LDKSignOrCreationError_CreationError: {
6071                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6072                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6073                 }
6074                 default: abort();
6075         }
6076 }
6077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6078         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6079 }
6080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6081         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6082         CHECK(val->result_ok);
6083         LDKInvoice res_var = (*val->contents.result);
6084         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6085         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6086         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6087         return res_ref;
6088 }
6089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6090         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6091         CHECK(!val->result_ok);
6092         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6093         return err_ref;
6094 }
6095 typedef struct LDKMessageSendEventsProvider_JCalls {
6096         atomic_size_t refcnt;
6097         JavaVM *vm;
6098         jweak o;
6099         jmethodID get_and_clear_pending_msg_events_meth;
6100 } LDKMessageSendEventsProvider_JCalls;
6101 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6102         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6103         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6104                 JNIEnv *env;
6105                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6106                 if (get_jenv_res == JNI_EDETACHED) {
6107                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6108                 } else {
6109                         DO_ASSERT(get_jenv_res == JNI_OK);
6110                 }
6111                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6112                 if (get_jenv_res == JNI_EDETACHED) {
6113                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6114                 }
6115                 FREE(j_calls);
6116         }
6117 }
6118 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6119         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6120         JNIEnv *env;
6121         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6122         if (get_jenv_res == JNI_EDETACHED) {
6123                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6124         } else {
6125                 DO_ASSERT(get_jenv_res == JNI_OK);
6126         }
6127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6128         CHECK(obj != NULL);
6129         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6130         if ((*env)->ExceptionCheck(env)) {
6131                 (*env)->ExceptionDescribe(env);
6132                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6133         }
6134         LDKCVec_MessageSendEventZ ret_constr;
6135         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6136         if (ret_constr.datalen > 0)
6137                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6138         else
6139                 ret_constr.data = NULL;
6140         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6141         for (size_t s = 0; s < ret_constr.datalen; s++) {
6142                 int64_t ret_conv_18 = ret_vals[s];
6143                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6144                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6145                 ret_constr.data[s] = ret_conv_18_conv;
6146         }
6147         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6148         if (get_jenv_res == JNI_EDETACHED) {
6149                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6150         }
6151         return ret_constr;
6152 }
6153 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6154         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6155         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6156 }
6157 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6158         jclass c = (*env)->GetObjectClass(env, o);
6159         CHECK(c != NULL);
6160         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6161         atomic_init(&calls->refcnt, 1);
6162         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6163         calls->o = (*env)->NewWeakGlobalRef(env, o);
6164         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6165         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6166
6167         LDKMessageSendEventsProvider ret = {
6168                 .this_arg = (void*) calls,
6169                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6170                 .free = LDKMessageSendEventsProvider_JCalls_free,
6171         };
6172         return ret;
6173 }
6174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6175         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6176         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6177         return (uint64_t)res_ptr;
6178 }
6179 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6180         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6181         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6182         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6183         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6184         for (size_t s = 0; s < ret_var.datalen; s++) {
6185                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6186                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6187                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6188                 ret_arr_ptr[s] = ret_conv_18_ref;
6189         }
6190         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6191         FREE(ret_var.data);
6192         return ret_arr;
6193 }
6194
6195 typedef struct LDKEventHandler_JCalls {
6196         atomic_size_t refcnt;
6197         JavaVM *vm;
6198         jweak o;
6199         jmethodID handle_event_meth;
6200 } LDKEventHandler_JCalls;
6201 static void LDKEventHandler_JCalls_free(void* this_arg) {
6202         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6203         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6204                 JNIEnv *env;
6205                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6206                 if (get_jenv_res == JNI_EDETACHED) {
6207                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6208                 } else {
6209                         DO_ASSERT(get_jenv_res == JNI_OK);
6210                 }
6211                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6212                 if (get_jenv_res == JNI_EDETACHED) {
6213                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6214                 }
6215                 FREE(j_calls);
6216         }
6217 }
6218 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6219         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6220         JNIEnv *env;
6221         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6222         if (get_jenv_res == JNI_EDETACHED) {
6223                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6224         } else {
6225                 DO_ASSERT(get_jenv_res == JNI_OK);
6226         }
6227         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6228         *event_copy = event;
6229         uint64_t event_ref = (uint64_t)event_copy;
6230         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6231         CHECK(obj != NULL);
6232         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6233         if ((*env)->ExceptionCheck(env)) {
6234                 (*env)->ExceptionDescribe(env);
6235                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6236         }
6237         if (get_jenv_res == JNI_EDETACHED) {
6238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6239         }
6240 }
6241 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6242         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6243         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6244 }
6245 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6246         jclass c = (*env)->GetObjectClass(env, o);
6247         CHECK(c != NULL);
6248         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6249         atomic_init(&calls->refcnt, 1);
6250         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6251         calls->o = (*env)->NewWeakGlobalRef(env, o);
6252         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6253         CHECK(calls->handle_event_meth != NULL);
6254
6255         LDKEventHandler ret = {
6256                 .this_arg = (void*) calls,
6257                 .handle_event = handle_event_LDKEventHandler_jcall,
6258                 .free = LDKEventHandler_JCalls_free,
6259         };
6260         return ret;
6261 }
6262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6263         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6264         *res_ptr = LDKEventHandler_init(env, clz, o);
6265         return (uint64_t)res_ptr;
6266 }
6267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6268         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6269         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6270         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6271 }
6272
6273 typedef struct LDKEventsProvider_JCalls {
6274         atomic_size_t refcnt;
6275         JavaVM *vm;
6276         jweak o;
6277         jmethodID process_pending_events_meth;
6278 } LDKEventsProvider_JCalls;
6279 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6280         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6281         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6282                 JNIEnv *env;
6283                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6284                 if (get_jenv_res == JNI_EDETACHED) {
6285                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6286                 } else {
6287                         DO_ASSERT(get_jenv_res == JNI_OK);
6288                 }
6289                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6290                 if (get_jenv_res == JNI_EDETACHED) {
6291                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6292                 }
6293                 FREE(j_calls);
6294         }
6295 }
6296 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6297         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6298         JNIEnv *env;
6299         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6300         if (get_jenv_res == JNI_EDETACHED) {
6301                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6302         } else {
6303                 DO_ASSERT(get_jenv_res == JNI_OK);
6304         }
6305         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6306         *ret = handler;
6307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6308         CHECK(obj != NULL);
6309         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6310         if ((*env)->ExceptionCheck(env)) {
6311                 (*env)->ExceptionDescribe(env);
6312                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6313         }
6314         if (get_jenv_res == JNI_EDETACHED) {
6315                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6316         }
6317 }
6318 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6319         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6320         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6321 }
6322 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6323         jclass c = (*env)->GetObjectClass(env, o);
6324         CHECK(c != NULL);
6325         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6326         atomic_init(&calls->refcnt, 1);
6327         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6328         calls->o = (*env)->NewWeakGlobalRef(env, o);
6329         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6330         CHECK(calls->process_pending_events_meth != NULL);
6331
6332         LDKEventsProvider ret = {
6333                 .this_arg = (void*) calls,
6334                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6335                 .free = LDKEventsProvider_JCalls_free,
6336         };
6337         return ret;
6338 }
6339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6340         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6341         *res_ptr = LDKEventsProvider_init(env, clz, o);
6342         return (uint64_t)res_ptr;
6343 }
6344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6345         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6346         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6347         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6348                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6349                 LDKEventHandler_JCalls_cloned(&handler_conv);
6350         }
6351         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6352 }
6353
6354 typedef struct LDKAccess_JCalls {
6355         atomic_size_t refcnt;
6356         JavaVM *vm;
6357         jweak o;
6358         jmethodID get_utxo_meth;
6359 } LDKAccess_JCalls;
6360 static void LDKAccess_JCalls_free(void* this_arg) {
6361         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6362         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6363                 JNIEnv *env;
6364                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6365                 if (get_jenv_res == JNI_EDETACHED) {
6366                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6367                 } else {
6368                         DO_ASSERT(get_jenv_res == JNI_OK);
6369                 }
6370                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6371                 if (get_jenv_res == JNI_EDETACHED) {
6372                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6373                 }
6374                 FREE(j_calls);
6375         }
6376 }
6377 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6378         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6379         JNIEnv *env;
6380         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6381         if (get_jenv_res == JNI_EDETACHED) {
6382                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6383         } else {
6384                 DO_ASSERT(get_jenv_res == JNI_OK);
6385         }
6386         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6387         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6389         CHECK(obj != NULL);
6390         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6391         if ((*env)->ExceptionCheck(env)) {
6392                 (*env)->ExceptionDescribe(env);
6393                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6394         }
6395         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6396         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6397         if (get_jenv_res == JNI_EDETACHED) {
6398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6399         }
6400         return ret_conv;
6401 }
6402 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6403         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6404         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6405 }
6406 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6407         jclass c = (*env)->GetObjectClass(env, o);
6408         CHECK(c != NULL);
6409         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6410         atomic_init(&calls->refcnt, 1);
6411         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6412         calls->o = (*env)->NewWeakGlobalRef(env, o);
6413         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6414         CHECK(calls->get_utxo_meth != NULL);
6415
6416         LDKAccess ret = {
6417                 .this_arg = (void*) calls,
6418                 .get_utxo = get_utxo_LDKAccess_jcall,
6419                 .free = LDKAccess_JCalls_free,
6420         };
6421         return ret;
6422 }
6423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6424         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6425         *res_ptr = LDKAccess_init(env, clz, o);
6426         return (uint64_t)res_ptr;
6427 }
6428 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) {
6429         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6430         unsigned char genesis_hash_arr[32];
6431         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6432         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6433         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6434         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6435         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6436         return (uint64_t)ret_conv;
6437 }
6438
6439 typedef struct LDKListen_JCalls {
6440         atomic_size_t refcnt;
6441         JavaVM *vm;
6442         jweak o;
6443         jmethodID block_connected_meth;
6444         jmethodID block_disconnected_meth;
6445 } LDKListen_JCalls;
6446 static void LDKListen_JCalls_free(void* this_arg) {
6447         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6448         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6449                 JNIEnv *env;
6450                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6451                 if (get_jenv_res == JNI_EDETACHED) {
6452                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6453                 } else {
6454                         DO_ASSERT(get_jenv_res == JNI_OK);
6455                 }
6456                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6457                 if (get_jenv_res == JNI_EDETACHED) {
6458                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6459                 }
6460                 FREE(j_calls);
6461         }
6462 }
6463 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6464         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6465         JNIEnv *env;
6466         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6467         if (get_jenv_res == JNI_EDETACHED) {
6468                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6469         } else {
6470                 DO_ASSERT(get_jenv_res == JNI_OK);
6471         }
6472         LDKu8slice block_var = block;
6473         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6474         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6475         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6476         CHECK(obj != NULL);
6477         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6478         if ((*env)->ExceptionCheck(env)) {
6479                 (*env)->ExceptionDescribe(env);
6480                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6481         }
6482         if (get_jenv_res == JNI_EDETACHED) {
6483                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6484         }
6485 }
6486 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6487         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6488         JNIEnv *env;
6489         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6490         if (get_jenv_res == JNI_EDETACHED) {
6491                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6492         } else {
6493                 DO_ASSERT(get_jenv_res == JNI_OK);
6494         }
6495         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6496         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6497         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6498         CHECK(obj != NULL);
6499         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6500         if ((*env)->ExceptionCheck(env)) {
6501                 (*env)->ExceptionDescribe(env);
6502                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6503         }
6504         if (get_jenv_res == JNI_EDETACHED) {
6505                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6506         }
6507 }
6508 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6509         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6510         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6511 }
6512 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6513         jclass c = (*env)->GetObjectClass(env, o);
6514         CHECK(c != NULL);
6515         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6516         atomic_init(&calls->refcnt, 1);
6517         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6518         calls->o = (*env)->NewWeakGlobalRef(env, o);
6519         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6520         CHECK(calls->block_connected_meth != NULL);
6521         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6522         CHECK(calls->block_disconnected_meth != NULL);
6523
6524         LDKListen ret = {
6525                 .this_arg = (void*) calls,
6526                 .block_connected = block_connected_LDKListen_jcall,
6527                 .block_disconnected = block_disconnected_LDKListen_jcall,
6528                 .free = LDKListen_JCalls_free,
6529         };
6530         return ret;
6531 }
6532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6533         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6534         *res_ptr = LDKListen_init(env, clz, o);
6535         return (uint64_t)res_ptr;
6536 }
6537 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) {
6538         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6539         LDKu8slice block_ref;
6540         block_ref.datalen = (*env)->GetArrayLength(env, block);
6541         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6542         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6543         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6544 }
6545
6546 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) {
6547         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6548         unsigned char header_arr[80];
6549         CHECK((*env)->GetArrayLength(env, header) == 80);
6550         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6551         unsigned char (*header_ref)[80] = &header_arr;
6552         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6553 }
6554
6555 typedef struct LDKConfirm_JCalls {
6556         atomic_size_t refcnt;
6557         JavaVM *vm;
6558         jweak o;
6559         jmethodID transactions_confirmed_meth;
6560         jmethodID transaction_unconfirmed_meth;
6561         jmethodID best_block_updated_meth;
6562         jmethodID get_relevant_txids_meth;
6563 } LDKConfirm_JCalls;
6564 static void LDKConfirm_JCalls_free(void* this_arg) {
6565         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6566         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6567                 JNIEnv *env;
6568                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6569                 if (get_jenv_res == JNI_EDETACHED) {
6570                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6571                 } else {
6572                         DO_ASSERT(get_jenv_res == JNI_OK);
6573                 }
6574                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6575                 if (get_jenv_res == JNI_EDETACHED) {
6576                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6577                 }
6578                 FREE(j_calls);
6579         }
6580 }
6581 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6582         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6583         JNIEnv *env;
6584         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6585         if (get_jenv_res == JNI_EDETACHED) {
6586                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6587         } else {
6588                 DO_ASSERT(get_jenv_res == JNI_OK);
6589         }
6590         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6591         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6592         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6593         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6594         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6595         for (size_t y = 0; y < txdata_var.datalen; y++) {
6596                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6597                 *txdata_conv_24_ref = txdata_var.data[y];
6598                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6599         }
6600         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6601         FREE(txdata_var.data);
6602         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6603         CHECK(obj != NULL);
6604         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6605         if ((*env)->ExceptionCheck(env)) {
6606                 (*env)->ExceptionDescribe(env);
6607                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6608         }
6609         if (get_jenv_res == JNI_EDETACHED) {
6610                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6611         }
6612 }
6613 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6614         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6615         JNIEnv *env;
6616         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6617         if (get_jenv_res == JNI_EDETACHED) {
6618                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6619         } else {
6620                 DO_ASSERT(get_jenv_res == JNI_OK);
6621         }
6622         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6623         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6624         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6625         CHECK(obj != NULL);
6626         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6627         if ((*env)->ExceptionCheck(env)) {
6628                 (*env)->ExceptionDescribe(env);
6629                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6630         }
6631         if (get_jenv_res == JNI_EDETACHED) {
6632                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6633         }
6634 }
6635 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6636         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6637         JNIEnv *env;
6638         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6639         if (get_jenv_res == JNI_EDETACHED) {
6640                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6641         } else {
6642                 DO_ASSERT(get_jenv_res == JNI_OK);
6643         }
6644         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6645         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6646         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6647         CHECK(obj != NULL);
6648         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6649         if ((*env)->ExceptionCheck(env)) {
6650                 (*env)->ExceptionDescribe(env);
6651                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6652         }
6653         if (get_jenv_res == JNI_EDETACHED) {
6654                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6655         }
6656 }
6657 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6658         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6659         JNIEnv *env;
6660         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6661         if (get_jenv_res == JNI_EDETACHED) {
6662                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6663         } else {
6664                 DO_ASSERT(get_jenv_res == JNI_OK);
6665         }
6666         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6667         CHECK(obj != NULL);
6668         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6669         if ((*env)->ExceptionCheck(env)) {
6670                 (*env)->ExceptionDescribe(env);
6671                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6672         }
6673         LDKCVec_TxidZ ret_constr;
6674         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6675         if (ret_constr.datalen > 0)
6676                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6677         else
6678                 ret_constr.data = NULL;
6679         for (size_t i = 0; i < ret_constr.datalen; i++) {
6680                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6681                 LDKThirtyTwoBytes ret_conv_8_ref;
6682                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6683                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6684                 ret_constr.data[i] = ret_conv_8_ref;
6685         }
6686         if (get_jenv_res == JNI_EDETACHED) {
6687                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6688         }
6689         return ret_constr;
6690 }
6691 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6692         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6693         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6694 }
6695 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6696         jclass c = (*env)->GetObjectClass(env, o);
6697         CHECK(c != NULL);
6698         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6699         atomic_init(&calls->refcnt, 1);
6700         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6701         calls->o = (*env)->NewWeakGlobalRef(env, o);
6702         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6703         CHECK(calls->transactions_confirmed_meth != NULL);
6704         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6705         CHECK(calls->transaction_unconfirmed_meth != NULL);
6706         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6707         CHECK(calls->best_block_updated_meth != NULL);
6708         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6709         CHECK(calls->get_relevant_txids_meth != NULL);
6710
6711         LDKConfirm ret = {
6712                 .this_arg = (void*) calls,
6713                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6714                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6715                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6716                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6717                 .free = LDKConfirm_JCalls_free,
6718         };
6719         return ret;
6720 }
6721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6722         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6723         *res_ptr = LDKConfirm_init(env, clz, o);
6724         return (uint64_t)res_ptr;
6725 }
6726 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) {
6727         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6728         unsigned char header_arr[80];
6729         CHECK((*env)->GetArrayLength(env, header) == 80);
6730         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6731         unsigned char (*header_ref)[80] = &header_arr;
6732         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6733         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6734         if (txdata_constr.datalen > 0)
6735                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6736         else
6737                 txdata_constr.data = NULL;
6738         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6739         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6740                 int64_t txdata_conv_24 = txdata_vals[y];
6741                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6742                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6743                 txdata_constr.data[y] = txdata_conv_24_conv;
6744         }
6745         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6746         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6747 }
6748
6749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6750         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6751         unsigned char txid_arr[32];
6752         CHECK((*env)->GetArrayLength(env, txid) == 32);
6753         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6754         unsigned char (*txid_ref)[32] = &txid_arr;
6755         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6756 }
6757
6758 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) {
6759         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6760         unsigned char header_arr[80];
6761         CHECK((*env)->GetArrayLength(env, header) == 80);
6762         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6763         unsigned char (*header_ref)[80] = &header_arr;
6764         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6765 }
6766
6767 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6768         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6769         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6770         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6771         ;
6772         for (size_t i = 0; i < ret_var.datalen; i++) {
6773                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6774                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6775                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6776         }
6777         FREE(ret_var.data);
6778         return ret_arr;
6779 }
6780
6781 typedef struct LDKFilter_JCalls {
6782         atomic_size_t refcnt;
6783         JavaVM *vm;
6784         jweak o;
6785         jmethodID register_tx_meth;
6786         jmethodID register_output_meth;
6787 } LDKFilter_JCalls;
6788 static void LDKFilter_JCalls_free(void* this_arg) {
6789         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6790         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6791                 JNIEnv *env;
6792                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6793                 if (get_jenv_res == JNI_EDETACHED) {
6794                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6795                 } else {
6796                         DO_ASSERT(get_jenv_res == JNI_OK);
6797                 }
6798                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6799                 if (get_jenv_res == JNI_EDETACHED) {
6800                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6801                 }
6802                 FREE(j_calls);
6803         }
6804 }
6805 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6806         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6807         JNIEnv *env;
6808         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6809         if (get_jenv_res == JNI_EDETACHED) {
6810                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6811         } else {
6812                 DO_ASSERT(get_jenv_res == JNI_OK);
6813         }
6814         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6815         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6816         LDKu8slice script_pubkey_var = script_pubkey;
6817         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6818         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6819         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6820         CHECK(obj != NULL);
6821         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6822         if ((*env)->ExceptionCheck(env)) {
6823                 (*env)->ExceptionDescribe(env);
6824                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6825         }
6826         if (get_jenv_res == JNI_EDETACHED) {
6827                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6828         }
6829 }
6830 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6831         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6832         JNIEnv *env;
6833         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6834         if (get_jenv_res == JNI_EDETACHED) {
6835                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6836         } else {
6837                 DO_ASSERT(get_jenv_res == JNI_OK);
6838         }
6839         LDKWatchedOutput output_var = output;
6840         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6841         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6842         uint64_t output_ref = (uint64_t)output_var.inner;
6843         if (output_var.is_owned) {
6844                 output_ref |= 1;
6845         }
6846         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6847         CHECK(obj != NULL);
6848         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6849         if ((*env)->ExceptionCheck(env)) {
6850                 (*env)->ExceptionDescribe(env);
6851                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
6852         }
6853         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6854         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6855         if (get_jenv_res == JNI_EDETACHED) {
6856                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6857         }
6858         return ret_conv;
6859 }
6860 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
6861         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
6862         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6863 }
6864 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6865         jclass c = (*env)->GetObjectClass(env, o);
6866         CHECK(c != NULL);
6867         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6868         atomic_init(&calls->refcnt, 1);
6869         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6870         calls->o = (*env)->NewWeakGlobalRef(env, o);
6871         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6872         CHECK(calls->register_tx_meth != NULL);
6873         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6874         CHECK(calls->register_output_meth != NULL);
6875
6876         LDKFilter ret = {
6877                 .this_arg = (void*) calls,
6878                 .register_tx = register_tx_LDKFilter_jcall,
6879                 .register_output = register_output_LDKFilter_jcall,
6880                 .free = LDKFilter_JCalls_free,
6881         };
6882         return ret;
6883 }
6884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6885         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6886         *res_ptr = LDKFilter_init(env, clz, o);
6887         return (uint64_t)res_ptr;
6888 }
6889 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) {
6890         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6891         unsigned char txid_arr[32];
6892         CHECK((*env)->GetArrayLength(env, txid) == 32);
6893         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6894         unsigned char (*txid_ref)[32] = &txid_arr;
6895         LDKu8slice script_pubkey_ref;
6896         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6897         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6898         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6899         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6900 }
6901
6902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6903         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6904         LDKWatchedOutput output_conv;
6905         output_conv.inner = (void*)(output & (~1));
6906         output_conv.is_owned = (output & 1) || (output == 0);
6907         output_conv = WatchedOutput_clone(&output_conv);
6908         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6909         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6910         uint64_t ret_ref = (uint64_t)ret_copy;
6911         return ret_ref;
6912 }
6913
6914 typedef struct LDKPersist_JCalls {
6915         atomic_size_t refcnt;
6916         JavaVM *vm;
6917         jweak o;
6918         jmethodID persist_new_channel_meth;
6919         jmethodID update_persisted_channel_meth;
6920 } LDKPersist_JCalls;
6921 static void LDKPersist_JCalls_free(void* this_arg) {
6922         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6923         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6924                 JNIEnv *env;
6925                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6926                 if (get_jenv_res == JNI_EDETACHED) {
6927                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6928                 } else {
6929                         DO_ASSERT(get_jenv_res == JNI_OK);
6930                 }
6931                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6932                 if (get_jenv_res == JNI_EDETACHED) {
6933                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6934                 }
6935                 FREE(j_calls);
6936         }
6937 }
6938 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6939         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6940         JNIEnv *env;
6941         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6942         if (get_jenv_res == JNI_EDETACHED) {
6943                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6944         } else {
6945                 DO_ASSERT(get_jenv_res == JNI_OK);
6946         }
6947         LDKOutPoint id_var = id;
6948         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6949         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6950         uint64_t id_ref = (uint64_t)id_var.inner;
6951         if (id_var.is_owned) {
6952                 id_ref |= 1;
6953         }
6954         LDKChannelMonitor data_var = *data;
6955         data_var = ChannelMonitor_clone(data);
6956         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6957         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6958         uint64_t data_ref = (uint64_t)data_var.inner;
6959         if (data_var.is_owned) {
6960                 data_ref |= 1;
6961         }
6962         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6963         CHECK(obj != NULL);
6964         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6965         if ((*env)->ExceptionCheck(env)) {
6966                 (*env)->ExceptionDescribe(env);
6967                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
6968         }
6969         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6970         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6971         if (get_jenv_res == JNI_EDETACHED) {
6972                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6973         }
6974         return ret_conv;
6975 }
6976 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6977         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6978         JNIEnv *env;
6979         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6980         if (get_jenv_res == JNI_EDETACHED) {
6981                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6982         } else {
6983                 DO_ASSERT(get_jenv_res == JNI_OK);
6984         }
6985         LDKOutPoint id_var = id;
6986         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6987         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6988         uint64_t id_ref = (uint64_t)id_var.inner;
6989         if (id_var.is_owned) {
6990                 id_ref |= 1;
6991         }
6992         LDKChannelMonitorUpdate update_var = *update;
6993         update_var = ChannelMonitorUpdate_clone(update);
6994         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6995         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6996         uint64_t update_ref = (uint64_t)update_var.inner;
6997         if (update_var.is_owned) {
6998                 update_ref |= 1;
6999         }
7000         LDKChannelMonitor data_var = *data;
7001         data_var = ChannelMonitor_clone(data);
7002         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7003         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7004         uint64_t data_ref = (uint64_t)data_var.inner;
7005         if (data_var.is_owned) {
7006                 data_ref |= 1;
7007         }
7008         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7009         CHECK(obj != NULL);
7010         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7011         if ((*env)->ExceptionCheck(env)) {
7012                 (*env)->ExceptionDescribe(env);
7013                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7014         }
7015         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7016         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7017         if (get_jenv_res == JNI_EDETACHED) {
7018                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7019         }
7020         return ret_conv;
7021 }
7022 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7023         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7024         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7025 }
7026 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7027         jclass c = (*env)->GetObjectClass(env, o);
7028         CHECK(c != NULL);
7029         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7030         atomic_init(&calls->refcnt, 1);
7031         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7032         calls->o = (*env)->NewWeakGlobalRef(env, o);
7033         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7034         CHECK(calls->persist_new_channel_meth != NULL);
7035         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7036         CHECK(calls->update_persisted_channel_meth != NULL);
7037
7038         LDKPersist ret = {
7039                 .this_arg = (void*) calls,
7040                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7041                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7042                 .free = LDKPersist_JCalls_free,
7043         };
7044         return ret;
7045 }
7046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7047         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7048         *res_ptr = LDKPersist_init(env, clz, o);
7049         return (uint64_t)res_ptr;
7050 }
7051 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) {
7052         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7053         LDKOutPoint id_conv;
7054         id_conv.inner = (void*)(id & (~1));
7055         id_conv.is_owned = (id & 1) || (id == 0);
7056         id_conv = OutPoint_clone(&id_conv);
7057         LDKChannelMonitor data_conv;
7058         data_conv.inner = (void*)(data & (~1));
7059         data_conv.is_owned = false;
7060         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7061         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7062         return (uint64_t)ret_conv;
7063 }
7064
7065 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) {
7066         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7067         LDKOutPoint id_conv;
7068         id_conv.inner = (void*)(id & (~1));
7069         id_conv.is_owned = (id & 1) || (id == 0);
7070         id_conv = OutPoint_clone(&id_conv);
7071         LDKChannelMonitorUpdate update_conv;
7072         update_conv.inner = (void*)(update & (~1));
7073         update_conv.is_owned = false;
7074         LDKChannelMonitor data_conv;
7075         data_conv.inner = (void*)(data & (~1));
7076         data_conv.is_owned = false;
7077         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7078         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7079         return (uint64_t)ret_conv;
7080 }
7081
7082 typedef struct LDKChannelMessageHandler_JCalls {
7083         atomic_size_t refcnt;
7084         JavaVM *vm;
7085         jweak o;
7086         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7087         jmethodID handle_open_channel_meth;
7088         jmethodID handle_accept_channel_meth;
7089         jmethodID handle_funding_created_meth;
7090         jmethodID handle_funding_signed_meth;
7091         jmethodID handle_funding_locked_meth;
7092         jmethodID handle_shutdown_meth;
7093         jmethodID handle_closing_signed_meth;
7094         jmethodID handle_update_add_htlc_meth;
7095         jmethodID handle_update_fulfill_htlc_meth;
7096         jmethodID handle_update_fail_htlc_meth;
7097         jmethodID handle_update_fail_malformed_htlc_meth;
7098         jmethodID handle_commitment_signed_meth;
7099         jmethodID handle_revoke_and_ack_meth;
7100         jmethodID handle_update_fee_meth;
7101         jmethodID handle_announcement_signatures_meth;
7102         jmethodID peer_disconnected_meth;
7103         jmethodID peer_connected_meth;
7104         jmethodID handle_channel_reestablish_meth;
7105         jmethodID handle_channel_update_meth;
7106         jmethodID handle_error_meth;
7107 } LDKChannelMessageHandler_JCalls;
7108 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7109         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7110         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7111                 JNIEnv *env;
7112                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7113                 if (get_jenv_res == JNI_EDETACHED) {
7114                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7115                 } else {
7116                         DO_ASSERT(get_jenv_res == JNI_OK);
7117                 }
7118                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7119                 if (get_jenv_res == JNI_EDETACHED) {
7120                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7121                 }
7122                 FREE(j_calls);
7123         }
7124 }
7125 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7126         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7127         JNIEnv *env;
7128         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7129         if (get_jenv_res == JNI_EDETACHED) {
7130                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7131         } else {
7132                 DO_ASSERT(get_jenv_res == JNI_OK);
7133         }
7134         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7135         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7136         LDKInitFeatures their_features_var = their_features;
7137         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7138         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7139         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7140         if (their_features_var.is_owned) {
7141                 their_features_ref |= 1;
7142         }
7143         LDKOpenChannel msg_var = *msg;
7144         msg_var = OpenChannel_clone(msg);
7145         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7146         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7147         uint64_t msg_ref = (uint64_t)msg_var.inner;
7148         if (msg_var.is_owned) {
7149                 msg_ref |= 1;
7150         }
7151         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7152         CHECK(obj != NULL);
7153         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7154         if ((*env)->ExceptionCheck(env)) {
7155                 (*env)->ExceptionDescribe(env);
7156                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7157         }
7158         if (get_jenv_res == JNI_EDETACHED) {
7159                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7160         }
7161 }
7162 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7163         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7164         JNIEnv *env;
7165         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7166         if (get_jenv_res == JNI_EDETACHED) {
7167                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7168         } else {
7169                 DO_ASSERT(get_jenv_res == JNI_OK);
7170         }
7171         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7172         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7173         LDKInitFeatures their_features_var = their_features;
7174         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7175         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7176         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7177         if (their_features_var.is_owned) {
7178                 their_features_ref |= 1;
7179         }
7180         LDKAcceptChannel msg_var = *msg;
7181         msg_var = AcceptChannel_clone(msg);
7182         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7183         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7184         uint64_t msg_ref = (uint64_t)msg_var.inner;
7185         if (msg_var.is_owned) {
7186                 msg_ref |= 1;
7187         }
7188         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7189         CHECK(obj != NULL);
7190         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7191         if ((*env)->ExceptionCheck(env)) {
7192                 (*env)->ExceptionDescribe(env);
7193                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7194         }
7195         if (get_jenv_res == JNI_EDETACHED) {
7196                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7197         }
7198 }
7199 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7200         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7201         JNIEnv *env;
7202         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7203         if (get_jenv_res == JNI_EDETACHED) {
7204                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7205         } else {
7206                 DO_ASSERT(get_jenv_res == JNI_OK);
7207         }
7208         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7209         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7210         LDKFundingCreated msg_var = *msg;
7211         msg_var = FundingCreated_clone(msg);
7212         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7213         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7214         uint64_t msg_ref = (uint64_t)msg_var.inner;
7215         if (msg_var.is_owned) {
7216                 msg_ref |= 1;
7217         }
7218         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7219         CHECK(obj != NULL);
7220         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7221         if ((*env)->ExceptionCheck(env)) {
7222                 (*env)->ExceptionDescribe(env);
7223                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7224         }
7225         if (get_jenv_res == JNI_EDETACHED) {
7226                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7227         }
7228 }
7229 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7230         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7231         JNIEnv *env;
7232         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7233         if (get_jenv_res == JNI_EDETACHED) {
7234                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7235         } else {
7236                 DO_ASSERT(get_jenv_res == JNI_OK);
7237         }
7238         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7239         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7240         LDKFundingSigned msg_var = *msg;
7241         msg_var = FundingSigned_clone(msg);
7242         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7243         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7244         uint64_t msg_ref = (uint64_t)msg_var.inner;
7245         if (msg_var.is_owned) {
7246                 msg_ref |= 1;
7247         }
7248         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7249         CHECK(obj != NULL);
7250         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7251         if ((*env)->ExceptionCheck(env)) {
7252                 (*env)->ExceptionDescribe(env);
7253                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7254         }
7255         if (get_jenv_res == JNI_EDETACHED) {
7256                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7257         }
7258 }
7259 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7260         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7261         JNIEnv *env;
7262         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7263         if (get_jenv_res == JNI_EDETACHED) {
7264                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7265         } else {
7266                 DO_ASSERT(get_jenv_res == JNI_OK);
7267         }
7268         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7269         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7270         LDKFundingLocked msg_var = *msg;
7271         msg_var = FundingLocked_clone(msg);
7272         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7273         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7274         uint64_t msg_ref = (uint64_t)msg_var.inner;
7275         if (msg_var.is_owned) {
7276                 msg_ref |= 1;
7277         }
7278         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7279         CHECK(obj != NULL);
7280         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7281         if ((*env)->ExceptionCheck(env)) {
7282                 (*env)->ExceptionDescribe(env);
7283                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7284         }
7285         if (get_jenv_res == JNI_EDETACHED) {
7286                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7287         }
7288 }
7289 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7290         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7291         JNIEnv *env;
7292         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7293         if (get_jenv_res == JNI_EDETACHED) {
7294                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7295         } else {
7296                 DO_ASSERT(get_jenv_res == JNI_OK);
7297         }
7298         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7299         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7300         LDKInitFeatures their_features_var = *their_features;
7301         their_features_var = InitFeatures_clone(their_features);
7302         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7303         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7304         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7305         if (their_features_var.is_owned) {
7306                 their_features_ref |= 1;
7307         }
7308         LDKShutdown msg_var = *msg;
7309         msg_var = Shutdown_clone(msg);
7310         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7311         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7312         uint64_t msg_ref = (uint64_t)msg_var.inner;
7313         if (msg_var.is_owned) {
7314                 msg_ref |= 1;
7315         }
7316         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7317         CHECK(obj != NULL);
7318         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7319         if ((*env)->ExceptionCheck(env)) {
7320                 (*env)->ExceptionDescribe(env);
7321                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7322         }
7323         if (get_jenv_res == JNI_EDETACHED) {
7324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7325         }
7326 }
7327 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7328         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7329         JNIEnv *env;
7330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7331         if (get_jenv_res == JNI_EDETACHED) {
7332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7333         } else {
7334                 DO_ASSERT(get_jenv_res == JNI_OK);
7335         }
7336         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7337         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7338         LDKClosingSigned msg_var = *msg;
7339         msg_var = ClosingSigned_clone(msg);
7340         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7341         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7342         uint64_t msg_ref = (uint64_t)msg_var.inner;
7343         if (msg_var.is_owned) {
7344                 msg_ref |= 1;
7345         }
7346         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7347         CHECK(obj != NULL);
7348         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7349         if ((*env)->ExceptionCheck(env)) {
7350                 (*env)->ExceptionDescribe(env);
7351                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7352         }
7353         if (get_jenv_res == JNI_EDETACHED) {
7354                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7355         }
7356 }
7357 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7358         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7359         JNIEnv *env;
7360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7361         if (get_jenv_res == JNI_EDETACHED) {
7362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7363         } else {
7364                 DO_ASSERT(get_jenv_res == JNI_OK);
7365         }
7366         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7367         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7368         LDKUpdateAddHTLC msg_var = *msg;
7369         msg_var = UpdateAddHTLC_clone(msg);
7370         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7371         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7372         uint64_t msg_ref = (uint64_t)msg_var.inner;
7373         if (msg_var.is_owned) {
7374                 msg_ref |= 1;
7375         }
7376         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7377         CHECK(obj != NULL);
7378         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7379         if ((*env)->ExceptionCheck(env)) {
7380                 (*env)->ExceptionDescribe(env);
7381                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7382         }
7383         if (get_jenv_res == JNI_EDETACHED) {
7384                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7385         }
7386 }
7387 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7388         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7389         JNIEnv *env;
7390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7391         if (get_jenv_res == JNI_EDETACHED) {
7392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7393         } else {
7394                 DO_ASSERT(get_jenv_res == JNI_OK);
7395         }
7396         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7397         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7398         LDKUpdateFulfillHTLC msg_var = *msg;
7399         msg_var = UpdateFulfillHTLC_clone(msg);
7400         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7401         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7402         uint64_t msg_ref = (uint64_t)msg_var.inner;
7403         if (msg_var.is_owned) {
7404                 msg_ref |= 1;
7405         }
7406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7407         CHECK(obj != NULL);
7408         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7409         if ((*env)->ExceptionCheck(env)) {
7410                 (*env)->ExceptionDescribe(env);
7411                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7412         }
7413         if (get_jenv_res == JNI_EDETACHED) {
7414                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7415         }
7416 }
7417 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7418         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7419         JNIEnv *env;
7420         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7421         if (get_jenv_res == JNI_EDETACHED) {
7422                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7423         } else {
7424                 DO_ASSERT(get_jenv_res == JNI_OK);
7425         }
7426         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7427         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7428         LDKUpdateFailHTLC msg_var = *msg;
7429         msg_var = UpdateFailHTLC_clone(msg);
7430         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7431         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7432         uint64_t msg_ref = (uint64_t)msg_var.inner;
7433         if (msg_var.is_owned) {
7434                 msg_ref |= 1;
7435         }
7436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7437         CHECK(obj != NULL);
7438         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7439         if ((*env)->ExceptionCheck(env)) {
7440                 (*env)->ExceptionDescribe(env);
7441                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7442         }
7443         if (get_jenv_res == JNI_EDETACHED) {
7444                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7445         }
7446 }
7447 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7449         JNIEnv *env;
7450         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7451         if (get_jenv_res == JNI_EDETACHED) {
7452                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7453         } else {
7454                 DO_ASSERT(get_jenv_res == JNI_OK);
7455         }
7456         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7457         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7458         LDKUpdateFailMalformedHTLC msg_var = *msg;
7459         msg_var = UpdateFailMalformedHTLC_clone(msg);
7460         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7461         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7462         uint64_t msg_ref = (uint64_t)msg_var.inner;
7463         if (msg_var.is_owned) {
7464                 msg_ref |= 1;
7465         }
7466         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7467         CHECK(obj != NULL);
7468         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7469         if ((*env)->ExceptionCheck(env)) {
7470                 (*env)->ExceptionDescribe(env);
7471                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7472         }
7473         if (get_jenv_res == JNI_EDETACHED) {
7474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7475         }
7476 }
7477 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7478         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7479         JNIEnv *env;
7480         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7481         if (get_jenv_res == JNI_EDETACHED) {
7482                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7483         } else {
7484                 DO_ASSERT(get_jenv_res == JNI_OK);
7485         }
7486         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7487         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7488         LDKCommitmentSigned msg_var = *msg;
7489         msg_var = CommitmentSigned_clone(msg);
7490         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7491         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7492         uint64_t msg_ref = (uint64_t)msg_var.inner;
7493         if (msg_var.is_owned) {
7494                 msg_ref |= 1;
7495         }
7496         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7497         CHECK(obj != NULL);
7498         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7499         if ((*env)->ExceptionCheck(env)) {
7500                 (*env)->ExceptionDescribe(env);
7501                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7502         }
7503         if (get_jenv_res == JNI_EDETACHED) {
7504                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7505         }
7506 }
7507 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7508         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7509         JNIEnv *env;
7510         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7511         if (get_jenv_res == JNI_EDETACHED) {
7512                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7513         } else {
7514                 DO_ASSERT(get_jenv_res == JNI_OK);
7515         }
7516         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7517         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7518         LDKRevokeAndACK msg_var = *msg;
7519         msg_var = RevokeAndACK_clone(msg);
7520         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7521         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7522         uint64_t msg_ref = (uint64_t)msg_var.inner;
7523         if (msg_var.is_owned) {
7524                 msg_ref |= 1;
7525         }
7526         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7527         CHECK(obj != NULL);
7528         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7529         if ((*env)->ExceptionCheck(env)) {
7530                 (*env)->ExceptionDescribe(env);
7531                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7532         }
7533         if (get_jenv_res == JNI_EDETACHED) {
7534                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7535         }
7536 }
7537 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7538         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7539         JNIEnv *env;
7540         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7541         if (get_jenv_res == JNI_EDETACHED) {
7542                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7543         } else {
7544                 DO_ASSERT(get_jenv_res == JNI_OK);
7545         }
7546         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7547         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7548         LDKUpdateFee msg_var = *msg;
7549         msg_var = UpdateFee_clone(msg);
7550         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7551         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7552         uint64_t msg_ref = (uint64_t)msg_var.inner;
7553         if (msg_var.is_owned) {
7554                 msg_ref |= 1;
7555         }
7556         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7557         CHECK(obj != NULL);
7558         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7559         if ((*env)->ExceptionCheck(env)) {
7560                 (*env)->ExceptionDescribe(env);
7561                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7562         }
7563         if (get_jenv_res == JNI_EDETACHED) {
7564                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7565         }
7566 }
7567 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7568         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7569         JNIEnv *env;
7570         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7571         if (get_jenv_res == JNI_EDETACHED) {
7572                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7573         } else {
7574                 DO_ASSERT(get_jenv_res == JNI_OK);
7575         }
7576         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7577         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7578         LDKAnnouncementSignatures msg_var = *msg;
7579         msg_var = AnnouncementSignatures_clone(msg);
7580         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7581         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7582         uint64_t msg_ref = (uint64_t)msg_var.inner;
7583         if (msg_var.is_owned) {
7584                 msg_ref |= 1;
7585         }
7586         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7587         CHECK(obj != NULL);
7588         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7589         if ((*env)->ExceptionCheck(env)) {
7590                 (*env)->ExceptionDescribe(env);
7591                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7592         }
7593         if (get_jenv_res == JNI_EDETACHED) {
7594                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7595         }
7596 }
7597 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7598         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7599         JNIEnv *env;
7600         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7601         if (get_jenv_res == JNI_EDETACHED) {
7602                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7603         } else {
7604                 DO_ASSERT(get_jenv_res == JNI_OK);
7605         }
7606         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7607         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7608         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7609         CHECK(obj != NULL);
7610         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7611         if ((*env)->ExceptionCheck(env)) {
7612                 (*env)->ExceptionDescribe(env);
7613                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7614         }
7615         if (get_jenv_res == JNI_EDETACHED) {
7616                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7617         }
7618 }
7619 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7621         JNIEnv *env;
7622         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7623         if (get_jenv_res == JNI_EDETACHED) {
7624                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7625         } else {
7626                 DO_ASSERT(get_jenv_res == JNI_OK);
7627         }
7628         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7629         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7630         LDKInit msg_var = *msg;
7631         msg_var = Init_clone(msg);
7632         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7633         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7634         uint64_t msg_ref = (uint64_t)msg_var.inner;
7635         if (msg_var.is_owned) {
7636                 msg_ref |= 1;
7637         }
7638         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7639         CHECK(obj != NULL);
7640         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7641         if ((*env)->ExceptionCheck(env)) {
7642                 (*env)->ExceptionDescribe(env);
7643                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7644         }
7645         if (get_jenv_res == JNI_EDETACHED) {
7646                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7647         }
7648 }
7649 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7650         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7651         JNIEnv *env;
7652         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7653         if (get_jenv_res == JNI_EDETACHED) {
7654                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7655         } else {
7656                 DO_ASSERT(get_jenv_res == JNI_OK);
7657         }
7658         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7659         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7660         LDKChannelReestablish msg_var = *msg;
7661         msg_var = ChannelReestablish_clone(msg);
7662         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7663         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7664         uint64_t msg_ref = (uint64_t)msg_var.inner;
7665         if (msg_var.is_owned) {
7666                 msg_ref |= 1;
7667         }
7668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7669         CHECK(obj != NULL);
7670         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7671         if ((*env)->ExceptionCheck(env)) {
7672                 (*env)->ExceptionDescribe(env);
7673                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7674         }
7675         if (get_jenv_res == JNI_EDETACHED) {
7676                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7677         }
7678 }
7679 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7680         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7681         JNIEnv *env;
7682         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7683         if (get_jenv_res == JNI_EDETACHED) {
7684                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7685         } else {
7686                 DO_ASSERT(get_jenv_res == JNI_OK);
7687         }
7688         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7689         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7690         LDKChannelUpdate msg_var = *msg;
7691         msg_var = ChannelUpdate_clone(msg);
7692         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7693         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7694         uint64_t msg_ref = (uint64_t)msg_var.inner;
7695         if (msg_var.is_owned) {
7696                 msg_ref |= 1;
7697         }
7698         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7699         CHECK(obj != NULL);
7700         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7701         if ((*env)->ExceptionCheck(env)) {
7702                 (*env)->ExceptionDescribe(env);
7703                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7704         }
7705         if (get_jenv_res == JNI_EDETACHED) {
7706                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7707         }
7708 }
7709 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7710         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7711         JNIEnv *env;
7712         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7713         if (get_jenv_res == JNI_EDETACHED) {
7714                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7715         } else {
7716                 DO_ASSERT(get_jenv_res == JNI_OK);
7717         }
7718         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7719         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7720         LDKErrorMessage msg_var = *msg;
7721         msg_var = ErrorMessage_clone(msg);
7722         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7723         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7724         uint64_t msg_ref = (uint64_t)msg_var.inner;
7725         if (msg_var.is_owned) {
7726                 msg_ref |= 1;
7727         }
7728         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7729         CHECK(obj != NULL);
7730         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7731         if ((*env)->ExceptionCheck(env)) {
7732                 (*env)->ExceptionDescribe(env);
7733                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7734         }
7735         if (get_jenv_res == JNI_EDETACHED) {
7736                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7737         }
7738 }
7739 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7740         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7741         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7742         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7743 }
7744 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7745         jclass c = (*env)->GetObjectClass(env, o);
7746         CHECK(c != NULL);
7747         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7748         atomic_init(&calls->refcnt, 1);
7749         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7750         calls->o = (*env)->NewWeakGlobalRef(env, o);
7751         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7752         CHECK(calls->handle_open_channel_meth != NULL);
7753         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7754         CHECK(calls->handle_accept_channel_meth != NULL);
7755         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7756         CHECK(calls->handle_funding_created_meth != NULL);
7757         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7758         CHECK(calls->handle_funding_signed_meth != NULL);
7759         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7760         CHECK(calls->handle_funding_locked_meth != NULL);
7761         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7762         CHECK(calls->handle_shutdown_meth != NULL);
7763         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7764         CHECK(calls->handle_closing_signed_meth != NULL);
7765         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7766         CHECK(calls->handle_update_add_htlc_meth != NULL);
7767         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7768         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7769         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7770         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7771         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7772         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7773         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7774         CHECK(calls->handle_commitment_signed_meth != NULL);
7775         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7776         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7777         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7778         CHECK(calls->handle_update_fee_meth != NULL);
7779         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7780         CHECK(calls->handle_announcement_signatures_meth != NULL);
7781         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7782         CHECK(calls->peer_disconnected_meth != NULL);
7783         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7784         CHECK(calls->peer_connected_meth != NULL);
7785         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7786         CHECK(calls->handle_channel_reestablish_meth != NULL);
7787         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7788         CHECK(calls->handle_channel_update_meth != NULL);
7789         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7790         CHECK(calls->handle_error_meth != NULL);
7791
7792         LDKChannelMessageHandler ret = {
7793                 .this_arg = (void*) calls,
7794                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7795                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7796                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7797                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7798                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7799                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7800                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7801                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7802                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7803                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7804                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7805                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7806                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7807                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7808                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7809                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7810                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7811                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7812                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7813                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7814                 .free = LDKChannelMessageHandler_JCalls_free,
7815                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7816         };
7817         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7818         return ret;
7819 }
7820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7821         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7822         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7823         return (uint64_t)res_ptr;
7824 }
7825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
7826         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
7827         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
7828         DO_ASSERT((res_ptr & 1) == 0);
7829         return (int64_t)(res_ptr | 1);
7830 }
7831 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) {
7832         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7833         LDKPublicKey their_node_id_ref;
7834         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7835         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7836         LDKInitFeatures their_features_conv;
7837         their_features_conv.inner = (void*)(their_features & (~1));
7838         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7839         their_features_conv = InitFeatures_clone(&their_features_conv);
7840         LDKOpenChannel msg_conv;
7841         msg_conv.inner = (void*)(msg & (~1));
7842         msg_conv.is_owned = false;
7843         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7844 }
7845
7846 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) {
7847         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7848         LDKPublicKey their_node_id_ref;
7849         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7850         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7851         LDKInitFeatures their_features_conv;
7852         their_features_conv.inner = (void*)(their_features & (~1));
7853         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7854         their_features_conv = InitFeatures_clone(&their_features_conv);
7855         LDKAcceptChannel msg_conv;
7856         msg_conv.inner = (void*)(msg & (~1));
7857         msg_conv.is_owned = false;
7858         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7859 }
7860
7861 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) {
7862         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7863         LDKPublicKey their_node_id_ref;
7864         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7865         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7866         LDKFundingCreated msg_conv;
7867         msg_conv.inner = (void*)(msg & (~1));
7868         msg_conv.is_owned = false;
7869         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7870 }
7871
7872 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) {
7873         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7874         LDKPublicKey their_node_id_ref;
7875         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7876         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7877         LDKFundingSigned msg_conv;
7878         msg_conv.inner = (void*)(msg & (~1));
7879         msg_conv.is_owned = false;
7880         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7881 }
7882
7883 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) {
7884         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7885         LDKPublicKey their_node_id_ref;
7886         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7887         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7888         LDKFundingLocked msg_conv;
7889         msg_conv.inner = (void*)(msg & (~1));
7890         msg_conv.is_owned = false;
7891         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7892 }
7893
7894 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) {
7895         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7896         LDKPublicKey their_node_id_ref;
7897         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7898         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7899         LDKInitFeatures their_features_conv;
7900         their_features_conv.inner = (void*)(their_features & (~1));
7901         their_features_conv.is_owned = false;
7902         LDKShutdown msg_conv;
7903         msg_conv.inner = (void*)(msg & (~1));
7904         msg_conv.is_owned = false;
7905         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7906 }
7907
7908 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) {
7909         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7910         LDKPublicKey their_node_id_ref;
7911         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7912         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7913         LDKClosingSigned msg_conv;
7914         msg_conv.inner = (void*)(msg & (~1));
7915         msg_conv.is_owned = false;
7916         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7917 }
7918
7919 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) {
7920         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7921         LDKPublicKey their_node_id_ref;
7922         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7923         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7924         LDKUpdateAddHTLC msg_conv;
7925         msg_conv.inner = (void*)(msg & (~1));
7926         msg_conv.is_owned = false;
7927         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7928 }
7929
7930 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) {
7931         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7932         LDKPublicKey their_node_id_ref;
7933         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7934         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7935         LDKUpdateFulfillHTLC msg_conv;
7936         msg_conv.inner = (void*)(msg & (~1));
7937         msg_conv.is_owned = false;
7938         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7939 }
7940
7941 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) {
7942         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7943         LDKPublicKey their_node_id_ref;
7944         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7945         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7946         LDKUpdateFailHTLC msg_conv;
7947         msg_conv.inner = (void*)(msg & (~1));
7948         msg_conv.is_owned = false;
7949         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7950 }
7951
7952 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) {
7953         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7954         LDKPublicKey their_node_id_ref;
7955         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7956         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7957         LDKUpdateFailMalformedHTLC msg_conv;
7958         msg_conv.inner = (void*)(msg & (~1));
7959         msg_conv.is_owned = false;
7960         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7961 }
7962
7963 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) {
7964         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7965         LDKPublicKey their_node_id_ref;
7966         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7967         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7968         LDKCommitmentSigned msg_conv;
7969         msg_conv.inner = (void*)(msg & (~1));
7970         msg_conv.is_owned = false;
7971         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7972 }
7973
7974 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) {
7975         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7976         LDKPublicKey their_node_id_ref;
7977         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7978         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7979         LDKRevokeAndACK msg_conv;
7980         msg_conv.inner = (void*)(msg & (~1));
7981         msg_conv.is_owned = false;
7982         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7983 }
7984
7985 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) {
7986         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7987         LDKPublicKey their_node_id_ref;
7988         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7989         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7990         LDKUpdateFee msg_conv;
7991         msg_conv.inner = (void*)(msg & (~1));
7992         msg_conv.is_owned = false;
7993         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7994 }
7995
7996 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) {
7997         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7998         LDKPublicKey their_node_id_ref;
7999         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8000         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8001         LDKAnnouncementSignatures msg_conv;
8002         msg_conv.inner = (void*)(msg & (~1));
8003         msg_conv.is_owned = false;
8004         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8005 }
8006
8007 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) {
8008         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8009         LDKPublicKey their_node_id_ref;
8010         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8011         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8012         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8013 }
8014
8015 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) {
8016         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8017         LDKPublicKey their_node_id_ref;
8018         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8019         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8020         LDKInit msg_conv;
8021         msg_conv.inner = (void*)(msg & (~1));
8022         msg_conv.is_owned = false;
8023         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8024 }
8025
8026 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) {
8027         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8028         LDKPublicKey their_node_id_ref;
8029         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8030         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8031         LDKChannelReestablish msg_conv;
8032         msg_conv.inner = (void*)(msg & (~1));
8033         msg_conv.is_owned = false;
8034         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8035 }
8036
8037 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) {
8038         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8039         LDKPublicKey their_node_id_ref;
8040         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8041         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8042         LDKChannelUpdate msg_conv;
8043         msg_conv.inner = (void*)(msg & (~1));
8044         msg_conv.is_owned = false;
8045         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8046 }
8047
8048 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) {
8049         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8050         LDKPublicKey their_node_id_ref;
8051         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8052         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8053         LDKErrorMessage msg_conv;
8054         msg_conv.inner = (void*)(msg & (~1));
8055         msg_conv.is_owned = false;
8056         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8057 }
8058
8059 typedef struct LDKRoutingMessageHandler_JCalls {
8060         atomic_size_t refcnt;
8061         JavaVM *vm;
8062         jweak o;
8063         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8064         jmethodID handle_node_announcement_meth;
8065         jmethodID handle_channel_announcement_meth;
8066         jmethodID handle_channel_update_meth;
8067         jmethodID handle_htlc_fail_channel_update_meth;
8068         jmethodID get_next_channel_announcements_meth;
8069         jmethodID get_next_node_announcements_meth;
8070         jmethodID sync_routing_table_meth;
8071         jmethodID handle_reply_channel_range_meth;
8072         jmethodID handle_reply_short_channel_ids_end_meth;
8073         jmethodID handle_query_channel_range_meth;
8074         jmethodID handle_query_short_channel_ids_meth;
8075 } LDKRoutingMessageHandler_JCalls;
8076 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8077         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8078         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8079                 JNIEnv *env;
8080                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8081                 if (get_jenv_res == JNI_EDETACHED) {
8082                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8083                 } else {
8084                         DO_ASSERT(get_jenv_res == JNI_OK);
8085                 }
8086                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8087                 if (get_jenv_res == JNI_EDETACHED) {
8088                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8089                 }
8090                 FREE(j_calls);
8091         }
8092 }
8093 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8094         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8095         JNIEnv *env;
8096         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8097         if (get_jenv_res == JNI_EDETACHED) {
8098                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8099         } else {
8100                 DO_ASSERT(get_jenv_res == JNI_OK);
8101         }
8102         LDKNodeAnnouncement msg_var = *msg;
8103         msg_var = NodeAnnouncement_clone(msg);
8104         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8105         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8106         uint64_t msg_ref = (uint64_t)msg_var.inner;
8107         if (msg_var.is_owned) {
8108                 msg_ref |= 1;
8109         }
8110         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8111         CHECK(obj != NULL);
8112         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8113         if ((*env)->ExceptionCheck(env)) {
8114                 (*env)->ExceptionDescribe(env);
8115                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8116         }
8117         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8118         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8119         if (get_jenv_res == JNI_EDETACHED) {
8120                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8121         }
8122         return ret_conv;
8123 }
8124 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8125         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8126         JNIEnv *env;
8127         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8128         if (get_jenv_res == JNI_EDETACHED) {
8129                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8130         } else {
8131                 DO_ASSERT(get_jenv_res == JNI_OK);
8132         }
8133         LDKChannelAnnouncement msg_var = *msg;
8134         msg_var = ChannelAnnouncement_clone(msg);
8135         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8136         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8137         uint64_t msg_ref = (uint64_t)msg_var.inner;
8138         if (msg_var.is_owned) {
8139                 msg_ref |= 1;
8140         }
8141         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8142         CHECK(obj != NULL);
8143         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8144         if ((*env)->ExceptionCheck(env)) {
8145                 (*env)->ExceptionDescribe(env);
8146                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8147         }
8148         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8149         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8150         if (get_jenv_res == JNI_EDETACHED) {
8151                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8152         }
8153         return ret_conv;
8154 }
8155 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8156         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8157         JNIEnv *env;
8158         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8159         if (get_jenv_res == JNI_EDETACHED) {
8160                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8161         } else {
8162                 DO_ASSERT(get_jenv_res == JNI_OK);
8163         }
8164         LDKChannelUpdate msg_var = *msg;
8165         msg_var = ChannelUpdate_clone(msg);
8166         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8167         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8168         uint64_t msg_ref = (uint64_t)msg_var.inner;
8169         if (msg_var.is_owned) {
8170                 msg_ref |= 1;
8171         }
8172         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8173         CHECK(obj != NULL);
8174         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8175         if ((*env)->ExceptionCheck(env)) {
8176                 (*env)->ExceptionDescribe(env);
8177                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8178         }
8179         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8180         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8181         if (get_jenv_res == JNI_EDETACHED) {
8182                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8183         }
8184         return ret_conv;
8185 }
8186 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8187         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8188         JNIEnv *env;
8189         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8190         if (get_jenv_res == JNI_EDETACHED) {
8191                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8192         } else {
8193                 DO_ASSERT(get_jenv_res == JNI_OK);
8194         }
8195         uint64_t ret_update = (uint64_t)update;
8196         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8197         CHECK(obj != NULL);
8198         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8199         if ((*env)->ExceptionCheck(env)) {
8200                 (*env)->ExceptionDescribe(env);
8201                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8202         }
8203         if (get_jenv_res == JNI_EDETACHED) {
8204                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8205         }
8206 }
8207 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8208         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8209         JNIEnv *env;
8210         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8211         if (get_jenv_res == JNI_EDETACHED) {
8212                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8213         } else {
8214                 DO_ASSERT(get_jenv_res == JNI_OK);
8215         }
8216         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8217         CHECK(obj != NULL);
8218         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8219         if ((*env)->ExceptionCheck(env)) {
8220                 (*env)->ExceptionDescribe(env);
8221                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8222         }
8223         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8224         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8225         if (ret_constr.datalen > 0)
8226                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8227         else
8228                 ret_constr.data = NULL;
8229         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8230         for (size_t l = 0; l < ret_constr.datalen; l++) {
8231                 int64_t ret_conv_63 = ret_vals[l];
8232                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8233                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8234                 ret_constr.data[l] = ret_conv_63_conv;
8235         }
8236         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8237         if (get_jenv_res == JNI_EDETACHED) {
8238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8239         }
8240         return ret_constr;
8241 }
8242 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8243         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8244         JNIEnv *env;
8245         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8246         if (get_jenv_res == JNI_EDETACHED) {
8247                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8248         } else {
8249                 DO_ASSERT(get_jenv_res == JNI_OK);
8250         }
8251         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8252         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8253         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8254         CHECK(obj != NULL);
8255         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8256         if ((*env)->ExceptionCheck(env)) {
8257                 (*env)->ExceptionDescribe(env);
8258                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8259         }
8260         LDKCVec_NodeAnnouncementZ ret_constr;
8261         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8262         if (ret_constr.datalen > 0)
8263                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8264         else
8265                 ret_constr.data = NULL;
8266         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8267         for (size_t s = 0; s < ret_constr.datalen; s++) {
8268                 int64_t ret_conv_18 = ret_vals[s];
8269                 LDKNodeAnnouncement ret_conv_18_conv;
8270                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8271                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8272                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8273                 ret_constr.data[s] = ret_conv_18_conv;
8274         }
8275         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8276         if (get_jenv_res == JNI_EDETACHED) {
8277                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8278         }
8279         return ret_constr;
8280 }
8281 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8282         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8283         JNIEnv *env;
8284         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8285         if (get_jenv_res == JNI_EDETACHED) {
8286                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8287         } else {
8288                 DO_ASSERT(get_jenv_res == JNI_OK);
8289         }
8290         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8291         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8292         LDKInit init_var = *init;
8293         init_var = Init_clone(init);
8294         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8295         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8296         uint64_t init_ref = (uint64_t)init_var.inner;
8297         if (init_var.is_owned) {
8298                 init_ref |= 1;
8299         }
8300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8301         CHECK(obj != NULL);
8302         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8303         if ((*env)->ExceptionCheck(env)) {
8304                 (*env)->ExceptionDescribe(env);
8305                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8306         }
8307         if (get_jenv_res == JNI_EDETACHED) {
8308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8309         }
8310 }
8311 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8312         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8313         JNIEnv *env;
8314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8315         if (get_jenv_res == JNI_EDETACHED) {
8316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8317         } else {
8318                 DO_ASSERT(get_jenv_res == JNI_OK);
8319         }
8320         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8321         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8322         LDKReplyChannelRange msg_var = msg;
8323         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8324         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8325         uint64_t msg_ref = (uint64_t)msg_var.inner;
8326         if (msg_var.is_owned) {
8327                 msg_ref |= 1;
8328         }
8329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8330         CHECK(obj != NULL);
8331         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8332         if ((*env)->ExceptionCheck(env)) {
8333                 (*env)->ExceptionDescribe(env);
8334                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8335         }
8336         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8337         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8338         if (get_jenv_res == JNI_EDETACHED) {
8339                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8340         }
8341         return ret_conv;
8342 }
8343 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8344         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8345         JNIEnv *env;
8346         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8347         if (get_jenv_res == JNI_EDETACHED) {
8348                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8349         } else {
8350                 DO_ASSERT(get_jenv_res == JNI_OK);
8351         }
8352         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8353         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8354         LDKReplyShortChannelIdsEnd msg_var = msg;
8355         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8356         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8357         uint64_t msg_ref = (uint64_t)msg_var.inner;
8358         if (msg_var.is_owned) {
8359                 msg_ref |= 1;
8360         }
8361         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8362         CHECK(obj != NULL);
8363         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8364         if ((*env)->ExceptionCheck(env)) {
8365                 (*env)->ExceptionDescribe(env);
8366                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8367         }
8368         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8369         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8370         if (get_jenv_res == JNI_EDETACHED) {
8371                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8372         }
8373         return ret_conv;
8374 }
8375 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8376         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8377         JNIEnv *env;
8378         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8379         if (get_jenv_res == JNI_EDETACHED) {
8380                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8381         } else {
8382                 DO_ASSERT(get_jenv_res == JNI_OK);
8383         }
8384         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8385         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8386         LDKQueryChannelRange msg_var = msg;
8387         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8388         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8389         uint64_t msg_ref = (uint64_t)msg_var.inner;
8390         if (msg_var.is_owned) {
8391                 msg_ref |= 1;
8392         }
8393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8394         CHECK(obj != NULL);
8395         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8396         if ((*env)->ExceptionCheck(env)) {
8397                 (*env)->ExceptionDescribe(env);
8398                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8399         }
8400         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8401         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8402         if (get_jenv_res == JNI_EDETACHED) {
8403                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8404         }
8405         return ret_conv;
8406 }
8407 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8408         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8409         JNIEnv *env;
8410         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8411         if (get_jenv_res == JNI_EDETACHED) {
8412                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8413         } else {
8414                 DO_ASSERT(get_jenv_res == JNI_OK);
8415         }
8416         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8417         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8418         LDKQueryShortChannelIds msg_var = msg;
8419         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8420         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8421         uint64_t msg_ref = (uint64_t)msg_var.inner;
8422         if (msg_var.is_owned) {
8423                 msg_ref |= 1;
8424         }
8425         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8426         CHECK(obj != NULL);
8427         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8428         if ((*env)->ExceptionCheck(env)) {
8429                 (*env)->ExceptionDescribe(env);
8430                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8431         }
8432         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8433         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8434         if (get_jenv_res == JNI_EDETACHED) {
8435                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8436         }
8437         return ret_conv;
8438 }
8439 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8440         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8441         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8442         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8443 }
8444 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8445         jclass c = (*env)->GetObjectClass(env, o);
8446         CHECK(c != NULL);
8447         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8448         atomic_init(&calls->refcnt, 1);
8449         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8450         calls->o = (*env)->NewWeakGlobalRef(env, o);
8451         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8452         CHECK(calls->handle_node_announcement_meth != NULL);
8453         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8454         CHECK(calls->handle_channel_announcement_meth != NULL);
8455         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8456         CHECK(calls->handle_channel_update_meth != NULL);
8457         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8458         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8459         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8460         CHECK(calls->get_next_channel_announcements_meth != NULL);
8461         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8462         CHECK(calls->get_next_node_announcements_meth != NULL);
8463         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8464         CHECK(calls->sync_routing_table_meth != NULL);
8465         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8466         CHECK(calls->handle_reply_channel_range_meth != NULL);
8467         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8468         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8469         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8470         CHECK(calls->handle_query_channel_range_meth != NULL);
8471         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8472         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8473
8474         LDKRoutingMessageHandler ret = {
8475                 .this_arg = (void*) calls,
8476                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8477                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8478                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8479                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8480                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8481                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8482                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8483                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8484                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8485                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8486                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8487                 .free = LDKRoutingMessageHandler_JCalls_free,
8488                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8489         };
8490         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8491         return ret;
8492 }
8493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8494         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8495         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8496         return (uint64_t)res_ptr;
8497 }
8498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8499         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
8500         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8501         DO_ASSERT((res_ptr & 1) == 0);
8502         return (int64_t)(res_ptr | 1);
8503 }
8504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8505         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8506         LDKNodeAnnouncement msg_conv;
8507         msg_conv.inner = (void*)(msg & (~1));
8508         msg_conv.is_owned = false;
8509         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8510         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8511         return (uint64_t)ret_conv;
8512 }
8513
8514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8515         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8516         LDKChannelAnnouncement msg_conv;
8517         msg_conv.inner = (void*)(msg & (~1));
8518         msg_conv.is_owned = false;
8519         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8520         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8521         return (uint64_t)ret_conv;
8522 }
8523
8524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8525         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8526         LDKChannelUpdate msg_conv;
8527         msg_conv.inner = (void*)(msg & (~1));
8528         msg_conv.is_owned = false;
8529         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8530         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8531         return (uint64_t)ret_conv;
8532 }
8533
8534 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) {
8535         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8536         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8537         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8538 }
8539
8540 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) {
8541         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8542         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8543         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8544         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8545         for (size_t l = 0; l < ret_var.datalen; l++) {
8546                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8547                 *ret_conv_63_ref = ret_var.data[l];
8548                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8549         }
8550         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8551         FREE(ret_var.data);
8552         return ret_arr;
8553 }
8554
8555 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) {
8556         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8557         LDKPublicKey starting_point_ref;
8558         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8559         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8560         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8561         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8562         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8563         for (size_t s = 0; s < ret_var.datalen; s++) {
8564                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8565                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8566                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8567                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8568                 if (ret_conv_18_var.is_owned) {
8569                         ret_conv_18_ref |= 1;
8570                 }
8571                 ret_arr_ptr[s] = ret_conv_18_ref;
8572         }
8573         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8574         FREE(ret_var.data);
8575         return ret_arr;
8576 }
8577
8578 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) {
8579         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8580         LDKPublicKey their_node_id_ref;
8581         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8582         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8583         LDKInit init_conv;
8584         init_conv.inner = (void*)(init & (~1));
8585         init_conv.is_owned = false;
8586         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8587 }
8588
8589 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) {
8590         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8591         LDKPublicKey their_node_id_ref;
8592         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8593         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8594         LDKReplyChannelRange msg_conv;
8595         msg_conv.inner = (void*)(msg & (~1));
8596         msg_conv.is_owned = (msg & 1) || (msg == 0);
8597         msg_conv = ReplyChannelRange_clone(&msg_conv);
8598         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8599         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8600         return (uint64_t)ret_conv;
8601 }
8602
8603 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) {
8604         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8605         LDKPublicKey their_node_id_ref;
8606         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8607         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8608         LDKReplyShortChannelIdsEnd msg_conv;
8609         msg_conv.inner = (void*)(msg & (~1));
8610         msg_conv.is_owned = (msg & 1) || (msg == 0);
8611         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8612         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8613         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8614         return (uint64_t)ret_conv;
8615 }
8616
8617 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) {
8618         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8619         LDKPublicKey their_node_id_ref;
8620         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8621         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8622         LDKQueryChannelRange msg_conv;
8623         msg_conv.inner = (void*)(msg & (~1));
8624         msg_conv.is_owned = (msg & 1) || (msg == 0);
8625         msg_conv = QueryChannelRange_clone(&msg_conv);
8626         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8627         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8628         return (uint64_t)ret_conv;
8629 }
8630
8631 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) {
8632         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8633         LDKPublicKey their_node_id_ref;
8634         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8635         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8636         LDKQueryShortChannelIds msg_conv;
8637         msg_conv.inner = (void*)(msg & (~1));
8638         msg_conv.is_owned = (msg & 1) || (msg == 0);
8639         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8640         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8641         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8642         return (uint64_t)ret_conv;
8643 }
8644
8645 typedef struct LDKSocketDescriptor_JCalls {
8646         atomic_size_t refcnt;
8647         JavaVM *vm;
8648         jweak o;
8649         jmethodID send_data_meth;
8650         jmethodID disconnect_socket_meth;
8651         jmethodID eq_meth;
8652         jmethodID hash_meth;
8653 } LDKSocketDescriptor_JCalls;
8654 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8655         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8656         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8657                 JNIEnv *env;
8658                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8659                 if (get_jenv_res == JNI_EDETACHED) {
8660                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8661                 } else {
8662                         DO_ASSERT(get_jenv_res == JNI_OK);
8663                 }
8664                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8665                 if (get_jenv_res == JNI_EDETACHED) {
8666                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8667                 }
8668                 FREE(j_calls);
8669         }
8670 }
8671 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8672         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8673         JNIEnv *env;
8674         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8675         if (get_jenv_res == JNI_EDETACHED) {
8676                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8677         } else {
8678                 DO_ASSERT(get_jenv_res == JNI_OK);
8679         }
8680         LDKu8slice data_var = data;
8681         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8682         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8683         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8684         CHECK(obj != NULL);
8685         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8686         if ((*env)->ExceptionCheck(env)) {
8687                 (*env)->ExceptionDescribe(env);
8688                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8689         }
8690         if (get_jenv_res == JNI_EDETACHED) {
8691                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8692         }
8693         return ret;
8694 }
8695 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8696         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8697         JNIEnv *env;
8698         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8699         if (get_jenv_res == JNI_EDETACHED) {
8700                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8701         } else {
8702                 DO_ASSERT(get_jenv_res == JNI_OK);
8703         }
8704         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8705         CHECK(obj != NULL);
8706         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8707         if ((*env)->ExceptionCheck(env)) {
8708                 (*env)->ExceptionDescribe(env);
8709                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8710         }
8711         if (get_jenv_res == JNI_EDETACHED) {
8712                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8713         }
8714 }
8715 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8716         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8717         JNIEnv *env;
8718         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8719         if (get_jenv_res == JNI_EDETACHED) {
8720                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8721         } else {
8722                 DO_ASSERT(get_jenv_res == JNI_OK);
8723         }
8724         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8725         *other_arg_clone = SocketDescriptor_clone(other_arg);
8726         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8727         CHECK(obj != NULL);
8728         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8729         if ((*env)->ExceptionCheck(env)) {
8730                 (*env)->ExceptionDescribe(env);
8731                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8732         }
8733         if (get_jenv_res == JNI_EDETACHED) {
8734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8735         }
8736         return ret;
8737 }
8738 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8739         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8740         JNIEnv *env;
8741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8742         if (get_jenv_res == JNI_EDETACHED) {
8743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8744         } else {
8745                 DO_ASSERT(get_jenv_res == JNI_OK);
8746         }
8747         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8748         CHECK(obj != NULL);
8749         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8750         if ((*env)->ExceptionCheck(env)) {
8751                 (*env)->ExceptionDescribe(env);
8752                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8753         }
8754         if (get_jenv_res == JNI_EDETACHED) {
8755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8756         }
8757         return ret;
8758 }
8759 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8760         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8761         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8762 }
8763 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8764         jclass c = (*env)->GetObjectClass(env, o);
8765         CHECK(c != NULL);
8766         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8767         atomic_init(&calls->refcnt, 1);
8768         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8769         calls->o = (*env)->NewWeakGlobalRef(env, o);
8770         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8771         CHECK(calls->send_data_meth != NULL);
8772         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8773         CHECK(calls->disconnect_socket_meth != NULL);
8774         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8775         CHECK(calls->eq_meth != NULL);
8776         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8777         CHECK(calls->hash_meth != NULL);
8778
8779         LDKSocketDescriptor ret = {
8780                 .this_arg = (void*) calls,
8781                 .send_data = send_data_LDKSocketDescriptor_jcall,
8782                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8783                 .eq = eq_LDKSocketDescriptor_jcall,
8784                 .hash = hash_LDKSocketDescriptor_jcall,
8785                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8786                 .free = LDKSocketDescriptor_JCalls_free,
8787         };
8788         return ret;
8789 }
8790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8791         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8792         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8793         return (uint64_t)res_ptr;
8794 }
8795 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) {
8796         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8797         LDKu8slice data_ref;
8798         data_ref.datalen = (*env)->GetArrayLength(env, data);
8799         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8800         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8801         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8802         return ret_val;
8803 }
8804
8805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8806         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8807         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8808 }
8809
8810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8811         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8812         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8813         return ret_val;
8814 }
8815
8816 typedef struct LDKChannelManagerPersister_JCalls {
8817         atomic_size_t refcnt;
8818         JavaVM *vm;
8819         jweak o;
8820         jmethodID persist_manager_meth;
8821 } LDKChannelManagerPersister_JCalls;
8822 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8823         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8824         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8825                 JNIEnv *env;
8826                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8827                 if (get_jenv_res == JNI_EDETACHED) {
8828                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8829                 } else {
8830                         DO_ASSERT(get_jenv_res == JNI_OK);
8831                 }
8832                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8833                 if (get_jenv_res == JNI_EDETACHED) {
8834                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8835                 }
8836                 FREE(j_calls);
8837         }
8838 }
8839 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8840         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8841         JNIEnv *env;
8842         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8843         if (get_jenv_res == JNI_EDETACHED) {
8844                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8845         } else {
8846                 DO_ASSERT(get_jenv_res == JNI_OK);
8847         }
8848         LDKChannelManager channel_manager_var = *channel_manager;
8849         // Warning: we may need a move here but no clone is available for LDKChannelManager
8850         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8851         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8852         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8853         if (channel_manager_var.is_owned) {
8854                 channel_manager_ref |= 1;
8855         }
8856         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8857         CHECK(obj != NULL);
8858         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8859         if ((*env)->ExceptionCheck(env)) {
8860                 (*env)->ExceptionDescribe(env);
8861                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
8862         }
8863         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8864         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8865         if (get_jenv_res == JNI_EDETACHED) {
8866                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8867         }
8868         return ret_conv;
8869 }
8870 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
8871         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
8872         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8873 }
8874 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8875         jclass c = (*env)->GetObjectClass(env, o);
8876         CHECK(c != NULL);
8877         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8878         atomic_init(&calls->refcnt, 1);
8879         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8880         calls->o = (*env)->NewWeakGlobalRef(env, o);
8881         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8882         CHECK(calls->persist_manager_meth != NULL);
8883
8884         LDKChannelManagerPersister ret = {
8885                 .this_arg = (void*) calls,
8886                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8887                 .free = LDKChannelManagerPersister_JCalls_free,
8888         };
8889         return ret;
8890 }
8891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8892         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8893         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8894         return (uint64_t)res_ptr;
8895 }
8896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8897         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8898         LDKChannelManager channel_manager_conv;
8899         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8900         channel_manager_conv.is_owned = false;
8901         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8902         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8903         return (uint64_t)ret_conv;
8904 }
8905
8906 static jclass LDKFallback_SegWitProgram_class = NULL;
8907 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8908 static jclass LDKFallback_PubKeyHash_class = NULL;
8909 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8910 static jclass LDKFallback_ScriptHash_class = NULL;
8911 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8913         LDKFallback_SegWitProgram_class =
8914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8915         CHECK(LDKFallback_SegWitProgram_class != NULL);
8916         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8917         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8918         LDKFallback_PubKeyHash_class =
8919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8920         CHECK(LDKFallback_PubKeyHash_class != NULL);
8921         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8922         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8923         LDKFallback_ScriptHash_class =
8924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8925         CHECK(LDKFallback_ScriptHash_class != NULL);
8926         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8927         CHECK(LDKFallback_ScriptHash_meth != NULL);
8928 }
8929 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8930         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8931         switch(obj->tag) {
8932                 case LDKFallback_SegWitProgram: {
8933                         uint8_t version_val = obj->seg_wit_program.version._0;
8934                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8935                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8936                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8937                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8938                 }
8939                 case LDKFallback_PubKeyHash: {
8940                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8941                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8942                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8943                 }
8944                 case LDKFallback_ScriptHash: {
8945                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8946                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8947                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8948                 }
8949                 default: abort();
8950         }
8951 }
8952 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8953         LDKStr ret_str = _ldk_get_compiled_version();
8954         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8955         Str_free(ret_str);
8956         return ret_conv;
8957 }
8958
8959 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8960         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8961         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8962         Str_free(ret_str);
8963         return ret_conv;
8964 }
8965
8966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8967         LDKTransaction _res_ref;
8968         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8969         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8970         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8971         _res_ref.data_is_owned = true;
8972         Transaction_free(_res_ref);
8973 }
8974
8975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
8976         LDKCVec_u8Z script_pubkey_ref;
8977         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
8978         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8979         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
8980         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8981         *ret_ref = TxOut_new(script_pubkey_ref, value);
8982         return (uint64_t)ret_ref;
8983 }
8984
8985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8986         if ((_res & 1) != 0) return;
8987         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8988         FREE((void*)_res);
8989         TxOut_free(_res_conv);
8990 }
8991
8992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8993         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8994         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8995         *ret_ref = TxOut_clone(orig_conv);
8996         return (uint64_t)ret_ref;
8997 }
8998
8999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
9000         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
9001         Str_free(dummy);
9002 }
9003
9004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9005         LDKSecretKey o_ref;
9006         CHECK((*env)->GetArrayLength(env, o) == 32);
9007         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
9008         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9009         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9010         return (uint64_t)ret_conv;
9011 }
9012
9013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9014         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9015         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9016         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9017         return (uint64_t)ret_conv;
9018 }
9019
9020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9021         if ((_res & 1) != 0) return;
9022         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9023         FREE((void*)_res);
9024         CResult_SecretKeyErrorZ_free(_res_conv);
9025 }
9026
9027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9028         LDKPublicKey o_ref;
9029         CHECK((*env)->GetArrayLength(env, o) == 33);
9030         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9031         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9032         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9033         return (uint64_t)ret_conv;
9034 }
9035
9036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9037         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9038         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9039         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9040         return (uint64_t)ret_conv;
9041 }
9042
9043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9044         if ((_res & 1) != 0) return;
9045         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9046         FREE((void*)_res);
9047         CResult_PublicKeyErrorZ_free(_res_conv);
9048 }
9049
9050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9051         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9052         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9053         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9054         return (uint64_t)ret_conv;
9055 }
9056
9057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9058         LDKTxCreationKeys o_conv;
9059         o_conv.inner = (void*)(o & (~1));
9060         o_conv.is_owned = (o & 1) || (o == 0);
9061         o_conv = TxCreationKeys_clone(&o_conv);
9062         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9063         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9064         return (uint64_t)ret_conv;
9065 }
9066
9067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9068         LDKDecodeError e_conv;
9069         e_conv.inner = (void*)(e & (~1));
9070         e_conv.is_owned = (e & 1) || (e == 0);
9071         e_conv = DecodeError_clone(&e_conv);
9072         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9073         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9074         return (uint64_t)ret_conv;
9075 }
9076
9077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9078         if ((_res & 1) != 0) return;
9079         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9080         FREE((void*)_res);
9081         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9082 }
9083
9084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9085         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9086         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9087         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9088         return (uint64_t)ret_conv;
9089 }
9090
9091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9092         LDKChannelPublicKeys o_conv;
9093         o_conv.inner = (void*)(o & (~1));
9094         o_conv.is_owned = (o & 1) || (o == 0);
9095         o_conv = ChannelPublicKeys_clone(&o_conv);
9096         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9097         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9098         return (uint64_t)ret_conv;
9099 }
9100
9101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9102         LDKDecodeError e_conv;
9103         e_conv.inner = (void*)(e & (~1));
9104         e_conv.is_owned = (e & 1) || (e == 0);
9105         e_conv = DecodeError_clone(&e_conv);
9106         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9107         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9108         return (uint64_t)ret_conv;
9109 }
9110
9111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9112         if ((_res & 1) != 0) return;
9113         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9114         FREE((void*)_res);
9115         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9116 }
9117
9118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9119         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9120         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9121         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9122         return (uint64_t)ret_conv;
9123 }
9124
9125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9126         LDKTxCreationKeys o_conv;
9127         o_conv.inner = (void*)(o & (~1));
9128         o_conv.is_owned = (o & 1) || (o == 0);
9129         o_conv = TxCreationKeys_clone(&o_conv);
9130         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9131         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9132         return (uint64_t)ret_conv;
9133 }
9134
9135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9136         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9137         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9138         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9139         return (uint64_t)ret_conv;
9140 }
9141
9142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9143         if ((_res & 1) != 0) return;
9144         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9145         FREE((void*)_res);
9146         CResult_TxCreationKeysErrorZ_free(_res_conv);
9147 }
9148
9149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9150         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9151         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9152         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9153         return (uint64_t)ret_conv;
9154 }
9155
9156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9157         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9158         *ret_copy = COption_u32Z_some(o);
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_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9164         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9165         *ret_copy = COption_u32Z_none();
9166         uint64_t ret_ref = (uint64_t)ret_copy;
9167         return ret_ref;
9168 }
9169
9170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9171         if ((_res & 1) != 0) return;
9172         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9173         FREE((void*)_res);
9174         COption_u32Z_free(_res_conv);
9175 }
9176
9177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9178         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9179         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9180         *ret_copy = COption_u32Z_clone(orig_conv);
9181         uint64_t ret_ref = (uint64_t)ret_copy;
9182         return ret_ref;
9183 }
9184
9185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9186         LDKHTLCOutputInCommitment o_conv;
9187         o_conv.inner = (void*)(o & (~1));
9188         o_conv.is_owned = (o & 1) || (o == 0);
9189         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9190         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9191         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9192         return (uint64_t)ret_conv;
9193 }
9194
9195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9196         LDKDecodeError e_conv;
9197         e_conv.inner = (void*)(e & (~1));
9198         e_conv.is_owned = (e & 1) || (e == 0);
9199         e_conv = DecodeError_clone(&e_conv);
9200         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9201         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9202         return (uint64_t)ret_conv;
9203 }
9204
9205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9206         if ((_res & 1) != 0) return;
9207         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9208         FREE((void*)_res);
9209         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9210 }
9211
9212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9213         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9214         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9215         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9216         return (uint64_t)ret_conv;
9217 }
9218
9219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9220         LDKCounterpartyChannelTransactionParameters o_conv;
9221         o_conv.inner = (void*)(o & (~1));
9222         o_conv.is_owned = (o & 1) || (o == 0);
9223         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9224         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9225         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9226         return (uint64_t)ret_conv;
9227 }
9228
9229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9230         LDKDecodeError e_conv;
9231         e_conv.inner = (void*)(e & (~1));
9232         e_conv.is_owned = (e & 1) || (e == 0);
9233         e_conv = DecodeError_clone(&e_conv);
9234         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9235         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9236         return (uint64_t)ret_conv;
9237 }
9238
9239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9240         if ((_res & 1) != 0) return;
9241         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9242         FREE((void*)_res);
9243         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9244 }
9245
9246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9247         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9248         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9249         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9250         return (uint64_t)ret_conv;
9251 }
9252
9253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9254         LDKChannelTransactionParameters o_conv;
9255         o_conv.inner = (void*)(o & (~1));
9256         o_conv.is_owned = (o & 1) || (o == 0);
9257         o_conv = ChannelTransactionParameters_clone(&o_conv);
9258         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9259         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9260         return (uint64_t)ret_conv;
9261 }
9262
9263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9264         LDKDecodeError e_conv;
9265         e_conv.inner = (void*)(e & (~1));
9266         e_conv.is_owned = (e & 1) || (e == 0);
9267         e_conv = DecodeError_clone(&e_conv);
9268         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9269         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9270         return (uint64_t)ret_conv;
9271 }
9272
9273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9274         if ((_res & 1) != 0) return;
9275         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9276         FREE((void*)_res);
9277         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9278 }
9279
9280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9281         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9282         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9283         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9284         return (uint64_t)ret_conv;
9285 }
9286
9287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9288         LDKCVec_SignatureZ _res_constr;
9289         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9290         if (_res_constr.datalen > 0)
9291                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9292         else
9293                 _res_constr.data = NULL;
9294         for (size_t i = 0; i < _res_constr.datalen; i++) {
9295                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9296                 LDKSignature _res_conv_8_ref;
9297                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9298                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9299                 _res_constr.data[i] = _res_conv_8_ref;
9300         }
9301         CVec_SignatureZ_free(_res_constr);
9302 }
9303
9304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9305         LDKHolderCommitmentTransaction o_conv;
9306         o_conv.inner = (void*)(o & (~1));
9307         o_conv.is_owned = (o & 1) || (o == 0);
9308         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9309         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9310         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9311         return (uint64_t)ret_conv;
9312 }
9313
9314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9315         LDKDecodeError e_conv;
9316         e_conv.inner = (void*)(e & (~1));
9317         e_conv.is_owned = (e & 1) || (e == 0);
9318         e_conv = DecodeError_clone(&e_conv);
9319         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9320         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9321         return (uint64_t)ret_conv;
9322 }
9323
9324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9325         if ((_res & 1) != 0) return;
9326         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9327         FREE((void*)_res);
9328         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9329 }
9330
9331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9332         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9333         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9334         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9335         return (uint64_t)ret_conv;
9336 }
9337
9338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9339         LDKBuiltCommitmentTransaction o_conv;
9340         o_conv.inner = (void*)(o & (~1));
9341         o_conv.is_owned = (o & 1) || (o == 0);
9342         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9343         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9344         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9345         return (uint64_t)ret_conv;
9346 }
9347
9348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9349         LDKDecodeError e_conv;
9350         e_conv.inner = (void*)(e & (~1));
9351         e_conv.is_owned = (e & 1) || (e == 0);
9352         e_conv = DecodeError_clone(&e_conv);
9353         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9354         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9355         return (uint64_t)ret_conv;
9356 }
9357
9358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9359         if ((_res & 1) != 0) return;
9360         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9361         FREE((void*)_res);
9362         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9363 }
9364
9365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9366         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9367         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9368         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9369         return (uint64_t)ret_conv;
9370 }
9371
9372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9373         LDKCommitmentTransaction o_conv;
9374         o_conv.inner = (void*)(o & (~1));
9375         o_conv.is_owned = (o & 1) || (o == 0);
9376         o_conv = CommitmentTransaction_clone(&o_conv);
9377         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9378         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9379         return (uint64_t)ret_conv;
9380 }
9381
9382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9383         LDKDecodeError e_conv;
9384         e_conv.inner = (void*)(e & (~1));
9385         e_conv.is_owned = (e & 1) || (e == 0);
9386         e_conv = DecodeError_clone(&e_conv);
9387         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9388         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9389         return (uint64_t)ret_conv;
9390 }
9391
9392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9393         if ((_res & 1) != 0) return;
9394         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9395         FREE((void*)_res);
9396         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9397 }
9398
9399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9400         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9401         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9402         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9403         return (uint64_t)ret_conv;
9404 }
9405
9406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9407         LDKTrustedCommitmentTransaction o_conv;
9408         o_conv.inner = (void*)(o & (~1));
9409         o_conv.is_owned = (o & 1) || (o == 0);
9410         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9411         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9412         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9413         return (uint64_t)ret_conv;
9414 }
9415
9416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9417         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9418         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9419         return (uint64_t)ret_conv;
9420 }
9421
9422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9423         if ((_res & 1) != 0) return;
9424         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9425         FREE((void*)_res);
9426         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9427 }
9428
9429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9430         LDKCVec_SignatureZ o_constr;
9431         o_constr.datalen = (*env)->GetArrayLength(env, o);
9432         if (o_constr.datalen > 0)
9433                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9434         else
9435                 o_constr.data = NULL;
9436         for (size_t i = 0; i < o_constr.datalen; i++) {
9437                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9438                 LDKSignature o_conv_8_ref;
9439                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9440                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9441                 o_constr.data[i] = o_conv_8_ref;
9442         }
9443         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9444         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9445         return (uint64_t)ret_conv;
9446 }
9447
9448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9449         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9450         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9451         return (uint64_t)ret_conv;
9452 }
9453
9454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9455         if ((_res & 1) != 0) return;
9456         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9457         FREE((void*)_res);
9458         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9459 }
9460
9461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9462         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9463         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9464         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9465         return (uint64_t)ret_conv;
9466 }
9467
9468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9469         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9470         *ret_conv = CResult_NoneErrorZ_ok();
9471         return (uint64_t)ret_conv;
9472 }
9473
9474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9475         LDKIOError e_conv = LDKIOError_from_java(env, e);
9476         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9477         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9478         return (uint64_t)ret_conv;
9479 }
9480
9481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9482         if ((_res & 1) != 0) return;
9483         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9484         FREE((void*)_res);
9485         CResult_NoneErrorZ_free(_res_conv);
9486 }
9487
9488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9489         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9490         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9491         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9492         return (uint64_t)ret_conv;
9493 }
9494
9495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9496         LDKRouteHop o_conv;
9497         o_conv.inner = (void*)(o & (~1));
9498         o_conv.is_owned = (o & 1) || (o == 0);
9499         o_conv = RouteHop_clone(&o_conv);
9500         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9501         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9502         return (uint64_t)ret_conv;
9503 }
9504
9505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9506         LDKDecodeError e_conv;
9507         e_conv.inner = (void*)(e & (~1));
9508         e_conv.is_owned = (e & 1) || (e == 0);
9509         e_conv = DecodeError_clone(&e_conv);
9510         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9511         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9512         return (uint64_t)ret_conv;
9513 }
9514
9515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9516         if ((_res & 1) != 0) return;
9517         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9518         FREE((void*)_res);
9519         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9520 }
9521
9522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9523         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9524         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9525         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9526         return (uint64_t)ret_conv;
9527 }
9528
9529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9530         LDKCVec_RouteHopZ _res_constr;
9531         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9532         if (_res_constr.datalen > 0)
9533                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9534         else
9535                 _res_constr.data = NULL;
9536         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9537         for (size_t k = 0; k < _res_constr.datalen; k++) {
9538                 int64_t _res_conv_10 = _res_vals[k];
9539                 LDKRouteHop _res_conv_10_conv;
9540                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9541                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9542                 _res_constr.data[k] = _res_conv_10_conv;
9543         }
9544         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9545         CVec_RouteHopZ_free(_res_constr);
9546 }
9547
9548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9549         LDKCVec_CVec_RouteHopZZ _res_constr;
9550         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9551         if (_res_constr.datalen > 0)
9552                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9553         else
9554                 _res_constr.data = NULL;
9555         for (size_t m = 0; m < _res_constr.datalen; m++) {
9556                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9557                 LDKCVec_RouteHopZ _res_conv_12_constr;
9558                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9559                 if (_res_conv_12_constr.datalen > 0)
9560                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9561                 else
9562                         _res_conv_12_constr.data = NULL;
9563                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9564                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9565                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9566                         LDKRouteHop _res_conv_12_conv_10_conv;
9567                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9568                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9569                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9570                 }
9571                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9572                 _res_constr.data[m] = _res_conv_12_constr;
9573         }
9574         CVec_CVec_RouteHopZZ_free(_res_constr);
9575 }
9576
9577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9578         LDKRoute o_conv;
9579         o_conv.inner = (void*)(o & (~1));
9580         o_conv.is_owned = (o & 1) || (o == 0);
9581         o_conv = Route_clone(&o_conv);
9582         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9583         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9584         return (uint64_t)ret_conv;
9585 }
9586
9587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9588         LDKDecodeError e_conv;
9589         e_conv.inner = (void*)(e & (~1));
9590         e_conv.is_owned = (e & 1) || (e == 0);
9591         e_conv = DecodeError_clone(&e_conv);
9592         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9593         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9594         return (uint64_t)ret_conv;
9595 }
9596
9597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9598         if ((_res & 1) != 0) return;
9599         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9600         FREE((void*)_res);
9601         CResult_RouteDecodeErrorZ_free(_res_conv);
9602 }
9603
9604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9605         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9606         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9607         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9608         return (uint64_t)ret_conv;
9609 }
9610
9611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9612         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9613         *ret_copy = COption_u64Z_some(o);
9614         uint64_t ret_ref = (uint64_t)ret_copy;
9615         return ret_ref;
9616 }
9617
9618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9619         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9620         *ret_copy = COption_u64Z_none();
9621         uint64_t ret_ref = (uint64_t)ret_copy;
9622         return ret_ref;
9623 }
9624
9625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9626         if ((_res & 1) != 0) return;
9627         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9628         FREE((void*)_res);
9629         COption_u64Z_free(_res_conv);
9630 }
9631
9632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9633         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9634         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9635         *ret_copy = COption_u64Z_clone(orig_conv);
9636         uint64_t ret_ref = (uint64_t)ret_copy;
9637         return ret_ref;
9638 }
9639
9640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9641         LDKCVec_ChannelDetailsZ _res_constr;
9642         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9643         if (_res_constr.datalen > 0)
9644                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9645         else
9646                 _res_constr.data = NULL;
9647         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9648         for (size_t q = 0; q < _res_constr.datalen; q++) {
9649                 int64_t _res_conv_16 = _res_vals[q];
9650                 LDKChannelDetails _res_conv_16_conv;
9651                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9652                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9653                 _res_constr.data[q] = _res_conv_16_conv;
9654         }
9655         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9656         CVec_ChannelDetailsZ_free(_res_constr);
9657 }
9658
9659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9660         LDKCVec_RouteHintZ _res_constr;
9661         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9662         if (_res_constr.datalen > 0)
9663                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9664         else
9665                 _res_constr.data = NULL;
9666         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9667         for (size_t l = 0; l < _res_constr.datalen; l++) {
9668                 int64_t _res_conv_11 = _res_vals[l];
9669                 LDKRouteHint _res_conv_11_conv;
9670                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9671                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9672                 _res_constr.data[l] = _res_conv_11_conv;
9673         }
9674         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9675         CVec_RouteHintZ_free(_res_constr);
9676 }
9677
9678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9679         LDKRoute o_conv;
9680         o_conv.inner = (void*)(o & (~1));
9681         o_conv.is_owned = (o & 1) || (o == 0);
9682         o_conv = Route_clone(&o_conv);
9683         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9684         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9685         return (uint64_t)ret_conv;
9686 }
9687
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9689         LDKLightningError e_conv;
9690         e_conv.inner = (void*)(e & (~1));
9691         e_conv.is_owned = (e & 1) || (e == 0);
9692         e_conv = LightningError_clone(&e_conv);
9693         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9694         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9695         return (uint64_t)ret_conv;
9696 }
9697
9698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9699         if ((_res & 1) != 0) return;
9700         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9701         FREE((void*)_res);
9702         CResult_RouteLightningErrorZ_free(_res_conv);
9703 }
9704
9705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9706         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9707         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9708         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9709         return (uint64_t)ret_conv;
9710 }
9711
9712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9713         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9714         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9715         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9716         return (uint64_t)ret_conv;
9717 }
9718
9719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9720         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9721         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9722         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9723         return (uint64_t)ret_conv;
9724 }
9725
9726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9727         if ((_res & 1) != 0) return;
9728         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9729         FREE((void*)_res);
9730         CResult_TxOutAccessErrorZ_free(_res_conv);
9731 }
9732
9733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9734         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9735         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9736         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9737         return (uint64_t)ret_conv;
9738 }
9739
9740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9741         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9742         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9743         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9744         return (uint64_t)ret_ref;
9745 }
9746
9747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9748         LDKTransaction b_ref;
9749         b_ref.datalen = (*env)->GetArrayLength(env, b);
9750         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9751         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9752         b_ref.data_is_owned = true;
9753         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9754         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9755         return (uint64_t)ret_ref;
9756 }
9757
9758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9759         if ((_res & 1) != 0) return;
9760         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9761         FREE((void*)_res);
9762         C2Tuple_usizeTransactionZ_free(_res_conv);
9763 }
9764
9765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9766         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9767         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9768         if (_res_constr.datalen > 0)
9769                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9770         else
9771                 _res_constr.data = NULL;
9772         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9773         for (size_t y = 0; y < _res_constr.datalen; y++) {
9774                 int64_t _res_conv_24 = _res_vals[y];
9775                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9776                 FREE((void*)_res_conv_24);
9777                 _res_constr.data[y] = _res_conv_24_conv;
9778         }
9779         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9780         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9781 }
9782
9783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9784         LDKCVec_TxidZ _res_constr;
9785         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9786         if (_res_constr.datalen > 0)
9787                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9788         else
9789                 _res_constr.data = NULL;
9790         for (size_t i = 0; i < _res_constr.datalen; i++) {
9791                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9792                 LDKThirtyTwoBytes _res_conv_8_ref;
9793                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9794                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9795                 _res_constr.data[i] = _res_conv_8_ref;
9796         }
9797         CVec_TxidZ_free(_res_constr);
9798 }
9799
9800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9801         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9802         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9803         return (uint64_t)ret_conv;
9804 }
9805
9806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9807         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9808         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9809         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9810         return (uint64_t)ret_conv;
9811 }
9812
9813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9814         if ((_res & 1) != 0) return;
9815         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9816         FREE((void*)_res);
9817         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9818 }
9819
9820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9821         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9822         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9823         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9824         return (uint64_t)ret_conv;
9825 }
9826
9827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9828         LDKCVec_MonitorEventZ _res_constr;
9829         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9830         if (_res_constr.datalen > 0)
9831                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9832         else
9833                 _res_constr.data = NULL;
9834         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9835         for (size_t o = 0; o < _res_constr.datalen; o++) {
9836                 int64_t _res_conv_14 = _res_vals[o];
9837                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9838                 FREE((void*)_res_conv_14);
9839                 _res_constr.data[o] = _res_conv_14_conv;
9840         }
9841         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9842         CVec_MonitorEventZ_free(_res_constr);
9843 }
9844
9845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9846         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9847         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9848         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9849         uint64_t ret_ref = (uint64_t)ret_copy;
9850         return ret_ref;
9851 }
9852
9853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9854         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9855         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9856         uint64_t ret_ref = (uint64_t)ret_copy;
9857         return ret_ref;
9858 }
9859
9860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9861         if ((_res & 1) != 0) return;
9862         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9863         FREE((void*)_res);
9864         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9865 }
9866
9867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9868         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9869         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9870         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9871         uint64_t ret_ref = (uint64_t)ret_copy;
9872         return ret_ref;
9873 }
9874
9875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9876         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9877         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9878         if (_res_constr.datalen > 0)
9879                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9880         else
9881                 _res_constr.data = NULL;
9882         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9883         for (size_t b = 0; b < _res_constr.datalen; b++) {
9884                 int64_t _res_conv_27 = _res_vals[b];
9885                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9886                 FREE((void*)_res_conv_27);
9887                 _res_constr.data[b] = _res_conv_27_conv;
9888         }
9889         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9890         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9891 }
9892
9893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9894         LDKCVec_MessageSendEventZ _res_constr;
9895         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9896         if (_res_constr.datalen > 0)
9897                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9898         else
9899                 _res_constr.data = NULL;
9900         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9901         for (size_t s = 0; s < _res_constr.datalen; s++) {
9902                 int64_t _res_conv_18 = _res_vals[s];
9903                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9904                 FREE((void*)_res_conv_18);
9905                 _res_constr.data[s] = _res_conv_18_conv;
9906         }
9907         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9908         CVec_MessageSendEventZ_free(_res_constr);
9909 }
9910
9911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9912         LDKInitFeatures o_conv;
9913         o_conv.inner = (void*)(o & (~1));
9914         o_conv.is_owned = (o & 1) || (o == 0);
9915         o_conv = InitFeatures_clone(&o_conv);
9916         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9917         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9918         return (uint64_t)ret_conv;
9919 }
9920
9921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9922         LDKDecodeError e_conv;
9923         e_conv.inner = (void*)(e & (~1));
9924         e_conv.is_owned = (e & 1) || (e == 0);
9925         e_conv = DecodeError_clone(&e_conv);
9926         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9927         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9928         return (uint64_t)ret_conv;
9929 }
9930
9931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9932         if ((_res & 1) != 0) return;
9933         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9934         FREE((void*)_res);
9935         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9936 }
9937
9938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9939         LDKNodeFeatures o_conv;
9940         o_conv.inner = (void*)(o & (~1));
9941         o_conv.is_owned = (o & 1) || (o == 0);
9942         o_conv = NodeFeatures_clone(&o_conv);
9943         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9944         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9945         return (uint64_t)ret_conv;
9946 }
9947
9948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9949         LDKDecodeError e_conv;
9950         e_conv.inner = (void*)(e & (~1));
9951         e_conv.is_owned = (e & 1) || (e == 0);
9952         e_conv = DecodeError_clone(&e_conv);
9953         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9954         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9955         return (uint64_t)ret_conv;
9956 }
9957
9958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9959         if ((_res & 1) != 0) return;
9960         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9961         FREE((void*)_res);
9962         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9963 }
9964
9965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9966         LDKChannelFeatures o_conv;
9967         o_conv.inner = (void*)(o & (~1));
9968         o_conv.is_owned = (o & 1) || (o == 0);
9969         o_conv = ChannelFeatures_clone(&o_conv);
9970         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9971         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9972         return (uint64_t)ret_conv;
9973 }
9974
9975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9976         LDKDecodeError e_conv;
9977         e_conv.inner = (void*)(e & (~1));
9978         e_conv.is_owned = (e & 1) || (e == 0);
9979         e_conv = DecodeError_clone(&e_conv);
9980         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9981         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9982         return (uint64_t)ret_conv;
9983 }
9984
9985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9986         if ((_res & 1) != 0) return;
9987         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9988         FREE((void*)_res);
9989         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9990 }
9991
9992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9993         LDKInvoiceFeatures o_conv;
9994         o_conv.inner = (void*)(o & (~1));
9995         o_conv.is_owned = (o & 1) || (o == 0);
9996         o_conv = InvoiceFeatures_clone(&o_conv);
9997         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9998         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9999         return (uint64_t)ret_conv;
10000 }
10001
10002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10003         LDKDecodeError e_conv;
10004         e_conv.inner = (void*)(e & (~1));
10005         e_conv.is_owned = (e & 1) || (e == 0);
10006         e_conv = DecodeError_clone(&e_conv);
10007         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10008         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10009         return (uint64_t)ret_conv;
10010 }
10011
10012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10013         if ((_res & 1) != 0) return;
10014         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10015         FREE((void*)_res);
10016         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10017 }
10018
10019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10020         LDKDelayedPaymentOutputDescriptor o_conv;
10021         o_conv.inner = (void*)(o & (~1));
10022         o_conv.is_owned = (o & 1) || (o == 0);
10023         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10024         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10025         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10026         return (uint64_t)ret_conv;
10027 }
10028
10029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10030         LDKDecodeError e_conv;
10031         e_conv.inner = (void*)(e & (~1));
10032         e_conv.is_owned = (e & 1) || (e == 0);
10033         e_conv = DecodeError_clone(&e_conv);
10034         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10035         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10036         return (uint64_t)ret_conv;
10037 }
10038
10039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10040         if ((_res & 1) != 0) return;
10041         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10042         FREE((void*)_res);
10043         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10044 }
10045
10046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10047         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10048         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10049         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10050         return (uint64_t)ret_conv;
10051 }
10052
10053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10054         LDKStaticPaymentOutputDescriptor o_conv;
10055         o_conv.inner = (void*)(o & (~1));
10056         o_conv.is_owned = (o & 1) || (o == 0);
10057         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10058         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10059         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10060         return (uint64_t)ret_conv;
10061 }
10062
10063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10064         LDKDecodeError e_conv;
10065         e_conv.inner = (void*)(e & (~1));
10066         e_conv.is_owned = (e & 1) || (e == 0);
10067         e_conv = DecodeError_clone(&e_conv);
10068         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10069         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10070         return (uint64_t)ret_conv;
10071 }
10072
10073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10074         if ((_res & 1) != 0) return;
10075         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10076         FREE((void*)_res);
10077         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10078 }
10079
10080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10081         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10082         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10083         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10084         return (uint64_t)ret_conv;
10085 }
10086
10087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10088         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10089         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10090         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10091         return (uint64_t)ret_conv;
10092 }
10093
10094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10095         LDKDecodeError e_conv;
10096         e_conv.inner = (void*)(e & (~1));
10097         e_conv.is_owned = (e & 1) || (e == 0);
10098         e_conv = DecodeError_clone(&e_conv);
10099         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10100         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10101         return (uint64_t)ret_conv;
10102 }
10103
10104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10105         if ((_res & 1) != 0) return;
10106         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10107         FREE((void*)_res);
10108         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10109 }
10110
10111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10112         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10113         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10114         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10115         return (uint64_t)ret_conv;
10116 }
10117
10118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10119         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10120         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10121         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10122         return (uint64_t)ret_ref;
10123 }
10124
10125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10126         LDKSignature a_ref;
10127         CHECK((*env)->GetArrayLength(env, a) == 64);
10128         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10129         LDKCVec_SignatureZ b_constr;
10130         b_constr.datalen = (*env)->GetArrayLength(env, b);
10131         if (b_constr.datalen > 0)
10132                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10133         else
10134                 b_constr.data = NULL;
10135         for (size_t i = 0; i < b_constr.datalen; i++) {
10136                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10137                 LDKSignature b_conv_8_ref;
10138                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10139                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10140                 b_constr.data[i] = b_conv_8_ref;
10141         }
10142         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10143         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10144         return (uint64_t)ret_ref;
10145 }
10146
10147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10148         if ((_res & 1) != 0) return;
10149         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10150         FREE((void*)_res);
10151         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10152 }
10153
10154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10155         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10156         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10157         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10158         return (uint64_t)ret_conv;
10159 }
10160
10161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10162         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10163         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10164         return (uint64_t)ret_conv;
10165 }
10166
10167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10168         if ((_res & 1) != 0) return;
10169         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10170         FREE((void*)_res);
10171         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10172 }
10173
10174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10175         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10176         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10177         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10178         return (uint64_t)ret_conv;
10179 }
10180
10181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10182         LDKSignature o_ref;
10183         CHECK((*env)->GetArrayLength(env, o) == 64);
10184         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10185         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10186         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10187         return (uint64_t)ret_conv;
10188 }
10189
10190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10191         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10192         *ret_conv = CResult_SignatureNoneZ_err();
10193         return (uint64_t)ret_conv;
10194 }
10195
10196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10197         if ((_res & 1) != 0) return;
10198         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10199         FREE((void*)_res);
10200         CResult_SignatureNoneZ_free(_res_conv);
10201 }
10202
10203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10204         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10205         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10206         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10207         return (uint64_t)ret_conv;
10208 }
10209
10210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10211         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10212         if (o_conv.free == LDKSign_JCalls_free) {
10213                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10214                 LDKSign_JCalls_cloned(&o_conv);
10215         }
10216         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10217         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10218         return (uint64_t)ret_conv;
10219 }
10220
10221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10222         LDKDecodeError e_conv;
10223         e_conv.inner = (void*)(e & (~1));
10224         e_conv.is_owned = (e & 1) || (e == 0);
10225         e_conv = DecodeError_clone(&e_conv);
10226         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10227         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10228         return (uint64_t)ret_conv;
10229 }
10230
10231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10232         if ((_res & 1) != 0) return;
10233         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10234         FREE((void*)_res);
10235         CResult_SignDecodeErrorZ_free(_res_conv);
10236 }
10237
10238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10239         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10240         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10241         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10242         return (uint64_t)ret_conv;
10243 }
10244
10245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10246         LDKCVec_u8Z _res_ref;
10247         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10248         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10249         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10250         CVec_u8Z_free(_res_ref);
10251 }
10252
10253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10254         LDKRecoverableSignature arg_ref;
10255         CHECK((*env)->GetArrayLength(env, arg) == 68);
10256         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10257         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10258         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10259         return (uint64_t)ret_conv;
10260 }
10261
10262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10263         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10264         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10265         return (uint64_t)ret_conv;
10266 }
10267
10268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10269         if ((_res & 1) != 0) return;
10270         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10271         FREE((void*)_res);
10272         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10273 }
10274
10275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10276         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10277         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10278         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10279         return (uint64_t)ret_conv;
10280 }
10281
10282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10283         LDKCVec_CVec_u8ZZ _res_constr;
10284         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10285         if (_res_constr.datalen > 0)
10286                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10287         else
10288                 _res_constr.data = NULL;
10289         for (size_t i = 0; i < _res_constr.datalen; i++) {
10290                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10291                 LDKCVec_u8Z _res_conv_8_ref;
10292                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10293                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10294                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10295                 _res_constr.data[i] = _res_conv_8_ref;
10296         }
10297         CVec_CVec_u8ZZ_free(_res_constr);
10298 }
10299
10300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10301         LDKCVec_CVec_u8ZZ o_constr;
10302         o_constr.datalen = (*env)->GetArrayLength(env, o);
10303         if (o_constr.datalen > 0)
10304                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10305         else
10306                 o_constr.data = NULL;
10307         for (size_t i = 0; i < o_constr.datalen; i++) {
10308                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10309                 LDKCVec_u8Z o_conv_8_ref;
10310                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10311                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10312                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10313                 o_constr.data[i] = o_conv_8_ref;
10314         }
10315         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10316         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10317         return (uint64_t)ret_conv;
10318 }
10319
10320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10321         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10322         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10323         return (uint64_t)ret_conv;
10324 }
10325
10326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10327         if ((_res & 1) != 0) return;
10328         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10329         FREE((void*)_res);
10330         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10331 }
10332
10333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10334         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10335         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10336         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10337         return (uint64_t)ret_conv;
10338 }
10339
10340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10341         LDKInMemorySigner o_conv;
10342         o_conv.inner = (void*)(o & (~1));
10343         o_conv.is_owned = (o & 1) || (o == 0);
10344         o_conv = InMemorySigner_clone(&o_conv);
10345         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10346         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10347         return (uint64_t)ret_conv;
10348 }
10349
10350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10351         LDKDecodeError e_conv;
10352         e_conv.inner = (void*)(e & (~1));
10353         e_conv.is_owned = (e & 1) || (e == 0);
10354         e_conv = DecodeError_clone(&e_conv);
10355         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10356         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10357         return (uint64_t)ret_conv;
10358 }
10359
10360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10361         if ((_res & 1) != 0) return;
10362         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10363         FREE((void*)_res);
10364         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10365 }
10366
10367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10368         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10369         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10370         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10371         return (uint64_t)ret_conv;
10372 }
10373
10374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10375         LDKCVec_TxOutZ _res_constr;
10376         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10377         if (_res_constr.datalen > 0)
10378                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10379         else
10380                 _res_constr.data = NULL;
10381         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10382         for (size_t h = 0; h < _res_constr.datalen; h++) {
10383                 int64_t _res_conv_7 = _res_vals[h];
10384                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10385                 FREE((void*)_res_conv_7);
10386                 _res_constr.data[h] = _res_conv_7_conv;
10387         }
10388         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10389         CVec_TxOutZ_free(_res_constr);
10390 }
10391
10392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10393         LDKTransaction o_ref;
10394         o_ref.datalen = (*env)->GetArrayLength(env, o);
10395         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10396         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10397         o_ref.data_is_owned = true;
10398         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10399         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10400         return (uint64_t)ret_conv;
10401 }
10402
10403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10404         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10405         *ret_conv = CResult_TransactionNoneZ_err();
10406         return (uint64_t)ret_conv;
10407 }
10408
10409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10410         if ((_res & 1) != 0) return;
10411         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10412         FREE((void*)_res);
10413         CResult_TransactionNoneZ_free(_res_conv);
10414 }
10415
10416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10417         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10418         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10419         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10420         return (uint64_t)ret_conv;
10421 }
10422
10423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10424         LDKThirtyTwoBytes a_ref;
10425         CHECK((*env)->GetArrayLength(env, a) == 32);
10426         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10427         LDKChannelMonitor b_conv;
10428         b_conv.inner = (void*)(b & (~1));
10429         b_conv.is_owned = (b & 1) || (b == 0);
10430         b_conv = ChannelMonitor_clone(&b_conv);
10431         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10432         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10433         return (uint64_t)ret_ref;
10434 }
10435
10436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10437         if ((_res & 1) != 0) return;
10438         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10439         FREE((void*)_res);
10440         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10441 }
10442
10443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10444         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10445         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10446         if (_res_constr.datalen > 0)
10447                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10448         else
10449                 _res_constr.data = NULL;
10450         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10451         for (size_t i = 0; i < _res_constr.datalen; i++) {
10452                 int64_t _res_conv_34 = _res_vals[i];
10453                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10454                 FREE((void*)_res_conv_34);
10455                 _res_constr.data[i] = _res_conv_34_conv;
10456         }
10457         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10458         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10459 }
10460
10461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10462         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10463         o_constr.datalen = (*env)->GetArrayLength(env, o);
10464         if (o_constr.datalen > 0)
10465                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10466         else
10467                 o_constr.data = NULL;
10468         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10469         for (size_t i = 0; i < o_constr.datalen; i++) {
10470                 int64_t o_conv_34 = o_vals[i];
10471                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10472                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10473                 o_constr.data[i] = o_conv_34_conv;
10474         }
10475         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10476         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10477         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10478         return (uint64_t)ret_conv;
10479 }
10480
10481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10482         LDKIOError e_conv = LDKIOError_from_java(env, e);
10483         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10484         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10485         return (uint64_t)ret_conv;
10486 }
10487
10488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10489         if ((_res & 1) != 0) return;
10490         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10491         FREE((void*)_res);
10492         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10493 }
10494
10495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10496         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10497         *ret_copy = COption_u16Z_some(o);
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_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10503         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10504         *ret_copy = COption_u16Z_none();
10505         uint64_t ret_ref = (uint64_t)ret_copy;
10506         return ret_ref;
10507 }
10508
10509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10510         if ((_res & 1) != 0) return;
10511         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10512         FREE((void*)_res);
10513         COption_u16Z_free(_res_conv);
10514 }
10515
10516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10517         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10518         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10519         *ret_copy = COption_u16Z_clone(orig_conv);
10520         uint64_t ret_ref = (uint64_t)ret_copy;
10521         return ret_ref;
10522 }
10523
10524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10525         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10526         *ret_conv = CResult_NoneAPIErrorZ_ok();
10527         return (uint64_t)ret_conv;
10528 }
10529
10530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10531         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10532         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10533         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10534         return (uint64_t)ret_conv;
10535 }
10536
10537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10538         if ((_res & 1) != 0) return;
10539         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10540         FREE((void*)_res);
10541         CResult_NoneAPIErrorZ_free(_res_conv);
10542 }
10543
10544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10545         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10546         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10547         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10548         return (uint64_t)ret_conv;
10549 }
10550
10551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10552         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10553         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10554         if (_res_constr.datalen > 0)
10555                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10556         else
10557                 _res_constr.data = NULL;
10558         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10559         for (size_t w = 0; w < _res_constr.datalen; w++) {
10560                 int64_t _res_conv_22 = _res_vals[w];
10561                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10562                 FREE((void*)_res_conv_22);
10563                 _res_constr.data[w] = _res_conv_22_conv;
10564         }
10565         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10566         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10567 }
10568
10569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10570         LDKCVec_APIErrorZ _res_constr;
10571         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10572         if (_res_constr.datalen > 0)
10573                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10574         else
10575                 _res_constr.data = NULL;
10576         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10577         for (size_t k = 0; k < _res_constr.datalen; k++) {
10578                 int64_t _res_conv_10 = _res_vals[k];
10579                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10580                 FREE((void*)_res_conv_10);
10581                 _res_constr.data[k] = _res_conv_10_conv;
10582         }
10583         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10584         CVec_APIErrorZ_free(_res_constr);
10585 }
10586
10587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10588         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10589         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10590         return (uint64_t)ret_conv;
10591 }
10592
10593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10594         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10595         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10596         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10597         return (uint64_t)ret_conv;
10598 }
10599
10600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10601         if ((_res & 1) != 0) return;
10602         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10603         FREE((void*)_res);
10604         CResult_NonePaymentSendFailureZ_free(_res_conv);
10605 }
10606
10607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10608         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10609         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10610         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10611         return (uint64_t)ret_conv;
10612 }
10613
10614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10615         LDKCVec_NetAddressZ _res_constr;
10616         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10617         if (_res_constr.datalen > 0)
10618                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10619         else
10620                 _res_constr.data = NULL;
10621         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10622         for (size_t m = 0; m < _res_constr.datalen; m++) {
10623                 int64_t _res_conv_12 = _res_vals[m];
10624                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10625                 FREE((void*)_res_conv_12);
10626                 _res_constr.data[m] = _res_conv_12_conv;
10627         }
10628         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10629         CVec_NetAddressZ_free(_res_constr);
10630 }
10631
10632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10633         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10634         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10635         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10636         return (uint64_t)ret_ref;
10637 }
10638
10639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10640         LDKThirtyTwoBytes a_ref;
10641         CHECK((*env)->GetArrayLength(env, a) == 32);
10642         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10643         LDKThirtyTwoBytes b_ref;
10644         CHECK((*env)->GetArrayLength(env, b) == 32);
10645         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10646         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10647         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10648         return (uint64_t)ret_ref;
10649 }
10650
10651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10652         if ((_res & 1) != 0) return;
10653         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10654         FREE((void*)_res);
10655         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10656 }
10657
10658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10659         LDKThirtyTwoBytes o_ref;
10660         CHECK((*env)->GetArrayLength(env, o) == 32);
10661         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10662         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10663         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10664         return (uint64_t)ret_conv;
10665 }
10666
10667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10668         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10669         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10670         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10671         return (uint64_t)ret_conv;
10672 }
10673
10674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10675         if ((_res & 1) != 0) return;
10676         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10677         FREE((void*)_res);
10678         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10679 }
10680
10681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10682         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10683         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10684         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10685         return (uint64_t)ret_conv;
10686 }
10687
10688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10689         LDKCVec_ChannelMonitorZ _res_constr;
10690         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10691         if (_res_constr.datalen > 0)
10692                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10693         else
10694                 _res_constr.data = NULL;
10695         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10696         for (size_t q = 0; q < _res_constr.datalen; q++) {
10697                 int64_t _res_conv_16 = _res_vals[q];
10698                 LDKChannelMonitor _res_conv_16_conv;
10699                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10700                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10701                 _res_constr.data[q] = _res_conv_16_conv;
10702         }
10703         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10704         CVec_ChannelMonitorZ_free(_res_constr);
10705 }
10706
10707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10708         LDKThirtyTwoBytes a_ref;
10709         CHECK((*env)->GetArrayLength(env, a) == 32);
10710         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10711         LDKChannelManager b_conv;
10712         b_conv.inner = (void*)(b & (~1));
10713         b_conv.is_owned = (b & 1) || (b == 0);
10714         // Warning: we need a move here but no clone is available for LDKChannelManager
10715         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10716         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10717         return (uint64_t)ret_ref;
10718 }
10719
10720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10721         if ((_res & 1) != 0) return;
10722         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10723         FREE((void*)_res);
10724         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10725 }
10726
10727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10728         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10729         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10730         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10731         return (uint64_t)ret_conv;
10732 }
10733
10734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10735         LDKDecodeError e_conv;
10736         e_conv.inner = (void*)(e & (~1));
10737         e_conv.is_owned = (e & 1) || (e == 0);
10738         e_conv = DecodeError_clone(&e_conv);
10739         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10740         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10741         return (uint64_t)ret_conv;
10742 }
10743
10744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10745         if ((_res & 1) != 0) return;
10746         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10747         FREE((void*)_res);
10748         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10749 }
10750
10751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10752         LDKChannelConfig o_conv;
10753         o_conv.inner = (void*)(o & (~1));
10754         o_conv.is_owned = (o & 1) || (o == 0);
10755         o_conv = ChannelConfig_clone(&o_conv);
10756         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10757         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10758         return (uint64_t)ret_conv;
10759 }
10760
10761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10762         LDKDecodeError e_conv;
10763         e_conv.inner = (void*)(e & (~1));
10764         e_conv.is_owned = (e & 1) || (e == 0);
10765         e_conv = DecodeError_clone(&e_conv);
10766         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10767         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10768         return (uint64_t)ret_conv;
10769 }
10770
10771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10772         if ((_res & 1) != 0) return;
10773         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10774         FREE((void*)_res);
10775         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10776 }
10777
10778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10779         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10780         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10781         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10782         return (uint64_t)ret_conv;
10783 }
10784
10785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10786         LDKOutPoint o_conv;
10787         o_conv.inner = (void*)(o & (~1));
10788         o_conv.is_owned = (o & 1) || (o == 0);
10789         o_conv = OutPoint_clone(&o_conv);
10790         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10791         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10792         return (uint64_t)ret_conv;
10793 }
10794
10795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10796         LDKDecodeError e_conv;
10797         e_conv.inner = (void*)(e & (~1));
10798         e_conv.is_owned = (e & 1) || (e == 0);
10799         e_conv = DecodeError_clone(&e_conv);
10800         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10801         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10802         return (uint64_t)ret_conv;
10803 }
10804
10805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10806         if ((_res & 1) != 0) return;
10807         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10808         FREE((void*)_res);
10809         CResult_OutPointDecodeErrorZ_free(_res_conv);
10810 }
10811
10812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10813         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10814         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10815         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10816         return (uint64_t)ret_conv;
10817 }
10818
10819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10820         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10821         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10822         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10823         return (uint64_t)ret_conv;
10824 }
10825
10826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10827         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10828         *ret_conv = CResult_SiPrefixNoneZ_err();
10829         return (uint64_t)ret_conv;
10830 }
10831
10832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10833         if ((_res & 1) != 0) return;
10834         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10835         FREE((void*)_res);
10836         CResult_SiPrefixNoneZ_free(_res_conv);
10837 }
10838
10839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10840         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10841         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10842         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10843         return (uint64_t)ret_conv;
10844 }
10845
10846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10847         LDKInvoice o_conv;
10848         o_conv.inner = (void*)(o & (~1));
10849         o_conv.is_owned = (o & 1) || (o == 0);
10850         o_conv = Invoice_clone(&o_conv);
10851         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10852         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10853         return (uint64_t)ret_conv;
10854 }
10855
10856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10857         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10858         *ret_conv = CResult_InvoiceNoneZ_err();
10859         return (uint64_t)ret_conv;
10860 }
10861
10862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10863         if ((_res & 1) != 0) return;
10864         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10865         FREE((void*)_res);
10866         CResult_InvoiceNoneZ_free(_res_conv);
10867 }
10868
10869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10870         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10871         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10872         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10873         return (uint64_t)ret_conv;
10874 }
10875
10876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10877         LDKSignedRawInvoice o_conv;
10878         o_conv.inner = (void*)(o & (~1));
10879         o_conv.is_owned = (o & 1) || (o == 0);
10880         o_conv = SignedRawInvoice_clone(&o_conv);
10881         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10882         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10883         return (uint64_t)ret_conv;
10884 }
10885
10886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10887         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10888         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10889         return (uint64_t)ret_conv;
10890 }
10891
10892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10893         if ((_res & 1) != 0) return;
10894         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10895         FREE((void*)_res);
10896         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10897 }
10898
10899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10900         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10901         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10902         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10903         return (uint64_t)ret_conv;
10904 }
10905
10906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10907         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10908         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10909         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10910         return (uint64_t)ret_ref;
10911 }
10912
10913 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) {
10914         LDKRawInvoice a_conv;
10915         a_conv.inner = (void*)(a & (~1));
10916         a_conv.is_owned = (a & 1) || (a == 0);
10917         a_conv = RawInvoice_clone(&a_conv);
10918         LDKThirtyTwoBytes b_ref;
10919         CHECK((*env)->GetArrayLength(env, b) == 32);
10920         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10921         LDKInvoiceSignature c_conv;
10922         c_conv.inner = (void*)(c & (~1));
10923         c_conv.is_owned = (c & 1) || (c == 0);
10924         c_conv = InvoiceSignature_clone(&c_conv);
10925         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10926         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10927         return (uint64_t)ret_ref;
10928 }
10929
10930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10931         if ((_res & 1) != 0) return;
10932         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10933         FREE((void*)_res);
10934         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10935 }
10936
10937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10938         LDKPayeePubKey o_conv;
10939         o_conv.inner = (void*)(o & (~1));
10940         o_conv.is_owned = (o & 1) || (o == 0);
10941         o_conv = PayeePubKey_clone(&o_conv);
10942         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10943         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10944         return (uint64_t)ret_conv;
10945 }
10946
10947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10948         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10949         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10950         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10951         return (uint64_t)ret_conv;
10952 }
10953
10954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10955         if ((_res & 1) != 0) return;
10956         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10957         FREE((void*)_res);
10958         CResult_PayeePubKeyErrorZ_free(_res_conv);
10959 }
10960
10961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10962         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10963         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10964         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10965         return (uint64_t)ret_conv;
10966 }
10967
10968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10969         LDKCVec_PrivateRouteZ _res_constr;
10970         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10971         if (_res_constr.datalen > 0)
10972                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10973         else
10974                 _res_constr.data = NULL;
10975         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10976         for (size_t o = 0; o < _res_constr.datalen; o++) {
10977                 int64_t _res_conv_14 = _res_vals[o];
10978                 LDKPrivateRoute _res_conv_14_conv;
10979                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10980                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10981                 _res_constr.data[o] = _res_conv_14_conv;
10982         }
10983         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10984         CVec_PrivateRouteZ_free(_res_constr);
10985 }
10986
10987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10988         LDKPositiveTimestamp o_conv;
10989         o_conv.inner = (void*)(o & (~1));
10990         o_conv.is_owned = (o & 1) || (o == 0);
10991         o_conv = PositiveTimestamp_clone(&o_conv);
10992         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10993         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10994         return (uint64_t)ret_conv;
10995 }
10996
10997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10998         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10999         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11000         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
11001         return (uint64_t)ret_conv;
11002 }
11003
11004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11005         if ((_res & 1) != 0) return;
11006         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
11007         FREE((void*)_res);
11008         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11009 }
11010
11011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11012         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11013         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11014         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11015         return (uint64_t)ret_conv;
11016 }
11017
11018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
11019         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11020         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11021         return (uint64_t)ret_conv;
11022 }
11023
11024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11025         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11026         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11027         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11028         return (uint64_t)ret_conv;
11029 }
11030
11031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11032         if ((_res & 1) != 0) return;
11033         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11034         FREE((void*)_res);
11035         CResult_NoneSemanticErrorZ_free(_res_conv);
11036 }
11037
11038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11039         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11040         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11041         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11042         return (uint64_t)ret_conv;
11043 }
11044
11045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11046         LDKInvoice o_conv;
11047         o_conv.inner = (void*)(o & (~1));
11048         o_conv.is_owned = (o & 1) || (o == 0);
11049         o_conv = Invoice_clone(&o_conv);
11050         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11051         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11052         return (uint64_t)ret_conv;
11053 }
11054
11055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11056         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11057         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11058         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11059         return (uint64_t)ret_conv;
11060 }
11061
11062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11063         if ((_res & 1) != 0) return;
11064         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11065         FREE((void*)_res);
11066         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11067 }
11068
11069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11070         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11071         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11072         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11073         return (uint64_t)ret_conv;
11074 }
11075
11076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11077         LDKDescription o_conv;
11078         o_conv.inner = (void*)(o & (~1));
11079         o_conv.is_owned = (o & 1) || (o == 0);
11080         o_conv = Description_clone(&o_conv);
11081         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11082         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11083         return (uint64_t)ret_conv;
11084 }
11085
11086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11087         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11088         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11089         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11090         return (uint64_t)ret_conv;
11091 }
11092
11093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11094         if ((_res & 1) != 0) return;
11095         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11096         FREE((void*)_res);
11097         CResult_DescriptionCreationErrorZ_free(_res_conv);
11098 }
11099
11100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11101         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11102         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11103         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11104         return (uint64_t)ret_conv;
11105 }
11106
11107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11108         LDKExpiryTime o_conv;
11109         o_conv.inner = (void*)(o & (~1));
11110         o_conv.is_owned = (o & 1) || (o == 0);
11111         o_conv = ExpiryTime_clone(&o_conv);
11112         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11113         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11114         return (uint64_t)ret_conv;
11115 }
11116
11117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11118         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11119         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11120         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11121         return (uint64_t)ret_conv;
11122 }
11123
11124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11125         if ((_res & 1) != 0) return;
11126         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11127         FREE((void*)_res);
11128         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11129 }
11130
11131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11132         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11133         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11134         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11135         return (uint64_t)ret_conv;
11136 }
11137
11138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11139         LDKPrivateRoute o_conv;
11140         o_conv.inner = (void*)(o & (~1));
11141         o_conv.is_owned = (o & 1) || (o == 0);
11142         o_conv = PrivateRoute_clone(&o_conv);
11143         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11144         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11145         return (uint64_t)ret_conv;
11146 }
11147
11148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11149         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11150         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11151         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11152         return (uint64_t)ret_conv;
11153 }
11154
11155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11156         if ((_res & 1) != 0) return;
11157         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11158         FREE((void*)_res);
11159         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11160 }
11161
11162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11163         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11164         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11165         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11166         return (uint64_t)ret_conv;
11167 }
11168
11169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11170         LDKStr o_conv = java_to_owned_str(env, o);
11171         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11172         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11173         return (uint64_t)ret_conv;
11174 }
11175
11176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11177         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11178         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11179         *ret_conv = CResult_StringErrorZ_err(e_conv);
11180         return (uint64_t)ret_conv;
11181 }
11182
11183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11184         if ((_res & 1) != 0) return;
11185         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11186         FREE((void*)_res);
11187         CResult_StringErrorZ_free(_res_conv);
11188 }
11189
11190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11191         LDKChannelMonitorUpdate o_conv;
11192         o_conv.inner = (void*)(o & (~1));
11193         o_conv.is_owned = (o & 1) || (o == 0);
11194         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11195         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11196         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11197         return (uint64_t)ret_conv;
11198 }
11199
11200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11201         LDKDecodeError e_conv;
11202         e_conv.inner = (void*)(e & (~1));
11203         e_conv.is_owned = (e & 1) || (e == 0);
11204         e_conv = DecodeError_clone(&e_conv);
11205         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11206         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11207         return (uint64_t)ret_conv;
11208 }
11209
11210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11211         if ((_res & 1) != 0) return;
11212         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11213         FREE((void*)_res);
11214         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11215 }
11216
11217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11218         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11219         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11220         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11221         return (uint64_t)ret_conv;
11222 }
11223
11224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11225         LDKHTLCUpdate o_conv;
11226         o_conv.inner = (void*)(o & (~1));
11227         o_conv.is_owned = (o & 1) || (o == 0);
11228         o_conv = HTLCUpdate_clone(&o_conv);
11229         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11230         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11231         return (uint64_t)ret_conv;
11232 }
11233
11234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11235         LDKDecodeError e_conv;
11236         e_conv.inner = (void*)(e & (~1));
11237         e_conv.is_owned = (e & 1) || (e == 0);
11238         e_conv = DecodeError_clone(&e_conv);
11239         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11240         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11241         return (uint64_t)ret_conv;
11242 }
11243
11244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11245         if ((_res & 1) != 0) return;
11246         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11247         FREE((void*)_res);
11248         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11249 }
11250
11251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11252         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11253         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11254         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11255         return (uint64_t)ret_conv;
11256 }
11257
11258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11259         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11260         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11261         return (uint64_t)ret_conv;
11262 }
11263
11264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11265         LDKMonitorUpdateError e_conv;
11266         e_conv.inner = (void*)(e & (~1));
11267         e_conv.is_owned = (e & 1) || (e == 0);
11268         e_conv = MonitorUpdateError_clone(&e_conv);
11269         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11270         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11271         return (uint64_t)ret_conv;
11272 }
11273
11274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11275         if ((_res & 1) != 0) return;
11276         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11277         FREE((void*)_res);
11278         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11279 }
11280
11281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11282         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11283         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11284         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11285         return (uint64_t)ret_conv;
11286 }
11287
11288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11289         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11290         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11291         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11292         return (uint64_t)ret_ref;
11293 }
11294
11295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11296         LDKOutPoint a_conv;
11297         a_conv.inner = (void*)(a & (~1));
11298         a_conv.is_owned = (a & 1) || (a == 0);
11299         a_conv = OutPoint_clone(&a_conv);
11300         LDKCVec_u8Z b_ref;
11301         b_ref.datalen = (*env)->GetArrayLength(env, b);
11302         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11303         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11304         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11305         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11306         return (uint64_t)ret_ref;
11307 }
11308
11309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11310         if ((_res & 1) != 0) return;
11311         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11312         FREE((void*)_res);
11313         C2Tuple_OutPointScriptZ_free(_res_conv);
11314 }
11315
11316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11317         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11318         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11319         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11320         return (uint64_t)ret_ref;
11321 }
11322
11323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11324         LDKCVec_u8Z b_ref;
11325         b_ref.datalen = (*env)->GetArrayLength(env, b);
11326         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11327         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11328         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11329         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11330         return (uint64_t)ret_ref;
11331 }
11332
11333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11334         if ((_res & 1) != 0) return;
11335         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11336         FREE((void*)_res);
11337         C2Tuple_u32ScriptZ_free(_res_conv);
11338 }
11339
11340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11341         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11342         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11343         if (_res_constr.datalen > 0)
11344                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11345         else
11346                 _res_constr.data = NULL;
11347         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11348         for (size_t b = 0; b < _res_constr.datalen; b++) {
11349                 int64_t _res_conv_27 = _res_vals[b];
11350                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11351                 FREE((void*)_res_conv_27);
11352                 _res_constr.data[b] = _res_conv_27_conv;
11353         }
11354         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11355         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11356 }
11357
11358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11359         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11360         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11361         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11362         return (uint64_t)ret_ref;
11363 }
11364
11365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11366         LDKThirtyTwoBytes a_ref;
11367         CHECK((*env)->GetArrayLength(env, a) == 32);
11368         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11369         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11370         b_constr.datalen = (*env)->GetArrayLength(env, b);
11371         if (b_constr.datalen > 0)
11372                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11373         else
11374                 b_constr.data = NULL;
11375         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11376         for (size_t b = 0; b < b_constr.datalen; b++) {
11377                 int64_t b_conv_27 = b_vals[b];
11378                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11379                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11380                 b_constr.data[b] = b_conv_27_conv;
11381         }
11382         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11383         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11384         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11385         return (uint64_t)ret_ref;
11386 }
11387
11388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11389         if ((_res & 1) != 0) return;
11390         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11391         FREE((void*)_res);
11392         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11393 }
11394
11395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11396         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11397         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11398         if (_res_constr.datalen > 0)
11399                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11400         else
11401                 _res_constr.data = NULL;
11402         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11403         for (size_t v = 0; v < _res_constr.datalen; v++) {
11404                 int64_t _res_conv_47 = _res_vals[v];
11405                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11406                 FREE((void*)_res_conv_47);
11407                 _res_constr.data[v] = _res_conv_47_conv;
11408         }
11409         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11410         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11411 }
11412
11413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11414         LDKCVec_EventZ _res_constr;
11415         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11416         if (_res_constr.datalen > 0)
11417                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11418         else
11419                 _res_constr.data = NULL;
11420         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11421         for (size_t h = 0; h < _res_constr.datalen; h++) {
11422                 int64_t _res_conv_7 = _res_vals[h];
11423                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11424                 FREE((void*)_res_conv_7);
11425                 _res_constr.data[h] = _res_conv_7_conv;
11426         }
11427         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11428         CVec_EventZ_free(_res_constr);
11429 }
11430
11431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11432         LDKCVec_TransactionZ _res_constr;
11433         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11434         if (_res_constr.datalen > 0)
11435                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11436         else
11437                 _res_constr.data = NULL;
11438         for (size_t i = 0; i < _res_constr.datalen; i++) {
11439                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11440                 LDKTransaction _res_conv_8_ref;
11441                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11442                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11443                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11444                 _res_conv_8_ref.data_is_owned = true;
11445                 _res_constr.data[i] = _res_conv_8_ref;
11446         }
11447         CVec_TransactionZ_free(_res_constr);
11448 }
11449
11450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11451         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11452         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11453         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11454         return (uint64_t)ret_ref;
11455 }
11456
11457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11458         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11459         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11460         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11461         return (uint64_t)ret_ref;
11462 }
11463
11464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11465         if ((_res & 1) != 0) return;
11466         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11467         FREE((void*)_res);
11468         C2Tuple_u32TxOutZ_free(_res_conv);
11469 }
11470
11471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11472         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11473         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11474         if (_res_constr.datalen > 0)
11475                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11476         else
11477                 _res_constr.data = NULL;
11478         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11479         for (size_t a = 0; a < _res_constr.datalen; a++) {
11480                 int64_t _res_conv_26 = _res_vals[a];
11481                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11482                 FREE((void*)_res_conv_26);
11483                 _res_constr.data[a] = _res_conv_26_conv;
11484         }
11485         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11486         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11487 }
11488
11489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11490         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11491         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11492         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11493         return (uint64_t)ret_ref;
11494 }
11495
11496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11497         LDKThirtyTwoBytes a_ref;
11498         CHECK((*env)->GetArrayLength(env, a) == 32);
11499         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11500         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11501         b_constr.datalen = (*env)->GetArrayLength(env, b);
11502         if (b_constr.datalen > 0)
11503                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11504         else
11505                 b_constr.data = NULL;
11506         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11507         for (size_t a = 0; a < b_constr.datalen; a++) {
11508                 int64_t b_conv_26 = b_vals[a];
11509                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11510                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11511                 b_constr.data[a] = b_conv_26_conv;
11512         }
11513         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11514         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11515         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11516         return (uint64_t)ret_ref;
11517 }
11518
11519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11520         if ((_res & 1) != 0) return;
11521         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11522         FREE((void*)_res);
11523         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11524 }
11525
11526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11527         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11528         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11529         if (_res_constr.datalen > 0)
11530                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11531         else
11532                 _res_constr.data = NULL;
11533         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11534         for (size_t u = 0; u < _res_constr.datalen; u++) {
11535                 int64_t _res_conv_46 = _res_vals[u];
11536                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11537                 FREE((void*)_res_conv_46);
11538                 _res_constr.data[u] = _res_conv_46_conv;
11539         }
11540         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11541         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11542 }
11543
11544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11545         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11546         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11547         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11548         return (uint64_t)ret_conv;
11549 }
11550
11551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11552         LDKDecodeError e_conv;
11553         e_conv.inner = (void*)(e & (~1));
11554         e_conv.is_owned = (e & 1) || (e == 0);
11555         e_conv = DecodeError_clone(&e_conv);
11556         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11557         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11558         return (uint64_t)ret_conv;
11559 }
11560
11561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11562         if ((_res & 1) != 0) return;
11563         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11564         FREE((void*)_res);
11565         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11566 }
11567
11568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11569         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11570         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11571         return (uint64_t)ret_conv;
11572 }
11573
11574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11575         LDKLightningError e_conv;
11576         e_conv.inner = (void*)(e & (~1));
11577         e_conv.is_owned = (e & 1) || (e == 0);
11578         e_conv = LightningError_clone(&e_conv);
11579         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11580         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11581         return (uint64_t)ret_conv;
11582 }
11583
11584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11585         if ((_res & 1) != 0) return;
11586         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11587         FREE((void*)_res);
11588         CResult_boolLightningErrorZ_free(_res_conv);
11589 }
11590
11591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11592         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11593         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11594         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11595         return (uint64_t)ret_conv;
11596 }
11597
11598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11599         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11600         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11601         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11602         return (uint64_t)ret_ref;
11603 }
11604
11605 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) {
11606         LDKChannelAnnouncement a_conv;
11607         a_conv.inner = (void*)(a & (~1));
11608         a_conv.is_owned = (a & 1) || (a == 0);
11609         a_conv = ChannelAnnouncement_clone(&a_conv);
11610         LDKChannelUpdate b_conv;
11611         b_conv.inner = (void*)(b & (~1));
11612         b_conv.is_owned = (b & 1) || (b == 0);
11613         b_conv = ChannelUpdate_clone(&b_conv);
11614         LDKChannelUpdate c_conv;
11615         c_conv.inner = (void*)(c & (~1));
11616         c_conv.is_owned = (c & 1) || (c == 0);
11617         c_conv = ChannelUpdate_clone(&c_conv);
11618         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11619         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11620         return (uint64_t)ret_ref;
11621 }
11622
11623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11624         if ((_res & 1) != 0) return;
11625         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11626         FREE((void*)_res);
11627         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11628 }
11629
11630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11631         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11632         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11633         if (_res_constr.datalen > 0)
11634                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11635         else
11636                 _res_constr.data = NULL;
11637         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11638         for (size_t l = 0; l < _res_constr.datalen; l++) {
11639                 int64_t _res_conv_63 = _res_vals[l];
11640                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11641                 FREE((void*)_res_conv_63);
11642                 _res_constr.data[l] = _res_conv_63_conv;
11643         }
11644         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11645         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11646 }
11647
11648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11649         LDKCVec_NodeAnnouncementZ _res_constr;
11650         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11651         if (_res_constr.datalen > 0)
11652                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11653         else
11654                 _res_constr.data = NULL;
11655         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11656         for (size_t s = 0; s < _res_constr.datalen; s++) {
11657                 int64_t _res_conv_18 = _res_vals[s];
11658                 LDKNodeAnnouncement _res_conv_18_conv;
11659                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11660                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11661                 _res_constr.data[s] = _res_conv_18_conv;
11662         }
11663         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11664         CVec_NodeAnnouncementZ_free(_res_constr);
11665 }
11666
11667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11668         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11669         *ret_conv = CResult_NoneLightningErrorZ_ok();
11670         return (uint64_t)ret_conv;
11671 }
11672
11673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11674         LDKLightningError e_conv;
11675         e_conv.inner = (void*)(e & (~1));
11676         e_conv.is_owned = (e & 1) || (e == 0);
11677         e_conv = LightningError_clone(&e_conv);
11678         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11679         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11680         return (uint64_t)ret_conv;
11681 }
11682
11683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11684         if ((_res & 1) != 0) return;
11685         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11686         FREE((void*)_res);
11687         CResult_NoneLightningErrorZ_free(_res_conv);
11688 }
11689
11690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11691         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11692         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11693         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11694         return (uint64_t)ret_conv;
11695 }
11696
11697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11698         LDKCVec_PublicKeyZ _res_constr;
11699         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11700         if (_res_constr.datalen > 0)
11701                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11702         else
11703                 _res_constr.data = NULL;
11704         for (size_t i = 0; i < _res_constr.datalen; i++) {
11705                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11706                 LDKPublicKey _res_conv_8_ref;
11707                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11708                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11709                 _res_constr.data[i] = _res_conv_8_ref;
11710         }
11711         CVec_PublicKeyZ_free(_res_constr);
11712 }
11713
11714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11715         LDKCVec_u8Z o_ref;
11716         o_ref.datalen = (*env)->GetArrayLength(env, o);
11717         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11718         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11719         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11720         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11721         return (uint64_t)ret_conv;
11722 }
11723
11724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11725         LDKPeerHandleError e_conv;
11726         e_conv.inner = (void*)(e & (~1));
11727         e_conv.is_owned = (e & 1) || (e == 0);
11728         e_conv = PeerHandleError_clone(&e_conv);
11729         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11730         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11731         return (uint64_t)ret_conv;
11732 }
11733
11734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11735         if ((_res & 1) != 0) return;
11736         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11737         FREE((void*)_res);
11738         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11739 }
11740
11741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11742         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11743         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11744         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11745         return (uint64_t)ret_conv;
11746 }
11747
11748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11749         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11750         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11751         return (uint64_t)ret_conv;
11752 }
11753
11754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11755         LDKPeerHandleError e_conv;
11756         e_conv.inner = (void*)(e & (~1));
11757         e_conv.is_owned = (e & 1) || (e == 0);
11758         e_conv = PeerHandleError_clone(&e_conv);
11759         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11760         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11761         return (uint64_t)ret_conv;
11762 }
11763
11764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11765         if ((_res & 1) != 0) return;
11766         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11767         FREE((void*)_res);
11768         CResult_NonePeerHandleErrorZ_free(_res_conv);
11769 }
11770
11771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11772         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11773         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11774         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11775         return (uint64_t)ret_conv;
11776 }
11777
11778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11779         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11780         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11781         return (uint64_t)ret_conv;
11782 }
11783
11784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11785         LDKPeerHandleError e_conv;
11786         e_conv.inner = (void*)(e & (~1));
11787         e_conv.is_owned = (e & 1) || (e == 0);
11788         e_conv = PeerHandleError_clone(&e_conv);
11789         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11790         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11791         return (uint64_t)ret_conv;
11792 }
11793
11794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11795         if ((_res & 1) != 0) return;
11796         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11797         FREE((void*)_res);
11798         CResult_boolPeerHandleErrorZ_free(_res_conv);
11799 }
11800
11801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11802         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11803         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11804         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11805         return (uint64_t)ret_conv;
11806 }
11807
11808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11809         LDKDirectionalChannelInfo o_conv;
11810         o_conv.inner = (void*)(o & (~1));
11811         o_conv.is_owned = (o & 1) || (o == 0);
11812         o_conv = DirectionalChannelInfo_clone(&o_conv);
11813         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11814         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11815         return (uint64_t)ret_conv;
11816 }
11817
11818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11819         LDKDecodeError e_conv;
11820         e_conv.inner = (void*)(e & (~1));
11821         e_conv.is_owned = (e & 1) || (e == 0);
11822         e_conv = DecodeError_clone(&e_conv);
11823         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11824         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11825         return (uint64_t)ret_conv;
11826 }
11827
11828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11829         if ((_res & 1) != 0) return;
11830         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11831         FREE((void*)_res);
11832         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11833 }
11834
11835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11836         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11837         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11838         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11839         return (uint64_t)ret_conv;
11840 }
11841
11842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11843         LDKChannelInfo o_conv;
11844         o_conv.inner = (void*)(o & (~1));
11845         o_conv.is_owned = (o & 1) || (o == 0);
11846         o_conv = ChannelInfo_clone(&o_conv);
11847         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11848         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11849         return (uint64_t)ret_conv;
11850 }
11851
11852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11853         LDKDecodeError e_conv;
11854         e_conv.inner = (void*)(e & (~1));
11855         e_conv.is_owned = (e & 1) || (e == 0);
11856         e_conv = DecodeError_clone(&e_conv);
11857         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11858         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11859         return (uint64_t)ret_conv;
11860 }
11861
11862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11863         if ((_res & 1) != 0) return;
11864         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11865         FREE((void*)_res);
11866         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11867 }
11868
11869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11870         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11871         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11872         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11873         return (uint64_t)ret_conv;
11874 }
11875
11876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11877         LDKRoutingFees o_conv;
11878         o_conv.inner = (void*)(o & (~1));
11879         o_conv.is_owned = (o & 1) || (o == 0);
11880         o_conv = RoutingFees_clone(&o_conv);
11881         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11882         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11883         return (uint64_t)ret_conv;
11884 }
11885
11886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11887         LDKDecodeError e_conv;
11888         e_conv.inner = (void*)(e & (~1));
11889         e_conv.is_owned = (e & 1) || (e == 0);
11890         e_conv = DecodeError_clone(&e_conv);
11891         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11892         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11893         return (uint64_t)ret_conv;
11894 }
11895
11896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11897         if ((_res & 1) != 0) return;
11898         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11899         FREE((void*)_res);
11900         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11901 }
11902
11903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11904         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11905         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11906         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11907         return (uint64_t)ret_conv;
11908 }
11909
11910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11911         LDKNodeAnnouncementInfo o_conv;
11912         o_conv.inner = (void*)(o & (~1));
11913         o_conv.is_owned = (o & 1) || (o == 0);
11914         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11915         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11916         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11917         return (uint64_t)ret_conv;
11918 }
11919
11920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11921         LDKDecodeError e_conv;
11922         e_conv.inner = (void*)(e & (~1));
11923         e_conv.is_owned = (e & 1) || (e == 0);
11924         e_conv = DecodeError_clone(&e_conv);
11925         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11926         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11927         return (uint64_t)ret_conv;
11928 }
11929
11930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11931         if ((_res & 1) != 0) return;
11932         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11933         FREE((void*)_res);
11934         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11935 }
11936
11937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11938         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11939         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11940         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11941         return (uint64_t)ret_conv;
11942 }
11943
11944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11945         LDKCVec_u64Z _res_constr;
11946         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11947         if (_res_constr.datalen > 0)
11948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11949         else
11950                 _res_constr.data = NULL;
11951         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11952         for (size_t g = 0; g < _res_constr.datalen; g++) {
11953                 int64_t _res_conv_6 = _res_vals[g];
11954                 _res_constr.data[g] = _res_conv_6;
11955         }
11956         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11957         CVec_u64Z_free(_res_constr);
11958 }
11959
11960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11961         LDKNodeInfo o_conv;
11962         o_conv.inner = (void*)(o & (~1));
11963         o_conv.is_owned = (o & 1) || (o == 0);
11964         o_conv = NodeInfo_clone(&o_conv);
11965         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11966         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11967         return (uint64_t)ret_conv;
11968 }
11969
11970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11971         LDKDecodeError e_conv;
11972         e_conv.inner = (void*)(e & (~1));
11973         e_conv.is_owned = (e & 1) || (e == 0);
11974         e_conv = DecodeError_clone(&e_conv);
11975         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11976         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11977         return (uint64_t)ret_conv;
11978 }
11979
11980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11981         if ((_res & 1) != 0) return;
11982         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11983         FREE((void*)_res);
11984         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11985 }
11986
11987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11988         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11989         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11990         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11991         return (uint64_t)ret_conv;
11992 }
11993
11994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11995         LDKNetworkGraph o_conv;
11996         o_conv.inner = (void*)(o & (~1));
11997         o_conv.is_owned = (o & 1) || (o == 0);
11998         o_conv = NetworkGraph_clone(&o_conv);
11999         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12000         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12001         return (uint64_t)ret_conv;
12002 }
12003
12004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12005         LDKDecodeError e_conv;
12006         e_conv.inner = (void*)(e & (~1));
12007         e_conv.is_owned = (e & 1) || (e == 0);
12008         e_conv = DecodeError_clone(&e_conv);
12009         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12010         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12011         return (uint64_t)ret_conv;
12012 }
12013
12014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12015         if ((_res & 1) != 0) return;
12016         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
12017         FREE((void*)_res);
12018         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12019 }
12020
12021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12022         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12023         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12024         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12025         return (uint64_t)ret_conv;
12026 }
12027
12028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12029         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12030         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12031         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12032         return (uint64_t)ret_conv;
12033 }
12034
12035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12036         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12037         *ret_conv = CResult_NetAddressu8Z_err(e);
12038         return (uint64_t)ret_conv;
12039 }
12040
12041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12042         if ((_res & 1) != 0) return;
12043         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12044         FREE((void*)_res);
12045         CResult_NetAddressu8Z_free(_res_conv);
12046 }
12047
12048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12049         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12050         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12051         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12052         return (uint64_t)ret_conv;
12053 }
12054
12055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12056         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12057         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12058         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12059         return (uint64_t)ret_conv;
12060 }
12061
12062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12063         LDKDecodeError e_conv;
12064         e_conv.inner = (void*)(e & (~1));
12065         e_conv.is_owned = (e & 1) || (e == 0);
12066         e_conv = DecodeError_clone(&e_conv);
12067         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12068         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12069         return (uint64_t)ret_conv;
12070 }
12071
12072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12073         if ((_res & 1) != 0) return;
12074         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12075         FREE((void*)_res);
12076         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12077 }
12078
12079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12080         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12081         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12082         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12083         return (uint64_t)ret_conv;
12084 }
12085
12086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12087         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12088         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12089         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12090         return (uint64_t)ret_conv;
12091 }
12092
12093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12094         LDKDecodeError e_conv;
12095         e_conv.inner = (void*)(e & (~1));
12096         e_conv.is_owned = (e & 1) || (e == 0);
12097         e_conv = DecodeError_clone(&e_conv);
12098         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12099         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12100         return (uint64_t)ret_conv;
12101 }
12102
12103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12104         if ((_res & 1) != 0) return;
12105         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12106         FREE((void*)_res);
12107         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12108 }
12109
12110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12111         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12112         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12113         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12114         return (uint64_t)ret_conv;
12115 }
12116
12117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12118         LDKCVec_UpdateAddHTLCZ _res_constr;
12119         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12120         if (_res_constr.datalen > 0)
12121                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12122         else
12123                 _res_constr.data = NULL;
12124         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12125         for (size_t p = 0; p < _res_constr.datalen; p++) {
12126                 int64_t _res_conv_15 = _res_vals[p];
12127                 LDKUpdateAddHTLC _res_conv_15_conv;
12128                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12129                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12130                 _res_constr.data[p] = _res_conv_15_conv;
12131         }
12132         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12133         CVec_UpdateAddHTLCZ_free(_res_constr);
12134 }
12135
12136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12137         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12138         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12139         if (_res_constr.datalen > 0)
12140                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12141         else
12142                 _res_constr.data = NULL;
12143         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12144         for (size_t t = 0; t < _res_constr.datalen; t++) {
12145                 int64_t _res_conv_19 = _res_vals[t];
12146                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12147                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12148                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12149                 _res_constr.data[t] = _res_conv_19_conv;
12150         }
12151         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12152         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12153 }
12154
12155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12156         LDKCVec_UpdateFailHTLCZ _res_constr;
12157         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12158         if (_res_constr.datalen > 0)
12159                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12160         else
12161                 _res_constr.data = NULL;
12162         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12163         for (size_t q = 0; q < _res_constr.datalen; q++) {
12164                 int64_t _res_conv_16 = _res_vals[q];
12165                 LDKUpdateFailHTLC _res_conv_16_conv;
12166                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12167                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12168                 _res_constr.data[q] = _res_conv_16_conv;
12169         }
12170         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12171         CVec_UpdateFailHTLCZ_free(_res_constr);
12172 }
12173
12174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12175         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12176         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12177         if (_res_constr.datalen > 0)
12178                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12179         else
12180                 _res_constr.data = NULL;
12181         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12182         for (size_t z = 0; z < _res_constr.datalen; z++) {
12183                 int64_t _res_conv_25 = _res_vals[z];
12184                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12185                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12186                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12187                 _res_constr.data[z] = _res_conv_25_conv;
12188         }
12189         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12190         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12191 }
12192
12193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12194         LDKAcceptChannel o_conv;
12195         o_conv.inner = (void*)(o & (~1));
12196         o_conv.is_owned = (o & 1) || (o == 0);
12197         o_conv = AcceptChannel_clone(&o_conv);
12198         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12199         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12200         return (uint64_t)ret_conv;
12201 }
12202
12203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12204         LDKDecodeError e_conv;
12205         e_conv.inner = (void*)(e & (~1));
12206         e_conv.is_owned = (e & 1) || (e == 0);
12207         e_conv = DecodeError_clone(&e_conv);
12208         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12209         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12210         return (uint64_t)ret_conv;
12211 }
12212
12213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12214         if ((_res & 1) != 0) return;
12215         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12216         FREE((void*)_res);
12217         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12218 }
12219
12220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12221         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12222         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12223         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12224         return (uint64_t)ret_conv;
12225 }
12226
12227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12228         LDKAnnouncementSignatures o_conv;
12229         o_conv.inner = (void*)(o & (~1));
12230         o_conv.is_owned = (o & 1) || (o == 0);
12231         o_conv = AnnouncementSignatures_clone(&o_conv);
12232         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12233         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12234         return (uint64_t)ret_conv;
12235 }
12236
12237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12238         LDKDecodeError e_conv;
12239         e_conv.inner = (void*)(e & (~1));
12240         e_conv.is_owned = (e & 1) || (e == 0);
12241         e_conv = DecodeError_clone(&e_conv);
12242         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12243         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12244         return (uint64_t)ret_conv;
12245 }
12246
12247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12248         if ((_res & 1) != 0) return;
12249         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12250         FREE((void*)_res);
12251         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12252 }
12253
12254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12255         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12256         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12257         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12258         return (uint64_t)ret_conv;
12259 }
12260
12261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12262         LDKChannelReestablish o_conv;
12263         o_conv.inner = (void*)(o & (~1));
12264         o_conv.is_owned = (o & 1) || (o == 0);
12265         o_conv = ChannelReestablish_clone(&o_conv);
12266         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12267         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12268         return (uint64_t)ret_conv;
12269 }
12270
12271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12272         LDKDecodeError e_conv;
12273         e_conv.inner = (void*)(e & (~1));
12274         e_conv.is_owned = (e & 1) || (e == 0);
12275         e_conv = DecodeError_clone(&e_conv);
12276         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12277         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12278         return (uint64_t)ret_conv;
12279 }
12280
12281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12282         if ((_res & 1) != 0) return;
12283         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12284         FREE((void*)_res);
12285         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12286 }
12287
12288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12289         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12290         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12291         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12292         return (uint64_t)ret_conv;
12293 }
12294
12295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12296         LDKClosingSigned o_conv;
12297         o_conv.inner = (void*)(o & (~1));
12298         o_conv.is_owned = (o & 1) || (o == 0);
12299         o_conv = ClosingSigned_clone(&o_conv);
12300         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12301         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12302         return (uint64_t)ret_conv;
12303 }
12304
12305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12306         LDKDecodeError e_conv;
12307         e_conv.inner = (void*)(e & (~1));
12308         e_conv.is_owned = (e & 1) || (e == 0);
12309         e_conv = DecodeError_clone(&e_conv);
12310         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12311         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12312         return (uint64_t)ret_conv;
12313 }
12314
12315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12316         if ((_res & 1) != 0) return;
12317         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12318         FREE((void*)_res);
12319         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12320 }
12321
12322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12323         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12324         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12325         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12326         return (uint64_t)ret_conv;
12327 }
12328
12329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12330         LDKCommitmentSigned o_conv;
12331         o_conv.inner = (void*)(o & (~1));
12332         o_conv.is_owned = (o & 1) || (o == 0);
12333         o_conv = CommitmentSigned_clone(&o_conv);
12334         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12335         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12336         return (uint64_t)ret_conv;
12337 }
12338
12339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12340         LDKDecodeError e_conv;
12341         e_conv.inner = (void*)(e & (~1));
12342         e_conv.is_owned = (e & 1) || (e == 0);
12343         e_conv = DecodeError_clone(&e_conv);
12344         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12345         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12346         return (uint64_t)ret_conv;
12347 }
12348
12349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12350         if ((_res & 1) != 0) return;
12351         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12352         FREE((void*)_res);
12353         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12354 }
12355
12356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12357         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12358         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12359         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12360         return (uint64_t)ret_conv;
12361 }
12362
12363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12364         LDKFundingCreated o_conv;
12365         o_conv.inner = (void*)(o & (~1));
12366         o_conv.is_owned = (o & 1) || (o == 0);
12367         o_conv = FundingCreated_clone(&o_conv);
12368         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12369         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12370         return (uint64_t)ret_conv;
12371 }
12372
12373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12374         LDKDecodeError e_conv;
12375         e_conv.inner = (void*)(e & (~1));
12376         e_conv.is_owned = (e & 1) || (e == 0);
12377         e_conv = DecodeError_clone(&e_conv);
12378         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12379         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12380         return (uint64_t)ret_conv;
12381 }
12382
12383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12384         if ((_res & 1) != 0) return;
12385         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12386         FREE((void*)_res);
12387         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12388 }
12389
12390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12391         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12392         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12393         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12394         return (uint64_t)ret_conv;
12395 }
12396
12397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12398         LDKFundingSigned o_conv;
12399         o_conv.inner = (void*)(o & (~1));
12400         o_conv.is_owned = (o & 1) || (o == 0);
12401         o_conv = FundingSigned_clone(&o_conv);
12402         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12403         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12404         return (uint64_t)ret_conv;
12405 }
12406
12407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12408         LDKDecodeError e_conv;
12409         e_conv.inner = (void*)(e & (~1));
12410         e_conv.is_owned = (e & 1) || (e == 0);
12411         e_conv = DecodeError_clone(&e_conv);
12412         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12413         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12414         return (uint64_t)ret_conv;
12415 }
12416
12417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12418         if ((_res & 1) != 0) return;
12419         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12420         FREE((void*)_res);
12421         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12422 }
12423
12424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12425         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12426         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12427         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12428         return (uint64_t)ret_conv;
12429 }
12430
12431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12432         LDKFundingLocked o_conv;
12433         o_conv.inner = (void*)(o & (~1));
12434         o_conv.is_owned = (o & 1) || (o == 0);
12435         o_conv = FundingLocked_clone(&o_conv);
12436         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12437         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12438         return (uint64_t)ret_conv;
12439 }
12440
12441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12442         LDKDecodeError e_conv;
12443         e_conv.inner = (void*)(e & (~1));
12444         e_conv.is_owned = (e & 1) || (e == 0);
12445         e_conv = DecodeError_clone(&e_conv);
12446         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12447         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12448         return (uint64_t)ret_conv;
12449 }
12450
12451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12452         if ((_res & 1) != 0) return;
12453         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12454         FREE((void*)_res);
12455         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12456 }
12457
12458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12459         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12460         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12461         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12462         return (uint64_t)ret_conv;
12463 }
12464
12465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12466         LDKInit o_conv;
12467         o_conv.inner = (void*)(o & (~1));
12468         o_conv.is_owned = (o & 1) || (o == 0);
12469         o_conv = Init_clone(&o_conv);
12470         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12471         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12472         return (uint64_t)ret_conv;
12473 }
12474
12475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12476         LDKDecodeError e_conv;
12477         e_conv.inner = (void*)(e & (~1));
12478         e_conv.is_owned = (e & 1) || (e == 0);
12479         e_conv = DecodeError_clone(&e_conv);
12480         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12481         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12482         return (uint64_t)ret_conv;
12483 }
12484
12485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12486         if ((_res & 1) != 0) return;
12487         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12488         FREE((void*)_res);
12489         CResult_InitDecodeErrorZ_free(_res_conv);
12490 }
12491
12492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12493         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12494         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12495         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12496         return (uint64_t)ret_conv;
12497 }
12498
12499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12500         LDKOpenChannel o_conv;
12501         o_conv.inner = (void*)(o & (~1));
12502         o_conv.is_owned = (o & 1) || (o == 0);
12503         o_conv = OpenChannel_clone(&o_conv);
12504         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12505         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12506         return (uint64_t)ret_conv;
12507 }
12508
12509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12510         LDKDecodeError e_conv;
12511         e_conv.inner = (void*)(e & (~1));
12512         e_conv.is_owned = (e & 1) || (e == 0);
12513         e_conv = DecodeError_clone(&e_conv);
12514         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12515         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12516         return (uint64_t)ret_conv;
12517 }
12518
12519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12520         if ((_res & 1) != 0) return;
12521         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12522         FREE((void*)_res);
12523         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12524 }
12525
12526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12527         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12528         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12529         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12530         return (uint64_t)ret_conv;
12531 }
12532
12533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12534         LDKRevokeAndACK o_conv;
12535         o_conv.inner = (void*)(o & (~1));
12536         o_conv.is_owned = (o & 1) || (o == 0);
12537         o_conv = RevokeAndACK_clone(&o_conv);
12538         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12539         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12540         return (uint64_t)ret_conv;
12541 }
12542
12543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12544         LDKDecodeError e_conv;
12545         e_conv.inner = (void*)(e & (~1));
12546         e_conv.is_owned = (e & 1) || (e == 0);
12547         e_conv = DecodeError_clone(&e_conv);
12548         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12549         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12550         return (uint64_t)ret_conv;
12551 }
12552
12553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12554         if ((_res & 1) != 0) return;
12555         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12556         FREE((void*)_res);
12557         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12558 }
12559
12560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12561         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12562         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12563         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12564         return (uint64_t)ret_conv;
12565 }
12566
12567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12568         LDKShutdown o_conv;
12569         o_conv.inner = (void*)(o & (~1));
12570         o_conv.is_owned = (o & 1) || (o == 0);
12571         o_conv = Shutdown_clone(&o_conv);
12572         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12573         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12574         return (uint64_t)ret_conv;
12575 }
12576
12577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12578         LDKDecodeError e_conv;
12579         e_conv.inner = (void*)(e & (~1));
12580         e_conv.is_owned = (e & 1) || (e == 0);
12581         e_conv = DecodeError_clone(&e_conv);
12582         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12583         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12584         return (uint64_t)ret_conv;
12585 }
12586
12587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12588         if ((_res & 1) != 0) return;
12589         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12590         FREE((void*)_res);
12591         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12592 }
12593
12594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12595         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12596         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12597         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12598         return (uint64_t)ret_conv;
12599 }
12600
12601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12602         LDKUpdateFailHTLC o_conv;
12603         o_conv.inner = (void*)(o & (~1));
12604         o_conv.is_owned = (o & 1) || (o == 0);
12605         o_conv = UpdateFailHTLC_clone(&o_conv);
12606         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12607         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12608         return (uint64_t)ret_conv;
12609 }
12610
12611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12612         LDKDecodeError e_conv;
12613         e_conv.inner = (void*)(e & (~1));
12614         e_conv.is_owned = (e & 1) || (e == 0);
12615         e_conv = DecodeError_clone(&e_conv);
12616         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12617         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12618         return (uint64_t)ret_conv;
12619 }
12620
12621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12622         if ((_res & 1) != 0) return;
12623         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12624         FREE((void*)_res);
12625         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12626 }
12627
12628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12629         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12630         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12631         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12632         return (uint64_t)ret_conv;
12633 }
12634
12635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12636         LDKUpdateFailMalformedHTLC o_conv;
12637         o_conv.inner = (void*)(o & (~1));
12638         o_conv.is_owned = (o & 1) || (o == 0);
12639         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12640         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12641         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12642         return (uint64_t)ret_conv;
12643 }
12644
12645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12646         LDKDecodeError e_conv;
12647         e_conv.inner = (void*)(e & (~1));
12648         e_conv.is_owned = (e & 1) || (e == 0);
12649         e_conv = DecodeError_clone(&e_conv);
12650         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12651         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12652         return (uint64_t)ret_conv;
12653 }
12654
12655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12656         if ((_res & 1) != 0) return;
12657         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12658         FREE((void*)_res);
12659         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12660 }
12661
12662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12663         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12664         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12665         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12666         return (uint64_t)ret_conv;
12667 }
12668
12669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12670         LDKUpdateFee o_conv;
12671         o_conv.inner = (void*)(o & (~1));
12672         o_conv.is_owned = (o & 1) || (o == 0);
12673         o_conv = UpdateFee_clone(&o_conv);
12674         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12675         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12676         return (uint64_t)ret_conv;
12677 }
12678
12679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12680         LDKDecodeError e_conv;
12681         e_conv.inner = (void*)(e & (~1));
12682         e_conv.is_owned = (e & 1) || (e == 0);
12683         e_conv = DecodeError_clone(&e_conv);
12684         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12685         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12686         return (uint64_t)ret_conv;
12687 }
12688
12689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12690         if ((_res & 1) != 0) return;
12691         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12692         FREE((void*)_res);
12693         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12694 }
12695
12696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12697         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12698         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12699         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12700         return (uint64_t)ret_conv;
12701 }
12702
12703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12704         LDKUpdateFulfillHTLC o_conv;
12705         o_conv.inner = (void*)(o & (~1));
12706         o_conv.is_owned = (o & 1) || (o == 0);
12707         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12708         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12709         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12710         return (uint64_t)ret_conv;
12711 }
12712
12713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12714         LDKDecodeError e_conv;
12715         e_conv.inner = (void*)(e & (~1));
12716         e_conv.is_owned = (e & 1) || (e == 0);
12717         e_conv = DecodeError_clone(&e_conv);
12718         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12719         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12720         return (uint64_t)ret_conv;
12721 }
12722
12723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12724         if ((_res & 1) != 0) return;
12725         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12726         FREE((void*)_res);
12727         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12728 }
12729
12730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12731         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12732         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12733         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12734         return (uint64_t)ret_conv;
12735 }
12736
12737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12738         LDKUpdateAddHTLC o_conv;
12739         o_conv.inner = (void*)(o & (~1));
12740         o_conv.is_owned = (o & 1) || (o == 0);
12741         o_conv = UpdateAddHTLC_clone(&o_conv);
12742         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12743         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12744         return (uint64_t)ret_conv;
12745 }
12746
12747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12748         LDKDecodeError e_conv;
12749         e_conv.inner = (void*)(e & (~1));
12750         e_conv.is_owned = (e & 1) || (e == 0);
12751         e_conv = DecodeError_clone(&e_conv);
12752         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12753         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12754         return (uint64_t)ret_conv;
12755 }
12756
12757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12758         if ((_res & 1) != 0) return;
12759         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12760         FREE((void*)_res);
12761         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12762 }
12763
12764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12765         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12766         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12767         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12768         return (uint64_t)ret_conv;
12769 }
12770
12771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12772         LDKPing o_conv;
12773         o_conv.inner = (void*)(o & (~1));
12774         o_conv.is_owned = (o & 1) || (o == 0);
12775         o_conv = Ping_clone(&o_conv);
12776         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12777         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12778         return (uint64_t)ret_conv;
12779 }
12780
12781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12782         LDKDecodeError e_conv;
12783         e_conv.inner = (void*)(e & (~1));
12784         e_conv.is_owned = (e & 1) || (e == 0);
12785         e_conv = DecodeError_clone(&e_conv);
12786         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12787         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12788         return (uint64_t)ret_conv;
12789 }
12790
12791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12792         if ((_res & 1) != 0) return;
12793         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12794         FREE((void*)_res);
12795         CResult_PingDecodeErrorZ_free(_res_conv);
12796 }
12797
12798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12799         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12800         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12801         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12802         return (uint64_t)ret_conv;
12803 }
12804
12805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12806         LDKPong o_conv;
12807         o_conv.inner = (void*)(o & (~1));
12808         o_conv.is_owned = (o & 1) || (o == 0);
12809         o_conv = Pong_clone(&o_conv);
12810         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12811         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12812         return (uint64_t)ret_conv;
12813 }
12814
12815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12816         LDKDecodeError e_conv;
12817         e_conv.inner = (void*)(e & (~1));
12818         e_conv.is_owned = (e & 1) || (e == 0);
12819         e_conv = DecodeError_clone(&e_conv);
12820         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12821         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12822         return (uint64_t)ret_conv;
12823 }
12824
12825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12826         if ((_res & 1) != 0) return;
12827         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12828         FREE((void*)_res);
12829         CResult_PongDecodeErrorZ_free(_res_conv);
12830 }
12831
12832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12833         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12834         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12835         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12836         return (uint64_t)ret_conv;
12837 }
12838
12839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12840         LDKUnsignedChannelAnnouncement o_conv;
12841         o_conv.inner = (void*)(o & (~1));
12842         o_conv.is_owned = (o & 1) || (o == 0);
12843         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12844         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12845         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12846         return (uint64_t)ret_conv;
12847 }
12848
12849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12850         LDKDecodeError e_conv;
12851         e_conv.inner = (void*)(e & (~1));
12852         e_conv.is_owned = (e & 1) || (e == 0);
12853         e_conv = DecodeError_clone(&e_conv);
12854         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12855         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12856         return (uint64_t)ret_conv;
12857 }
12858
12859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12860         if ((_res & 1) != 0) return;
12861         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12862         FREE((void*)_res);
12863         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12864 }
12865
12866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12867         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12868         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12869         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12870         return (uint64_t)ret_conv;
12871 }
12872
12873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12874         LDKChannelAnnouncement o_conv;
12875         o_conv.inner = (void*)(o & (~1));
12876         o_conv.is_owned = (o & 1) || (o == 0);
12877         o_conv = ChannelAnnouncement_clone(&o_conv);
12878         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12879         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12880         return (uint64_t)ret_conv;
12881 }
12882
12883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12884         LDKDecodeError e_conv;
12885         e_conv.inner = (void*)(e & (~1));
12886         e_conv.is_owned = (e & 1) || (e == 0);
12887         e_conv = DecodeError_clone(&e_conv);
12888         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12889         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12890         return (uint64_t)ret_conv;
12891 }
12892
12893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12894         if ((_res & 1) != 0) return;
12895         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12896         FREE((void*)_res);
12897         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12898 }
12899
12900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12901         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12902         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12903         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12904         return (uint64_t)ret_conv;
12905 }
12906
12907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12908         LDKUnsignedChannelUpdate o_conv;
12909         o_conv.inner = (void*)(o & (~1));
12910         o_conv.is_owned = (o & 1) || (o == 0);
12911         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12912         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12913         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12914         return (uint64_t)ret_conv;
12915 }
12916
12917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12918         LDKDecodeError e_conv;
12919         e_conv.inner = (void*)(e & (~1));
12920         e_conv.is_owned = (e & 1) || (e == 0);
12921         e_conv = DecodeError_clone(&e_conv);
12922         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12923         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12924         return (uint64_t)ret_conv;
12925 }
12926
12927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12928         if ((_res & 1) != 0) return;
12929         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12930         FREE((void*)_res);
12931         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12932 }
12933
12934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12935         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12936         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12937         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12938         return (uint64_t)ret_conv;
12939 }
12940
12941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12942         LDKChannelUpdate o_conv;
12943         o_conv.inner = (void*)(o & (~1));
12944         o_conv.is_owned = (o & 1) || (o == 0);
12945         o_conv = ChannelUpdate_clone(&o_conv);
12946         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12947         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12948         return (uint64_t)ret_conv;
12949 }
12950
12951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12952         LDKDecodeError e_conv;
12953         e_conv.inner = (void*)(e & (~1));
12954         e_conv.is_owned = (e & 1) || (e == 0);
12955         e_conv = DecodeError_clone(&e_conv);
12956         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12957         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12958         return (uint64_t)ret_conv;
12959 }
12960
12961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12962         if ((_res & 1) != 0) return;
12963         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12964         FREE((void*)_res);
12965         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12966 }
12967
12968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12969         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12970         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12971         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12972         return (uint64_t)ret_conv;
12973 }
12974
12975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12976         LDKErrorMessage o_conv;
12977         o_conv.inner = (void*)(o & (~1));
12978         o_conv.is_owned = (o & 1) || (o == 0);
12979         o_conv = ErrorMessage_clone(&o_conv);
12980         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12981         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12982         return (uint64_t)ret_conv;
12983 }
12984
12985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12986         LDKDecodeError e_conv;
12987         e_conv.inner = (void*)(e & (~1));
12988         e_conv.is_owned = (e & 1) || (e == 0);
12989         e_conv = DecodeError_clone(&e_conv);
12990         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12991         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12992         return (uint64_t)ret_conv;
12993 }
12994
12995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12996         if ((_res & 1) != 0) return;
12997         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12998         FREE((void*)_res);
12999         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
13000 }
13001
13002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13003         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13004         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13005         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13006         return (uint64_t)ret_conv;
13007 }
13008
13009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13010         LDKUnsignedNodeAnnouncement o_conv;
13011         o_conv.inner = (void*)(o & (~1));
13012         o_conv.is_owned = (o & 1) || (o == 0);
13013         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13014         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13015         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13016         return (uint64_t)ret_conv;
13017 }
13018
13019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13020         LDKDecodeError e_conv;
13021         e_conv.inner = (void*)(e & (~1));
13022         e_conv.is_owned = (e & 1) || (e == 0);
13023         e_conv = DecodeError_clone(&e_conv);
13024         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13025         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13026         return (uint64_t)ret_conv;
13027 }
13028
13029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13030         if ((_res & 1) != 0) return;
13031         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13032         FREE((void*)_res);
13033         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13034 }
13035
13036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13037         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13038         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13039         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13040         return (uint64_t)ret_conv;
13041 }
13042
13043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13044         LDKNodeAnnouncement o_conv;
13045         o_conv.inner = (void*)(o & (~1));
13046         o_conv.is_owned = (o & 1) || (o == 0);
13047         o_conv = NodeAnnouncement_clone(&o_conv);
13048         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13049         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13050         return (uint64_t)ret_conv;
13051 }
13052
13053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13054         LDKDecodeError e_conv;
13055         e_conv.inner = (void*)(e & (~1));
13056         e_conv.is_owned = (e & 1) || (e == 0);
13057         e_conv = DecodeError_clone(&e_conv);
13058         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13059         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13060         return (uint64_t)ret_conv;
13061 }
13062
13063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13064         if ((_res & 1) != 0) return;
13065         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13066         FREE((void*)_res);
13067         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13068 }
13069
13070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13071         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13072         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13073         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13074         return (uint64_t)ret_conv;
13075 }
13076
13077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13078         LDKQueryShortChannelIds o_conv;
13079         o_conv.inner = (void*)(o & (~1));
13080         o_conv.is_owned = (o & 1) || (o == 0);
13081         o_conv = QueryShortChannelIds_clone(&o_conv);
13082         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13083         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13084         return (uint64_t)ret_conv;
13085 }
13086
13087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13088         LDKDecodeError e_conv;
13089         e_conv.inner = (void*)(e & (~1));
13090         e_conv.is_owned = (e & 1) || (e == 0);
13091         e_conv = DecodeError_clone(&e_conv);
13092         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13093         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13094         return (uint64_t)ret_conv;
13095 }
13096
13097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13098         if ((_res & 1) != 0) return;
13099         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13100         FREE((void*)_res);
13101         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13102 }
13103
13104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13105         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13106         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13107         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13108         return (uint64_t)ret_conv;
13109 }
13110
13111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13112         LDKReplyShortChannelIdsEnd o_conv;
13113         o_conv.inner = (void*)(o & (~1));
13114         o_conv.is_owned = (o & 1) || (o == 0);
13115         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13116         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13117         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13118         return (uint64_t)ret_conv;
13119 }
13120
13121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13122         LDKDecodeError e_conv;
13123         e_conv.inner = (void*)(e & (~1));
13124         e_conv.is_owned = (e & 1) || (e == 0);
13125         e_conv = DecodeError_clone(&e_conv);
13126         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13127         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13128         return (uint64_t)ret_conv;
13129 }
13130
13131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13132         if ((_res & 1) != 0) return;
13133         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13134         FREE((void*)_res);
13135         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13136 }
13137
13138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13139         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13140         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13141         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13142         return (uint64_t)ret_conv;
13143 }
13144
13145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13146         LDKQueryChannelRange o_conv;
13147         o_conv.inner = (void*)(o & (~1));
13148         o_conv.is_owned = (o & 1) || (o == 0);
13149         o_conv = QueryChannelRange_clone(&o_conv);
13150         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13151         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13152         return (uint64_t)ret_conv;
13153 }
13154
13155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13156         LDKDecodeError e_conv;
13157         e_conv.inner = (void*)(e & (~1));
13158         e_conv.is_owned = (e & 1) || (e == 0);
13159         e_conv = DecodeError_clone(&e_conv);
13160         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13161         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13162         return (uint64_t)ret_conv;
13163 }
13164
13165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13166         if ((_res & 1) != 0) return;
13167         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13168         FREE((void*)_res);
13169         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13170 }
13171
13172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13173         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13174         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13175         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13176         return (uint64_t)ret_conv;
13177 }
13178
13179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13180         LDKReplyChannelRange o_conv;
13181         o_conv.inner = (void*)(o & (~1));
13182         o_conv.is_owned = (o & 1) || (o == 0);
13183         o_conv = ReplyChannelRange_clone(&o_conv);
13184         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13185         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13186         return (uint64_t)ret_conv;
13187 }
13188
13189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13190         LDKDecodeError e_conv;
13191         e_conv.inner = (void*)(e & (~1));
13192         e_conv.is_owned = (e & 1) || (e == 0);
13193         e_conv = DecodeError_clone(&e_conv);
13194         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13195         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13196         return (uint64_t)ret_conv;
13197 }
13198
13199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13200         if ((_res & 1) != 0) return;
13201         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13202         FREE((void*)_res);
13203         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13204 }
13205
13206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13207         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13208         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13209         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13210         return (uint64_t)ret_conv;
13211 }
13212
13213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13214         LDKGossipTimestampFilter o_conv;
13215         o_conv.inner = (void*)(o & (~1));
13216         o_conv.is_owned = (o & 1) || (o == 0);
13217         o_conv = GossipTimestampFilter_clone(&o_conv);
13218         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13219         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13220         return (uint64_t)ret_conv;
13221 }
13222
13223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13224         LDKDecodeError e_conv;
13225         e_conv.inner = (void*)(e & (~1));
13226         e_conv.is_owned = (e & 1) || (e == 0);
13227         e_conv = DecodeError_clone(&e_conv);
13228         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13229         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13230         return (uint64_t)ret_conv;
13231 }
13232
13233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13234         if ((_res & 1) != 0) return;
13235         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13236         FREE((void*)_res);
13237         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13238 }
13239
13240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13241         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13242         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13243         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13244         return (uint64_t)ret_conv;
13245 }
13246
13247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13248         LDKInvoice o_conv;
13249         o_conv.inner = (void*)(o & (~1));
13250         o_conv.is_owned = (o & 1) || (o == 0);
13251         o_conv = Invoice_clone(&o_conv);
13252         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13253         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13254         return (uint64_t)ret_conv;
13255 }
13256
13257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13258         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13259         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13260         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13261         return (uint64_t)ret_conv;
13262 }
13263
13264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13265         if ((_res & 1) != 0) return;
13266         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13267         FREE((void*)_res);
13268         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13269 }
13270
13271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13272         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13273         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13274         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13275         return (uint64_t)ret_conv;
13276 }
13277
13278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13279         if ((this_ptr & 1) != 0) return;
13280         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13281         FREE((void*)this_ptr);
13282         Event_free(this_ptr_conv);
13283 }
13284
13285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13286         LDKEvent* orig_conv = (LDKEvent*)orig;
13287         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13288         *ret_copy = Event_clone(orig_conv);
13289         uint64_t ret_ref = (uint64_t)ret_copy;
13290         return ret_ref;
13291 }
13292
13293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
13294         LDKThirtyTwoBytes temporary_channel_id_ref;
13295         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
13296         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
13297         LDKCVec_u8Z output_script_ref;
13298         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
13299         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
13300         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
13301         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13302         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
13303         uint64_t ret_ref = (uint64_t)ret_copy;
13304         return ret_ref;
13305 }
13306
13307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t amt, int64_t user_payment_id) {
13308         LDKThirtyTwoBytes payment_hash_ref;
13309         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13310         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13311         LDKThirtyTwoBytes payment_preimage_ref;
13312         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13313         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13314         LDKThirtyTwoBytes payment_secret_ref;
13315         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13316         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13317         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13318         *ret_copy = Event_payment_received(payment_hash_ref, payment_preimage_ref, payment_secret_ref, amt, user_payment_id);
13319         uint64_t ret_ref = (uint64_t)ret_copy;
13320         return ret_ref;
13321 }
13322
13323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage) {
13324         LDKThirtyTwoBytes payment_preimage_ref;
13325         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13326         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13327         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13328         *ret_copy = Event_payment_sent(payment_preimage_ref);
13329         uint64_t ret_ref = (uint64_t)ret_copy;
13330         return ret_ref;
13331 }
13332
13333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest) {
13334         LDKThirtyTwoBytes payment_hash_ref;
13335         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13336         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13337         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13338         *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest);
13339         uint64_t ret_ref = (uint64_t)ret_copy;
13340         return ret_ref;
13341 }
13342
13343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
13344         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13345         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
13346         uint64_t ret_ref = (uint64_t)ret_copy;
13347         return ret_ref;
13348 }
13349
13350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
13351         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
13352         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
13353         if (outputs_constr.datalen > 0)
13354                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13355         else
13356                 outputs_constr.data = NULL;
13357         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
13358         for (size_t b = 0; b < outputs_constr.datalen; b++) {
13359                 int64_t outputs_conv_27 = outputs_vals[b];
13360                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
13361                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
13362                 outputs_constr.data[b] = outputs_conv_27_conv;
13363         }
13364         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
13365         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13366         *ret_copy = Event_spendable_outputs(outputs_constr);
13367         uint64_t ret_ref = (uint64_t)ret_copy;
13368         return ret_ref;
13369 }
13370
13371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13372         LDKEvent* obj_conv = (LDKEvent*)obj;
13373         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13374         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13375         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13376         CVec_u8Z_free(ret_var);
13377         return ret_arr;
13378 }
13379
13380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13381         if ((this_ptr & 1) != 0) return;
13382         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13383         FREE((void*)this_ptr);
13384         MessageSendEvent_free(this_ptr_conv);
13385 }
13386
13387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13388         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13389         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13390         *ret_copy = MessageSendEvent_clone(orig_conv);
13391         uint64_t ret_ref = (uint64_t)ret_copy;
13392         return ret_ref;
13393 }
13394
13395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13396         LDKPublicKey node_id_ref;
13397         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13398         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13399         LDKAcceptChannel msg_conv;
13400         msg_conv.inner = (void*)(msg & (~1));
13401         msg_conv.is_owned = (msg & 1) || (msg == 0);
13402         msg_conv = AcceptChannel_clone(&msg_conv);
13403         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13404         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
13405         uint64_t ret_ref = (uint64_t)ret_copy;
13406         return ret_ref;
13407 }
13408
13409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13410         LDKPublicKey node_id_ref;
13411         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13412         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13413         LDKOpenChannel msg_conv;
13414         msg_conv.inner = (void*)(msg & (~1));
13415         msg_conv.is_owned = (msg & 1) || (msg == 0);
13416         msg_conv = OpenChannel_clone(&msg_conv);
13417         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13418         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
13419         uint64_t ret_ref = (uint64_t)ret_copy;
13420         return ret_ref;
13421 }
13422
13423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13424         LDKPublicKey node_id_ref;
13425         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13426         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13427         LDKFundingCreated msg_conv;
13428         msg_conv.inner = (void*)(msg & (~1));
13429         msg_conv.is_owned = (msg & 1) || (msg == 0);
13430         msg_conv = FundingCreated_clone(&msg_conv);
13431         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13432         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
13433         uint64_t ret_ref = (uint64_t)ret_copy;
13434         return ret_ref;
13435 }
13436
13437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13438         LDKPublicKey node_id_ref;
13439         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13440         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13441         LDKFundingSigned msg_conv;
13442         msg_conv.inner = (void*)(msg & (~1));
13443         msg_conv.is_owned = (msg & 1) || (msg == 0);
13444         msg_conv = FundingSigned_clone(&msg_conv);
13445         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13446         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
13447         uint64_t ret_ref = (uint64_t)ret_copy;
13448         return ret_ref;
13449 }
13450
13451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13452         LDKPublicKey node_id_ref;
13453         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13454         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13455         LDKFundingLocked msg_conv;
13456         msg_conv.inner = (void*)(msg & (~1));
13457         msg_conv.is_owned = (msg & 1) || (msg == 0);
13458         msg_conv = FundingLocked_clone(&msg_conv);
13459         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13460         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
13461         uint64_t ret_ref = (uint64_t)ret_copy;
13462         return ret_ref;
13463 }
13464
13465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13466         LDKPublicKey node_id_ref;
13467         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13468         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13469         LDKAnnouncementSignatures msg_conv;
13470         msg_conv.inner = (void*)(msg & (~1));
13471         msg_conv.is_owned = (msg & 1) || (msg == 0);
13472         msg_conv = AnnouncementSignatures_clone(&msg_conv);
13473         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13474         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
13475         uint64_t ret_ref = (uint64_t)ret_copy;
13476         return ret_ref;
13477 }
13478
13479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
13480         LDKPublicKey node_id_ref;
13481         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13482         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13483         LDKCommitmentUpdate updates_conv;
13484         updates_conv.inner = (void*)(updates & (~1));
13485         updates_conv.is_owned = (updates & 1) || (updates == 0);
13486         updates_conv = CommitmentUpdate_clone(&updates_conv);
13487         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13488         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
13489         uint64_t ret_ref = (uint64_t)ret_copy;
13490         return ret_ref;
13491 }
13492
13493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1revoke_1and_1ack(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13494         LDKPublicKey node_id_ref;
13495         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13496         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13497         LDKRevokeAndACK msg_conv;
13498         msg_conv.inner = (void*)(msg & (~1));
13499         msg_conv.is_owned = (msg & 1) || (msg == 0);
13500         msg_conv = RevokeAndACK_clone(&msg_conv);
13501         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13502         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
13503         uint64_t ret_ref = (uint64_t)ret_copy;
13504         return ret_ref;
13505 }
13506
13507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13508         LDKPublicKey node_id_ref;
13509         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13510         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13511         LDKClosingSigned msg_conv;
13512         msg_conv.inner = (void*)(msg & (~1));
13513         msg_conv.is_owned = (msg & 1) || (msg == 0);
13514         msg_conv = ClosingSigned_clone(&msg_conv);
13515         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13516         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
13517         uint64_t ret_ref = (uint64_t)ret_copy;
13518         return ret_ref;
13519 }
13520
13521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13522         LDKPublicKey node_id_ref;
13523         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13524         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13525         LDKShutdown msg_conv;
13526         msg_conv.inner = (void*)(msg & (~1));
13527         msg_conv.is_owned = (msg & 1) || (msg == 0);
13528         msg_conv = Shutdown_clone(&msg_conv);
13529         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13530         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
13531         uint64_t ret_ref = (uint64_t)ret_copy;
13532         return ret_ref;
13533 }
13534
13535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13536         LDKPublicKey node_id_ref;
13537         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13538         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13539         LDKChannelReestablish msg_conv;
13540         msg_conv.inner = (void*)(msg & (~1));
13541         msg_conv.is_owned = (msg & 1) || (msg == 0);
13542         msg_conv = ChannelReestablish_clone(&msg_conv);
13543         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13544         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
13545         uint64_t ret_ref = (uint64_t)ret_copy;
13546         return ret_ref;
13547 }
13548
13549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
13550         LDKChannelAnnouncement msg_conv;
13551         msg_conv.inner = (void*)(msg & (~1));
13552         msg_conv.is_owned = (msg & 1) || (msg == 0);
13553         msg_conv = ChannelAnnouncement_clone(&msg_conv);
13554         LDKChannelUpdate update_msg_conv;
13555         update_msg_conv.inner = (void*)(update_msg & (~1));
13556         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
13557         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
13558         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13559         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
13560         uint64_t ret_ref = (uint64_t)ret_copy;
13561         return ret_ref;
13562 }
13563
13564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
13565         LDKNodeAnnouncement msg_conv;
13566         msg_conv.inner = (void*)(msg & (~1));
13567         msg_conv.is_owned = (msg & 1) || (msg == 0);
13568         msg_conv = NodeAnnouncement_clone(&msg_conv);
13569         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13570         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
13571         uint64_t ret_ref = (uint64_t)ret_copy;
13572         return ret_ref;
13573 }
13574
13575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
13576         LDKChannelUpdate msg_conv;
13577         msg_conv.inner = (void*)(msg & (~1));
13578         msg_conv.is_owned = (msg & 1) || (msg == 0);
13579         msg_conv = ChannelUpdate_clone(&msg_conv);
13580         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13581         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
13582         uint64_t ret_ref = (uint64_t)ret_copy;
13583         return ret_ref;
13584 }
13585
13586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13587         LDKPublicKey node_id_ref;
13588         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13589         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13590         LDKChannelUpdate msg_conv;
13591         msg_conv.inner = (void*)(msg & (~1));
13592         msg_conv.is_owned = (msg & 1) || (msg == 0);
13593         msg_conv = ChannelUpdate_clone(&msg_conv);
13594         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13595         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
13596         uint64_t ret_ref = (uint64_t)ret_copy;
13597         return ret_ref;
13598 }
13599
13600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
13601         LDKPublicKey node_id_ref;
13602         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13603         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13604         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
13605         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13606         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
13607         uint64_t ret_ref = (uint64_t)ret_copy;
13608         return ret_ref;
13609 }
13610
13611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1payment_1failure_1network_1update(JNIEnv *env, jclass clz, int64_t update) {
13612         LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1);
13613         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13614         *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv);
13615         uint64_t ret_ref = (uint64_t)ret_copy;
13616         return ret_ref;
13617 }
13618
13619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13620         LDKPublicKey node_id_ref;
13621         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13622         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13623         LDKQueryChannelRange msg_conv;
13624         msg_conv.inner = (void*)(msg & (~1));
13625         msg_conv.is_owned = (msg & 1) || (msg == 0);
13626         msg_conv = QueryChannelRange_clone(&msg_conv);
13627         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13628         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
13629         uint64_t ret_ref = (uint64_t)ret_copy;
13630         return ret_ref;
13631 }
13632
13633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1short_1ids_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13634         LDKPublicKey node_id_ref;
13635         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13636         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13637         LDKQueryShortChannelIds msg_conv;
13638         msg_conv.inner = (void*)(msg & (~1));
13639         msg_conv.is_owned = (msg & 1) || (msg == 0);
13640         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13641         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13642         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
13643         uint64_t ret_ref = (uint64_t)ret_copy;
13644         return ret_ref;
13645 }
13646
13647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1reply_1channel_1range(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13648         LDKPublicKey node_id_ref;
13649         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13650         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13651         LDKReplyChannelRange msg_conv;
13652         msg_conv.inner = (void*)(msg & (~1));
13653         msg_conv.is_owned = (msg & 1) || (msg == 0);
13654         msg_conv = ReplyChannelRange_clone(&msg_conv);
13655         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13656         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
13657         uint64_t ret_ref = (uint64_t)ret_copy;
13658         return ret_ref;
13659 }
13660
13661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13662         if ((this_ptr & 1) != 0) return;
13663         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13664         FREE((void*)this_ptr);
13665         MessageSendEventsProvider_free(this_ptr_conv);
13666 }
13667
13668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13669         if ((this_ptr & 1) != 0) return;
13670         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13671         FREE((void*)this_ptr);
13672         EventsProvider_free(this_ptr_conv);
13673 }
13674
13675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13676         if ((this_ptr & 1) != 0) return;
13677         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13678         FREE((void*)this_ptr);
13679         EventHandler_free(this_ptr_conv);
13680 }
13681
13682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13683         if ((this_ptr & 1) != 0) return;
13684         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13685         FREE((void*)this_ptr);
13686         APIError_free(this_ptr_conv);
13687 }
13688
13689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13690         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13691         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13692         *ret_copy = APIError_clone(orig_conv);
13693         uint64_t ret_ref = (uint64_t)ret_copy;
13694         return ret_ref;
13695 }
13696
13697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
13698         LDKStr err_conv = java_to_owned_str(env, err);
13699         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13700         *ret_copy = APIError_apimisuse_error(err_conv);
13701         uint64_t ret_ref = (uint64_t)ret_copy;
13702         return ret_ref;
13703 }
13704
13705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
13706         LDKStr err_conv = java_to_owned_str(env, err);
13707         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13708         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
13709         uint64_t ret_ref = (uint64_t)ret_copy;
13710         return ret_ref;
13711 }
13712
13713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
13714         LDKStr err_conv = java_to_owned_str(env, err);
13715         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13716         *ret_copy = APIError_route_error(err_conv);
13717         uint64_t ret_ref = (uint64_t)ret_copy;
13718         return ret_ref;
13719 }
13720
13721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
13722         LDKStr err_conv = java_to_owned_str(env, err);
13723         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13724         *ret_copy = APIError_channel_unavailable(err_conv);
13725         uint64_t ret_ref = (uint64_t)ret_copy;
13726         return ret_ref;
13727 }
13728
13729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
13730         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13731         *ret_copy = APIError_monitor_update_failed();
13732         uint64_t ret_ref = (uint64_t)ret_copy;
13733         return ret_ref;
13734 }
13735
13736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
13737         LDKu8slice msg_ref;
13738         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13739         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13740         unsigned char sk_arr[32];
13741         CHECK((*env)->GetArrayLength(env, sk) == 32);
13742         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
13743         unsigned char (*sk_ref)[32] = &sk_arr;
13744         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13745         *ret_conv = sign(msg_ref, sk_ref);
13746         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13747         return (uint64_t)ret_conv;
13748 }
13749
13750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
13751         LDKu8slice msg_ref;
13752         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13753         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13754         LDKStr sig_conv = java_to_owned_str(env, sig);
13755         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13756         *ret_conv = recover_pk(msg_ref, sig_conv);
13757         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13758         return (uint64_t)ret_conv;
13759 }
13760
13761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
13762         LDKu8slice msg_ref;
13763         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13764         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13765         LDKStr sig_conv = java_to_owned_str(env, sig);
13766         LDKPublicKey pk_ref;
13767         CHECK((*env)->GetArrayLength(env, pk) == 33);
13768         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
13769         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13770         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13771         return ret_val;
13772 }
13773
13774 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13775         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13776         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
13777         return ret_conv;
13778 }
13779
13780 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
13781         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
13782         return ret_conv;
13783 }
13784
13785 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
13786         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
13787         return ret_conv;
13788 }
13789
13790 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
13791         jclass ret_conv = LDKLevel_to_java(env, Level_info());
13792         return ret_conv;
13793 }
13794
13795 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
13796         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
13797         return ret_conv;
13798 }
13799
13800 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
13801         jclass ret_conv = LDKLevel_to_java(env, Level_error());
13802         return ret_conv;
13803 }
13804
13805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
13806         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13807         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13808         jboolean ret_val = Level_eq(a_conv, b_conv);
13809         return ret_val;
13810 }
13811
13812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13813         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13814         int64_t ret_val = Level_hash(o_conv);
13815         return ret_val;
13816 }
13817
13818 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13819         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13820         return ret_conv;
13821 }
13822
13823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13824         if ((this_ptr & 1) != 0) return;
13825         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13826         FREE((void*)this_ptr);
13827         Logger_free(this_ptr_conv);
13828 }
13829
13830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13831         LDKChannelHandshakeConfig this_obj_conv;
13832         this_obj_conv.inner = (void*)(this_obj & (~1));
13833         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13834         ChannelHandshakeConfig_free(this_obj_conv);
13835 }
13836
13837 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13838         LDKChannelHandshakeConfig this_ptr_conv;
13839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13840         this_ptr_conv.is_owned = false;
13841         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13842         return ret_val;
13843 }
13844
13845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13846         LDKChannelHandshakeConfig this_ptr_conv;
13847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13848         this_ptr_conv.is_owned = false;
13849         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13850 }
13851
13852 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13853         LDKChannelHandshakeConfig this_ptr_conv;
13854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13855         this_ptr_conv.is_owned = false;
13856         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13857         return ret_val;
13858 }
13859
13860 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) {
13861         LDKChannelHandshakeConfig this_ptr_conv;
13862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13863         this_ptr_conv.is_owned = false;
13864         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13865 }
13866
13867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13868         LDKChannelHandshakeConfig this_ptr_conv;
13869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13870         this_ptr_conv.is_owned = false;
13871         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13872         return ret_val;
13873 }
13874
13875 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) {
13876         LDKChannelHandshakeConfig this_ptr_conv;
13877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13878         this_ptr_conv.is_owned = false;
13879         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13880 }
13881
13882 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) {
13883         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13886         uint64_t ret_ref = (uint64_t)ret_var.inner;
13887         if (ret_var.is_owned) {
13888                 ret_ref |= 1;
13889         }
13890         return ret_ref;
13891 }
13892
13893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13894         LDKChannelHandshakeConfig orig_conv;
13895         orig_conv.inner = (void*)(orig & (~1));
13896         orig_conv.is_owned = false;
13897         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13898         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13899         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13900         uint64_t ret_ref = (uint64_t)ret_var.inner;
13901         if (ret_var.is_owned) {
13902                 ret_ref |= 1;
13903         }
13904         return ret_ref;
13905 }
13906
13907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13908         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13909         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13910         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13911         uint64_t ret_ref = (uint64_t)ret_var.inner;
13912         if (ret_var.is_owned) {
13913                 ret_ref |= 1;
13914         }
13915         return ret_ref;
13916 }
13917
13918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13919         LDKChannelHandshakeLimits this_obj_conv;
13920         this_obj_conv.inner = (void*)(this_obj & (~1));
13921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13922         ChannelHandshakeLimits_free(this_obj_conv);
13923 }
13924
13925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13926         LDKChannelHandshakeLimits this_ptr_conv;
13927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13928         this_ptr_conv.is_owned = false;
13929         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13930         return ret_val;
13931 }
13932
13933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13934         LDKChannelHandshakeLimits this_ptr_conv;
13935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13936         this_ptr_conv.is_owned = false;
13937         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13938 }
13939
13940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13941         LDKChannelHandshakeLimits this_ptr_conv;
13942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13943         this_ptr_conv.is_owned = false;
13944         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13945         return ret_val;
13946 }
13947
13948 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) {
13949         LDKChannelHandshakeLimits this_ptr_conv;
13950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13951         this_ptr_conv.is_owned = false;
13952         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13953 }
13954
13955 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) {
13956         LDKChannelHandshakeLimits this_ptr_conv;
13957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13958         this_ptr_conv.is_owned = false;
13959         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13960         return ret_val;
13961 }
13962
13963 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) {
13964         LDKChannelHandshakeLimits this_ptr_conv;
13965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13966         this_ptr_conv.is_owned = false;
13967         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13968 }
13969
13970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13971         LDKChannelHandshakeLimits this_ptr_conv;
13972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13973         this_ptr_conv.is_owned = false;
13974         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13975         return ret_val;
13976 }
13977
13978 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) {
13979         LDKChannelHandshakeLimits this_ptr_conv;
13980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13981         this_ptr_conv.is_owned = false;
13982         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13983 }
13984
13985 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13986         LDKChannelHandshakeLimits this_ptr_conv;
13987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13988         this_ptr_conv.is_owned = false;
13989         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13990         return ret_val;
13991 }
13992
13993 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) {
13994         LDKChannelHandshakeLimits this_ptr_conv;
13995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13996         this_ptr_conv.is_owned = false;
13997         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13998 }
13999
14000 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14001         LDKChannelHandshakeLimits this_ptr_conv;
14002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14003         this_ptr_conv.is_owned = false;
14004         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
14005         return ret_val;
14006 }
14007
14008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14009         LDKChannelHandshakeLimits this_ptr_conv;
14010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14011         this_ptr_conv.is_owned = false;
14012         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
14013 }
14014
14015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
14016         LDKChannelHandshakeLimits this_ptr_conv;
14017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14018         this_ptr_conv.is_owned = false;
14019         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
14020         return ret_val;
14021 }
14022
14023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14024         LDKChannelHandshakeLimits this_ptr_conv;
14025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14026         this_ptr_conv.is_owned = false;
14027         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
14028 }
14029
14030 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14031         LDKChannelHandshakeLimits this_ptr_conv;
14032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14033         this_ptr_conv.is_owned = false;
14034         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
14035         return ret_val;
14036 }
14037
14038 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) {
14039         LDKChannelHandshakeLimits this_ptr_conv;
14040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14041         this_ptr_conv.is_owned = false;
14042         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
14043 }
14044
14045 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) {
14046         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);
14047         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14048         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14049         uint64_t ret_ref = (uint64_t)ret_var.inner;
14050         if (ret_var.is_owned) {
14051                 ret_ref |= 1;
14052         }
14053         return ret_ref;
14054 }
14055
14056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14057         LDKChannelHandshakeLimits orig_conv;
14058         orig_conv.inner = (void*)(orig & (~1));
14059         orig_conv.is_owned = false;
14060         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
14061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14063         uint64_t ret_ref = (uint64_t)ret_var.inner;
14064         if (ret_var.is_owned) {
14065                 ret_ref |= 1;
14066         }
14067         return ret_ref;
14068 }
14069
14070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
14071         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
14072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14074         uint64_t ret_ref = (uint64_t)ret_var.inner;
14075         if (ret_var.is_owned) {
14076                 ret_ref |= 1;
14077         }
14078         return ret_ref;
14079 }
14080
14081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14082         LDKChannelConfig this_obj_conv;
14083         this_obj_conv.inner = (void*)(this_obj & (~1));
14084         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14085         ChannelConfig_free(this_obj_conv);
14086 }
14087
14088 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
14089         LDKChannelConfig this_ptr_conv;
14090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14091         this_ptr_conv.is_owned = false;
14092         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
14093         return ret_val;
14094 }
14095
14096 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) {
14097         LDKChannelConfig this_ptr_conv;
14098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14099         this_ptr_conv.is_owned = false;
14100         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
14101 }
14102
14103 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14104         LDKChannelConfig this_ptr_conv;
14105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14106         this_ptr_conv.is_owned = false;
14107         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
14108         return ret_val;
14109 }
14110
14111 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) {
14112         LDKChannelConfig this_ptr_conv;
14113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14114         this_ptr_conv.is_owned = false;
14115         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
14116 }
14117
14118 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
14119         LDKChannelConfig this_ptr_conv;
14120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14121         this_ptr_conv.is_owned = false;
14122         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
14123         return ret_val;
14124 }
14125
14126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14127         LDKChannelConfig this_ptr_conv;
14128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14129         this_ptr_conv.is_owned = false;
14130         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
14131 }
14132
14133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
14134         LDKChannelConfig this_ptr_conv;
14135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14136         this_ptr_conv.is_owned = false;
14137         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
14138         return ret_val;
14139 }
14140
14141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14142         LDKChannelConfig this_ptr_conv;
14143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14144         this_ptr_conv.is_owned = false;
14145         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
14146 }
14147
14148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14149         LDKChannelConfig this_ptr_conv;
14150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14151         this_ptr_conv.is_owned = false;
14152         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
14153         return ret_val;
14154 }
14155
14156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14157         LDKChannelConfig this_ptr_conv;
14158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14159         this_ptr_conv.is_owned = false;
14160         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
14161 }
14162
14163 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) {
14164         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);
14165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14167         uint64_t ret_ref = (uint64_t)ret_var.inner;
14168         if (ret_var.is_owned) {
14169                 ret_ref |= 1;
14170         }
14171         return ret_ref;
14172 }
14173
14174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14175         LDKChannelConfig orig_conv;
14176         orig_conv.inner = (void*)(orig & (~1));
14177         orig_conv.is_owned = false;
14178         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
14179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14181         uint64_t ret_ref = (uint64_t)ret_var.inner;
14182         if (ret_var.is_owned) {
14183                 ret_ref |= 1;
14184         }
14185         return ret_ref;
14186 }
14187
14188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
14189         LDKChannelConfig ret_var = ChannelConfig_default();
14190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14192         uint64_t ret_ref = (uint64_t)ret_var.inner;
14193         if (ret_var.is_owned) {
14194                 ret_ref |= 1;
14195         }
14196         return ret_ref;
14197 }
14198
14199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
14200         LDKChannelConfig obj_conv;
14201         obj_conv.inner = (void*)(obj & (~1));
14202         obj_conv.is_owned = false;
14203         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
14204         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14205         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14206         CVec_u8Z_free(ret_var);
14207         return ret_arr;
14208 }
14209
14210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14211         LDKu8slice ser_ref;
14212         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14213         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14214         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14215         *ret_conv = ChannelConfig_read(ser_ref);
14216         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14217         return (uint64_t)ret_conv;
14218 }
14219
14220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14221         LDKUserConfig this_obj_conv;
14222         this_obj_conv.inner = (void*)(this_obj & (~1));
14223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14224         UserConfig_free(this_obj_conv);
14225 }
14226
14227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
14228         LDKUserConfig this_ptr_conv;
14229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14230         this_ptr_conv.is_owned = false;
14231         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
14232         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14233         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14234         uint64_t ret_ref = (uint64_t)ret_var.inner;
14235         if (ret_var.is_owned) {
14236                 ret_ref |= 1;
14237         }
14238         return ret_ref;
14239 }
14240
14241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14242         LDKUserConfig this_ptr_conv;
14243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14244         this_ptr_conv.is_owned = false;
14245         LDKChannelHandshakeConfig val_conv;
14246         val_conv.inner = (void*)(val & (~1));
14247         val_conv.is_owned = (val & 1) || (val == 0);
14248         val_conv = ChannelHandshakeConfig_clone(&val_conv);
14249         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
14250 }
14251
14252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
14253         LDKUserConfig this_ptr_conv;
14254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14255         this_ptr_conv.is_owned = false;
14256         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
14257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14259         uint64_t ret_ref = (uint64_t)ret_var.inner;
14260         if (ret_var.is_owned) {
14261                 ret_ref |= 1;
14262         }
14263         return ret_ref;
14264 }
14265
14266 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) {
14267         LDKUserConfig this_ptr_conv;
14268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14269         this_ptr_conv.is_owned = false;
14270         LDKChannelHandshakeLimits val_conv;
14271         val_conv.inner = (void*)(val & (~1));
14272         val_conv.is_owned = (val & 1) || (val == 0);
14273         val_conv = ChannelHandshakeLimits_clone(&val_conv);
14274         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
14275 }
14276
14277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
14278         LDKUserConfig this_ptr_conv;
14279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14280         this_ptr_conv.is_owned = false;
14281         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
14282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14284         uint64_t ret_ref = (uint64_t)ret_var.inner;
14285         if (ret_var.is_owned) {
14286                 ret_ref |= 1;
14287         }
14288         return ret_ref;
14289 }
14290
14291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14292         LDKUserConfig this_ptr_conv;
14293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14294         this_ptr_conv.is_owned = false;
14295         LDKChannelConfig val_conv;
14296         val_conv.inner = (void*)(val & (~1));
14297         val_conv.is_owned = (val & 1) || (val == 0);
14298         val_conv = ChannelConfig_clone(&val_conv);
14299         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
14300 }
14301
14302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
14303         LDKUserConfig this_ptr_conv;
14304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14305         this_ptr_conv.is_owned = false;
14306         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
14307         return ret_val;
14308 }
14309
14310 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) {
14311         LDKUserConfig this_ptr_conv;
14312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14313         this_ptr_conv.is_owned = false;
14314         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
14315 }
14316
14317 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) {
14318         LDKChannelHandshakeConfig own_channel_config_arg_conv;
14319         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
14320         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
14321         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
14322         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
14323         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
14324         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
14325         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
14326         LDKChannelConfig channel_options_arg_conv;
14327         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
14328         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
14329         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
14330         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);
14331         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14332         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14333         uint64_t ret_ref = (uint64_t)ret_var.inner;
14334         if (ret_var.is_owned) {
14335                 ret_ref |= 1;
14336         }
14337         return ret_ref;
14338 }
14339
14340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14341         LDKUserConfig orig_conv;
14342         orig_conv.inner = (void*)(orig & (~1));
14343         orig_conv.is_owned = false;
14344         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
14345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14347         uint64_t ret_ref = (uint64_t)ret_var.inner;
14348         if (ret_var.is_owned) {
14349                 ret_ref |= 1;
14350         }
14351         return ret_ref;
14352 }
14353
14354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
14355         LDKUserConfig ret_var = UserConfig_default();
14356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14358         uint64_t ret_ref = (uint64_t)ret_var.inner;
14359         if (ret_var.is_owned) {
14360                 ret_ref |= 1;
14361         }
14362         return ret_ref;
14363 }
14364
14365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14366         LDKBestBlock this_obj_conv;
14367         this_obj_conv.inner = (void*)(this_obj & (~1));
14368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14369         BestBlock_free(this_obj_conv);
14370 }
14371
14372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14373         LDKBestBlock orig_conv;
14374         orig_conv.inner = (void*)(orig & (~1));
14375         orig_conv.is_owned = false;
14376         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
14377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14379         uint64_t ret_ref = (uint64_t)ret_var.inner;
14380         if (ret_var.is_owned) {
14381                 ret_ref |= 1;
14382         }
14383         return ret_ref;
14384 }
14385
14386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
14387         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
14388         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
14389         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14390         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14391         uint64_t ret_ref = (uint64_t)ret_var.inner;
14392         if (ret_var.is_owned) {
14393                 ret_ref |= 1;
14394         }
14395         return ret_ref;
14396 }
14397
14398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
14399         LDKThirtyTwoBytes block_hash_ref;
14400         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
14401         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
14402         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
14403         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14404         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14405         uint64_t ret_ref = (uint64_t)ret_var.inner;
14406         if (ret_var.is_owned) {
14407                 ret_ref |= 1;
14408         }
14409         return ret_ref;
14410 }
14411
14412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14413         LDKBestBlock this_arg_conv;
14414         this_arg_conv.inner = (void*)(this_arg & (~1));
14415         this_arg_conv.is_owned = false;
14416         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
14418         return ret_arr;
14419 }
14420
14421 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
14422         LDKBestBlock this_arg_conv;
14423         this_arg_conv.inner = (void*)(this_arg & (~1));
14424         this_arg_conv.is_owned = false;
14425         int32_t ret_val = BestBlock_height(&this_arg_conv);
14426         return ret_val;
14427 }
14428
14429 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14430         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14431         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14432         return ret_conv;
14433 }
14434
14435 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
14436         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
14437         return ret_conv;
14438 }
14439
14440 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
14441         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
14442         return ret_conv;
14443 }
14444
14445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14446         if ((this_ptr & 1) != 0) return;
14447         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14448         FREE((void*)this_ptr);
14449         Access_free(this_ptr_conv);
14450 }
14451
14452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14453         if ((this_ptr & 1) != 0) return;
14454         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14455         FREE((void*)this_ptr);
14456         Listen_free(this_ptr_conv);
14457 }
14458
14459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14460         if ((this_ptr & 1) != 0) return;
14461         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14462         FREE((void*)this_ptr);
14463         Confirm_free(this_ptr_conv);
14464 }
14465
14466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14467         if ((this_ptr & 1) != 0) return;
14468         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14469         FREE((void*)this_ptr);
14470         Watch_free(this_ptr_conv);
14471 }
14472
14473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14474         if ((this_ptr & 1) != 0) return;
14475         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14476         FREE((void*)this_ptr);
14477         Filter_free(this_ptr_conv);
14478 }
14479
14480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14481         LDKWatchedOutput this_obj_conv;
14482         this_obj_conv.inner = (void*)(this_obj & (~1));
14483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14484         WatchedOutput_free(this_obj_conv);
14485 }
14486
14487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14488         LDKWatchedOutput this_ptr_conv;
14489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14490         this_ptr_conv.is_owned = false;
14491         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14493         return ret_arr;
14494 }
14495
14496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14497         LDKWatchedOutput this_ptr_conv;
14498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14499         this_ptr_conv.is_owned = false;
14500         LDKThirtyTwoBytes val_ref;
14501         CHECK((*env)->GetArrayLength(env, val) == 32);
14502         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14503         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14504 }
14505
14506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14507         LDKWatchedOutput this_ptr_conv;
14508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14509         this_ptr_conv.is_owned = false;
14510         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14513         uint64_t ret_ref = (uint64_t)ret_var.inner;
14514         if (ret_var.is_owned) {
14515                 ret_ref |= 1;
14516         }
14517         return ret_ref;
14518 }
14519
14520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14521         LDKWatchedOutput this_ptr_conv;
14522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14523         this_ptr_conv.is_owned = false;
14524         LDKOutPoint val_conv;
14525         val_conv.inner = (void*)(val & (~1));
14526         val_conv.is_owned = (val & 1) || (val == 0);
14527         val_conv = OutPoint_clone(&val_conv);
14528         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14529 }
14530
14531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14532         LDKWatchedOutput this_ptr_conv;
14533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14534         this_ptr_conv.is_owned = false;
14535         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14536         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14537         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14538         return ret_arr;
14539 }
14540
14541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14542         LDKWatchedOutput this_ptr_conv;
14543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14544         this_ptr_conv.is_owned = false;
14545         LDKCVec_u8Z val_ref;
14546         val_ref.datalen = (*env)->GetArrayLength(env, val);
14547         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14548         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14549         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14550 }
14551
14552 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) {
14553         LDKThirtyTwoBytes block_hash_arg_ref;
14554         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14555         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14556         LDKOutPoint outpoint_arg_conv;
14557         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14558         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14559         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14560         LDKCVec_u8Z script_pubkey_arg_ref;
14561         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14562         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14563         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14564         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14567         uint64_t ret_ref = (uint64_t)ret_var.inner;
14568         if (ret_var.is_owned) {
14569                 ret_ref |= 1;
14570         }
14571         return ret_ref;
14572 }
14573
14574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14575         LDKWatchedOutput orig_conv;
14576         orig_conv.inner = (void*)(orig & (~1));
14577         orig_conv.is_owned = false;
14578         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14581         uint64_t ret_ref = (uint64_t)ret_var.inner;
14582         if (ret_var.is_owned) {
14583                 ret_ref |= 1;
14584         }
14585         return ret_ref;
14586 }
14587
14588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14589         LDKWatchedOutput o_conv;
14590         o_conv.inner = (void*)(o & (~1));
14591         o_conv.is_owned = false;
14592         int64_t ret_val = WatchedOutput_hash(&o_conv);
14593         return ret_val;
14594 }
14595
14596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14597         if ((this_ptr & 1) != 0) return;
14598         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14599         FREE((void*)this_ptr);
14600         BroadcasterInterface_free(this_ptr_conv);
14601 }
14602
14603 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14604         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14605         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14606         return ret_conv;
14607 }
14608
14609 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
14610         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
14611         return ret_conv;
14612 }
14613
14614 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
14615         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
14616         return ret_conv;
14617 }
14618
14619 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
14620         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
14621         return ret_conv;
14622 }
14623
14624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14625         if ((this_ptr & 1) != 0) return;
14626         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14627         FREE((void*)this_ptr);
14628         FeeEstimator_free(this_ptr_conv);
14629 }
14630
14631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14632         LDKChainMonitor this_obj_conv;
14633         this_obj_conv.inner = (void*)(this_obj & (~1));
14634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14635         ChainMonitor_free(this_obj_conv);
14636 }
14637
14638 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) {
14639         LDKFilter *chain_source_conv_ptr = NULL;
14640         if (chain_source != 0) {
14641                 LDKFilter chain_source_conv;
14642                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14643                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14644                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14645                         LDKFilter_JCalls_cloned(&chain_source_conv);
14646                 }
14647                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
14648                 *chain_source_conv_ptr = chain_source_conv;
14649         }
14650         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14651         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14652                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14653                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14654         }
14655         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14656         if (logger_conv.free == LDKLogger_JCalls_free) {
14657                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14658                 LDKLogger_JCalls_cloned(&logger_conv);
14659         }
14660         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
14661         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
14662                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14663                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
14664         }
14665         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
14666         if (persister_conv.free == LDKPersist_JCalls_free) {
14667                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14668                 LDKPersist_JCalls_cloned(&persister_conv);
14669         }
14670         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
14671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14673         uint64_t ret_ref = (uint64_t)ret_var.inner;
14674         if (ret_var.is_owned) {
14675                 ret_ref |= 1;
14676         }
14677         return ret_ref;
14678 }
14679
14680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
14681         LDKChainMonitor this_arg_conv;
14682         this_arg_conv.inner = (void*)(this_arg & (~1));
14683         this_arg_conv.is_owned = false;
14684         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14685         *ret = ChainMonitor_as_Listen(&this_arg_conv);
14686         return (uint64_t)ret;
14687 }
14688
14689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
14690         LDKChainMonitor this_arg_conv;
14691         this_arg_conv.inner = (void*)(this_arg & (~1));
14692         this_arg_conv.is_owned = false;
14693         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14694         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
14695         return (uint64_t)ret;
14696 }
14697
14698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14699         LDKChainMonitor this_arg_conv;
14700         this_arg_conv.inner = (void*)(this_arg & (~1));
14701         this_arg_conv.is_owned = false;
14702         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
14703         *ret = ChainMonitor_as_Watch(&this_arg_conv);
14704         return (uint64_t)ret;
14705 }
14706
14707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
14708         LDKChainMonitor this_arg_conv;
14709         this_arg_conv.inner = (void*)(this_arg & (~1));
14710         this_arg_conv.is_owned = false;
14711         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14712         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14713         return (uint64_t)ret;
14714 }
14715
14716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14717         LDKChannelMonitorUpdate this_obj_conv;
14718         this_obj_conv.inner = (void*)(this_obj & (~1));
14719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14720         ChannelMonitorUpdate_free(this_obj_conv);
14721 }
14722
14723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14724         LDKChannelMonitorUpdate this_ptr_conv;
14725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14726         this_ptr_conv.is_owned = false;
14727         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14728         return ret_val;
14729 }
14730
14731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14732         LDKChannelMonitorUpdate this_ptr_conv;
14733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14734         this_ptr_conv.is_owned = false;
14735         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14736 }
14737
14738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14739         LDKChannelMonitorUpdate orig_conv;
14740         orig_conv.inner = (void*)(orig & (~1));
14741         orig_conv.is_owned = false;
14742         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14743         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14744         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14745         uint64_t ret_ref = (uint64_t)ret_var.inner;
14746         if (ret_var.is_owned) {
14747                 ret_ref |= 1;
14748         }
14749         return ret_ref;
14750 }
14751
14752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14753         LDKChannelMonitorUpdate obj_conv;
14754         obj_conv.inner = (void*)(obj & (~1));
14755         obj_conv.is_owned = false;
14756         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14757         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14758         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14759         CVec_u8Z_free(ret_var);
14760         return ret_arr;
14761 }
14762
14763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14764         LDKu8slice ser_ref;
14765         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14766         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14767         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14768         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14769         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14770         return (uint64_t)ret_conv;
14771 }
14772
14773 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14774         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
14775         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
14776         return ret_conv;
14777 }
14778
14779 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
14780         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
14781         return ret_conv;
14782 }
14783
14784 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
14785         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
14786         return ret_conv;
14787 }
14788
14789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14790         LDKMonitorUpdateError this_obj_conv;
14791         this_obj_conv.inner = (void*)(this_obj & (~1));
14792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14793         MonitorUpdateError_free(this_obj_conv);
14794 }
14795
14796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14797         LDKMonitorUpdateError orig_conv;
14798         orig_conv.inner = (void*)(orig & (~1));
14799         orig_conv.is_owned = false;
14800         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14803         uint64_t ret_ref = (uint64_t)ret_var.inner;
14804         if (ret_var.is_owned) {
14805                 ret_ref |= 1;
14806         }
14807         return ret_ref;
14808 }
14809
14810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14811         if ((this_ptr & 1) != 0) return;
14812         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14813         FREE((void*)this_ptr);
14814         MonitorEvent_free(this_ptr_conv);
14815 }
14816
14817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14818         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14819         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14820         *ret_copy = MonitorEvent_clone(orig_conv);
14821         uint64_t ret_ref = (uint64_t)ret_copy;
14822         return ret_ref;
14823 }
14824
14825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
14826         LDKHTLCUpdate a_conv;
14827         a_conv.inner = (void*)(a & (~1));
14828         a_conv.is_owned = (a & 1) || (a == 0);
14829         a_conv = HTLCUpdate_clone(&a_conv);
14830         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14831         *ret_copy = MonitorEvent_htlcevent(a_conv);
14832         uint64_t ret_ref = (uint64_t)ret_copy;
14833         return ret_ref;
14834 }
14835
14836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted(JNIEnv *env, jclass clz, int64_t a) {
14837         LDKOutPoint a_conv;
14838         a_conv.inner = (void*)(a & (~1));
14839         a_conv.is_owned = (a & 1) || (a == 0);
14840         a_conv = OutPoint_clone(&a_conv);
14841         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14842         *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv);
14843         uint64_t ret_ref = (uint64_t)ret_copy;
14844         return ret_ref;
14845 }
14846
14847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14848         LDKHTLCUpdate this_obj_conv;
14849         this_obj_conv.inner = (void*)(this_obj & (~1));
14850         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14851         HTLCUpdate_free(this_obj_conv);
14852 }
14853
14854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14855         LDKHTLCUpdate orig_conv;
14856         orig_conv.inner = (void*)(orig & (~1));
14857         orig_conv.is_owned = false;
14858         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
14859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14861         uint64_t ret_ref = (uint64_t)ret_var.inner;
14862         if (ret_var.is_owned) {
14863                 ret_ref |= 1;
14864         }
14865         return ret_ref;
14866 }
14867
14868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14869         LDKHTLCUpdate obj_conv;
14870         obj_conv.inner = (void*)(obj & (~1));
14871         obj_conv.is_owned = false;
14872         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14873         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14874         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14875         CVec_u8Z_free(ret_var);
14876         return ret_arr;
14877 }
14878
14879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14880         LDKu8slice ser_ref;
14881         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14882         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14883         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14884         *ret_conv = HTLCUpdate_read(ser_ref);
14885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14886         return (uint64_t)ret_conv;
14887 }
14888
14889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14890         LDKChannelMonitor this_obj_conv;
14891         this_obj_conv.inner = (void*)(this_obj & (~1));
14892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14893         ChannelMonitor_free(this_obj_conv);
14894 }
14895
14896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14897         LDKChannelMonitor orig_conv;
14898         orig_conv.inner = (void*)(orig & (~1));
14899         orig_conv.is_owned = false;
14900         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14901         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14902         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14903         uint64_t ret_ref = (uint64_t)ret_var.inner;
14904         if (ret_var.is_owned) {
14905                 ret_ref |= 1;
14906         }
14907         return ret_ref;
14908 }
14909
14910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14911         LDKChannelMonitor obj_conv;
14912         obj_conv.inner = (void*)(obj & (~1));
14913         obj_conv.is_owned = false;
14914         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14917         CVec_u8Z_free(ret_var);
14918         return ret_arr;
14919 }
14920
14921 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) {
14922         LDKChannelMonitor this_arg_conv;
14923         this_arg_conv.inner = (void*)(this_arg & (~1));
14924         this_arg_conv.is_owned = false;
14925         LDKChannelMonitorUpdate updates_conv;
14926         updates_conv.inner = (void*)(updates & (~1));
14927         updates_conv.is_owned = false;
14928         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14929         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14930         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14931         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14932         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14933         return (uint64_t)ret_conv;
14934 }
14935
14936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14937         LDKChannelMonitor this_arg_conv;
14938         this_arg_conv.inner = (void*)(this_arg & (~1));
14939         this_arg_conv.is_owned = false;
14940         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14941         return ret_val;
14942 }
14943
14944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
14945         LDKChannelMonitor this_arg_conv;
14946         this_arg_conv.inner = (void*)(this_arg & (~1));
14947         this_arg_conv.is_owned = false;
14948         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14949         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
14950         return (uint64_t)ret_ref;
14951 }
14952
14953 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14954         LDKChannelMonitor this_arg_conv;
14955         this_arg_conv.inner = (void*)(this_arg & (~1));
14956         this_arg_conv.is_owned = false;
14957         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14958         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14959         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14960         for (size_t v = 0; v < ret_var.datalen; v++) {
14961                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14962                 *ret_conv_47_ref = ret_var.data[v];
14963                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14964         }
14965         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14966         FREE(ret_var.data);
14967         return ret_arr;
14968 }
14969
14970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14971         LDKChannelMonitor this_arg_conv;
14972         this_arg_conv.inner = (void*)(this_arg & (~1));
14973         this_arg_conv.is_owned = false;
14974         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14975         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14976 }
14977
14978 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14979         LDKChannelMonitor this_arg_conv;
14980         this_arg_conv.inner = (void*)(this_arg & (~1));
14981         this_arg_conv.is_owned = false;
14982         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14983         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14984         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14985         for (size_t o = 0; o < ret_var.datalen; o++) {
14986                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14987                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14988                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14989                 ret_arr_ptr[o] = ret_conv_14_ref;
14990         }
14991         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14992         FREE(ret_var.data);
14993         return ret_arr;
14994 }
14995
14996 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14997         LDKChannelMonitor this_arg_conv;
14998         this_arg_conv.inner = (void*)(this_arg & (~1));
14999         this_arg_conv.is_owned = false;
15000         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
15001         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15002         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15003         for (size_t h = 0; h < ret_var.datalen; h++) {
15004                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15005                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
15006                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
15007                 ret_arr_ptr[h] = ret_conv_7_ref;
15008         }
15009         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15010         FREE(ret_var.data);
15011         return ret_arr;
15012 }
15013
15014 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) {
15015         LDKChannelMonitor this_arg_conv;
15016         this_arg_conv.inner = (void*)(this_arg & (~1));
15017         this_arg_conv.is_owned = false;
15018         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
15019         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
15020         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15021         ;
15022         for (size_t i = 0; i < ret_var.datalen; i++) {
15023                 LDKTransaction ret_conv_8_var = ret_var.data[i];
15024                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
15025                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
15026                 Transaction_free(ret_conv_8_var);
15027                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15028         }
15029         FREE(ret_var.data);
15030         return ret_arr;
15031 }
15032
15033 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) {
15034         LDKChannelMonitor this_arg_conv;
15035         this_arg_conv.inner = (void*)(this_arg & (~1));
15036         this_arg_conv.is_owned = false;
15037         unsigned char header_arr[80];
15038         CHECK((*env)->GetArrayLength(env, header) == 80);
15039         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15040         unsigned char (*header_ref)[80] = &header_arr;
15041         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15042         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15043         if (txdata_constr.datalen > 0)
15044                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15045         else
15046                 txdata_constr.data = NULL;
15047         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15048         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15049                 int64_t txdata_conv_24 = txdata_vals[y];
15050                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15051                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15052                 txdata_constr.data[y] = txdata_conv_24_conv;
15053         }
15054         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15055         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15056         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15057                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15058                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15059         }
15060         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15061         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15062                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15063                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15064         }
15065         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15066         if (logger_conv.free == LDKLogger_JCalls_free) {
15067                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15068                 LDKLogger_JCalls_cloned(&logger_conv);
15069         }
15070         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);
15071         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15072         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15073         for (size_t u = 0; u < ret_var.datalen; u++) {
15074                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15075                 *ret_conv_46_ref = ret_var.data[u];
15076                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15077         }
15078         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15079         FREE(ret_var.data);
15080         return ret_arr;
15081 }
15082
15083 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) {
15084         LDKChannelMonitor this_arg_conv;
15085         this_arg_conv.inner = (void*)(this_arg & (~1));
15086         this_arg_conv.is_owned = false;
15087         unsigned char header_arr[80];
15088         CHECK((*env)->GetArrayLength(env, header) == 80);
15089         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15090         unsigned char (*header_ref)[80] = &header_arr;
15091         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15092         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15094                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15095         }
15096         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15097         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15098                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15099                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15100         }
15101         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15102         if (logger_conv.free == LDKLogger_JCalls_free) {
15103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15104                 LDKLogger_JCalls_cloned(&logger_conv);
15105         }
15106         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15107 }
15108
15109 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) {
15110         LDKChannelMonitor this_arg_conv;
15111         this_arg_conv.inner = (void*)(this_arg & (~1));
15112         this_arg_conv.is_owned = false;
15113         unsigned char header_arr[80];
15114         CHECK((*env)->GetArrayLength(env, header) == 80);
15115         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15116         unsigned char (*header_ref)[80] = &header_arr;
15117         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15118         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15119         if (txdata_constr.datalen > 0)
15120                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15121         else
15122                 txdata_constr.data = NULL;
15123         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15124         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15125                 int64_t txdata_conv_24 = txdata_vals[y];
15126                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15127                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15128                 txdata_constr.data[y] = txdata_conv_24_conv;
15129         }
15130         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15131         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15132         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15134                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15135         }
15136         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15137         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15138                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15139                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15140         }
15141         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15142         if (logger_conv.free == LDKLogger_JCalls_free) {
15143                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15144                 LDKLogger_JCalls_cloned(&logger_conv);
15145         }
15146         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);
15147         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15148         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15149         for (size_t u = 0; u < ret_var.datalen; u++) {
15150                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15151                 *ret_conv_46_ref = ret_var.data[u];
15152                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15153         }
15154         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15155         FREE(ret_var.data);
15156         return ret_arr;
15157 }
15158
15159 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) {
15160         LDKChannelMonitor this_arg_conv;
15161         this_arg_conv.inner = (void*)(this_arg & (~1));
15162         this_arg_conv.is_owned = false;
15163         unsigned char txid_arr[32];
15164         CHECK((*env)->GetArrayLength(env, txid) == 32);
15165         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
15166         unsigned char (*txid_ref)[32] = &txid_arr;
15167         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15168         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15169                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15170                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15171         }
15172         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15173         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15175                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15176         }
15177         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15178         if (logger_conv.free == LDKLogger_JCalls_free) {
15179                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15180                 LDKLogger_JCalls_cloned(&logger_conv);
15181         }
15182         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
15183 }
15184
15185 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) {
15186         LDKChannelMonitor this_arg_conv;
15187         this_arg_conv.inner = (void*)(this_arg & (~1));
15188         this_arg_conv.is_owned = false;
15189         unsigned char header_arr[80];
15190         CHECK((*env)->GetArrayLength(env, header) == 80);
15191         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15192         unsigned char (*header_ref)[80] = &header_arr;
15193         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15194         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15195                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15196                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15197         }
15198         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15199         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15200                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15201                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15202         }
15203         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15204         if (logger_conv.free == LDKLogger_JCalls_free) {
15205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15206                 LDKLogger_JCalls_cloned(&logger_conv);
15207         }
15208         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15209         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15211         for (size_t u = 0; u < ret_var.datalen; u++) {
15212                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15213                 *ret_conv_46_ref = ret_var.data[u];
15214                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15215         }
15216         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15217         FREE(ret_var.data);
15218         return ret_arr;
15219 }
15220
15221 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
15222         LDKChannelMonitor this_arg_conv;
15223         this_arg_conv.inner = (void*)(this_arg & (~1));
15224         this_arg_conv.is_owned = false;
15225         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
15226         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15227         ;
15228         for (size_t i = 0; i < ret_var.datalen; i++) {
15229                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
15230                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
15231                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15232         }
15233         FREE(ret_var.data);
15234         return ret_arr;
15235 }
15236
15237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
15238         LDKChannelMonitor this_arg_conv;
15239         this_arg_conv.inner = (void*)(this_arg & (~1));
15240         this_arg_conv.is_owned = false;
15241         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
15242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15244         uint64_t ret_ref = (uint64_t)ret_var.inner;
15245         if (ret_var.is_owned) {
15246                 ret_ref |= 1;
15247         }
15248         return ret_ref;
15249 }
15250
15251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15252         if ((this_ptr & 1) != 0) return;
15253         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
15254         FREE((void*)this_ptr);
15255         Persist_free(this_ptr_conv);
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
15259         LDKu8slice ser_ref;
15260         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15261         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15262         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
15263         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
15264         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
15265         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15266         return (uint64_t)ret_conv;
15267 }
15268
15269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15270         LDKOutPoint this_obj_conv;
15271         this_obj_conv.inner = (void*)(this_obj & (~1));
15272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15273         OutPoint_free(this_obj_conv);
15274 }
15275
15276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
15277         LDKOutPoint this_ptr_conv;
15278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15279         this_ptr_conv.is_owned = false;
15280         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
15282         return ret_arr;
15283 }
15284
15285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15286         LDKOutPoint this_ptr_conv;
15287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15288         this_ptr_conv.is_owned = false;
15289         LDKThirtyTwoBytes val_ref;
15290         CHECK((*env)->GetArrayLength(env, val) == 32);
15291         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15292         OutPoint_set_txid(&this_ptr_conv, val_ref);
15293 }
15294
15295 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
15296         LDKOutPoint this_ptr_conv;
15297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15298         this_ptr_conv.is_owned = false;
15299         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
15300         return ret_val;
15301 }
15302
15303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15304         LDKOutPoint this_ptr_conv;
15305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15306         this_ptr_conv.is_owned = false;
15307         OutPoint_set_index(&this_ptr_conv, val);
15308 }
15309
15310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
15311         LDKThirtyTwoBytes txid_arg_ref;
15312         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
15313         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
15314         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
15315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15317         uint64_t ret_ref = (uint64_t)ret_var.inner;
15318         if (ret_var.is_owned) {
15319                 ret_ref |= 1;
15320         }
15321         return ret_ref;
15322 }
15323
15324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15325         LDKOutPoint orig_conv;
15326         orig_conv.inner = (void*)(orig & (~1));
15327         orig_conv.is_owned = false;
15328         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
15329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15331         uint64_t ret_ref = (uint64_t)ret_var.inner;
15332         if (ret_var.is_owned) {
15333                 ret_ref |= 1;
15334         }
15335         return ret_ref;
15336 }
15337
15338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15339         LDKOutPoint a_conv;
15340         a_conv.inner = (void*)(a & (~1));
15341         a_conv.is_owned = false;
15342         LDKOutPoint b_conv;
15343         b_conv.inner = (void*)(b & (~1));
15344         b_conv.is_owned = false;
15345         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
15346         return ret_val;
15347 }
15348
15349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
15350         LDKOutPoint o_conv;
15351         o_conv.inner = (void*)(o & (~1));
15352         o_conv.is_owned = false;
15353         int64_t ret_val = OutPoint_hash(&o_conv);
15354         return ret_val;
15355 }
15356
15357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15358         LDKOutPoint this_arg_conv;
15359         this_arg_conv.inner = (void*)(this_arg & (~1));
15360         this_arg_conv.is_owned = false;
15361         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15362         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
15363         return ret_arr;
15364 }
15365
15366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
15367         LDKOutPoint obj_conv;
15368         obj_conv.inner = (void*)(obj & (~1));
15369         obj_conv.is_owned = false;
15370         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
15371         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15372         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15373         CVec_u8Z_free(ret_var);
15374         return ret_arr;
15375 }
15376
15377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15378         LDKu8slice ser_ref;
15379         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15380         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15381         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15382         *ret_conv = OutPoint_read(ser_ref);
15383         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15384         return (uint64_t)ret_conv;
15385 }
15386
15387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15388         LDKDelayedPaymentOutputDescriptor this_obj_conv;
15389         this_obj_conv.inner = (void*)(this_obj & (~1));
15390         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15391         DelayedPaymentOutputDescriptor_free(this_obj_conv);
15392 }
15393
15394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15395         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15397         this_ptr_conv.is_owned = false;
15398         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15401         uint64_t ret_ref = (uint64_t)ret_var.inner;
15402         if (ret_var.is_owned) {
15403                 ret_ref |= 1;
15404         }
15405         return ret_ref;
15406 }
15407
15408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15409         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15411         this_ptr_conv.is_owned = false;
15412         LDKOutPoint val_conv;
15413         val_conv.inner = (void*)(val & (~1));
15414         val_conv.is_owned = (val & 1) || (val == 0);
15415         val_conv = OutPoint_clone(&val_conv);
15416         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15417 }
15418
15419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15420         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15422         this_ptr_conv.is_owned = false;
15423         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15424         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
15425         return ret_arr;
15426 }
15427
15428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15429         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15431         this_ptr_conv.is_owned = false;
15432         LDKPublicKey val_ref;
15433         CHECK((*env)->GetArrayLength(env, val) == 33);
15434         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15435         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
15436 }
15437
15438 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15439         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15441         this_ptr_conv.is_owned = false;
15442         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
15443         return ret_val;
15444 }
15445
15446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15447         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15449         this_ptr_conv.is_owned = false;
15450         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
15451 }
15452
15453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15454         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15456         this_ptr_conv.is_owned = false;
15457         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15458         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15459 }
15460
15461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15462         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15464         this_ptr_conv.is_owned = false;
15465         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15466         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
15467         return ret_arr;
15468 }
15469
15470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15471         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15473         this_ptr_conv.is_owned = false;
15474         LDKPublicKey val_ref;
15475         CHECK((*env)->GetArrayLength(env, val) == 33);
15476         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15477         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
15478 }
15479
15480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15481         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15483         this_ptr_conv.is_owned = false;
15484         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15485         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15486         return ret_arr;
15487 }
15488
15489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15490         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15492         this_ptr_conv.is_owned = false;
15493         LDKThirtyTwoBytes val_ref;
15494         CHECK((*env)->GetArrayLength(env, val) == 32);
15495         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15496         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15497 }
15498
15499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15500         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15502         this_ptr_conv.is_owned = false;
15503         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15504         return ret_val;
15505 }
15506
15507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15508         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15510         this_ptr_conv.is_owned = false;
15511         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15512 }
15513
15514 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) {
15515         LDKOutPoint outpoint_arg_conv;
15516         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15517         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15518         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15519         LDKPublicKey per_commitment_point_arg_ref;
15520         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15521         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15522         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15523         LDKPublicKey revocation_pubkey_arg_ref;
15524         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15525         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15526         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15527         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15528         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15529         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);
15530         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15531         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15532         uint64_t ret_ref = (uint64_t)ret_var.inner;
15533         if (ret_var.is_owned) {
15534                 ret_ref |= 1;
15535         }
15536         return ret_ref;
15537 }
15538
15539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15540         LDKDelayedPaymentOutputDescriptor orig_conv;
15541         orig_conv.inner = (void*)(orig & (~1));
15542         orig_conv.is_owned = false;
15543         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15544         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15545         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15546         uint64_t ret_ref = (uint64_t)ret_var.inner;
15547         if (ret_var.is_owned) {
15548                 ret_ref |= 1;
15549         }
15550         return ret_ref;
15551 }
15552
15553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15554         LDKDelayedPaymentOutputDescriptor obj_conv;
15555         obj_conv.inner = (void*)(obj & (~1));
15556         obj_conv.is_owned = false;
15557         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15558         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15559         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15560         CVec_u8Z_free(ret_var);
15561         return ret_arr;
15562 }
15563
15564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15565         LDKu8slice ser_ref;
15566         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15567         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15568         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15569         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15570         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15571         return (uint64_t)ret_conv;
15572 }
15573
15574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15575         LDKStaticPaymentOutputDescriptor this_obj_conv;
15576         this_obj_conv.inner = (void*)(this_obj & (~1));
15577         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15578         StaticPaymentOutputDescriptor_free(this_obj_conv);
15579 }
15580
15581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15582         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15584         this_ptr_conv.is_owned = false;
15585         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15588         uint64_t ret_ref = (uint64_t)ret_var.inner;
15589         if (ret_var.is_owned) {
15590                 ret_ref |= 1;
15591         }
15592         return ret_ref;
15593 }
15594
15595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15596         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15598         this_ptr_conv.is_owned = false;
15599         LDKOutPoint val_conv;
15600         val_conv.inner = (void*)(val & (~1));
15601         val_conv.is_owned = (val & 1) || (val == 0);
15602         val_conv = OutPoint_clone(&val_conv);
15603         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15604 }
15605
15606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15607         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15609         this_ptr_conv.is_owned = false;
15610         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15611         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15612 }
15613
15614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15615         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15617         this_ptr_conv.is_owned = false;
15618         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15620         return ret_arr;
15621 }
15622
15623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15624         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15626         this_ptr_conv.is_owned = false;
15627         LDKThirtyTwoBytes val_ref;
15628         CHECK((*env)->GetArrayLength(env, val) == 32);
15629         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15630         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15631 }
15632
15633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15634         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15636         this_ptr_conv.is_owned = false;
15637         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15638         return ret_val;
15639 }
15640
15641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15642         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15644         this_ptr_conv.is_owned = false;
15645         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15646 }
15647
15648 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) {
15649         LDKOutPoint outpoint_arg_conv;
15650         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15651         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15652         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15653         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15654         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15655         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15656         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15657         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15660         uint64_t ret_ref = (uint64_t)ret_var.inner;
15661         if (ret_var.is_owned) {
15662                 ret_ref |= 1;
15663         }
15664         return ret_ref;
15665 }
15666
15667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15668         LDKStaticPaymentOutputDescriptor orig_conv;
15669         orig_conv.inner = (void*)(orig & (~1));
15670         orig_conv.is_owned = false;
15671         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15672         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15673         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15674         uint64_t ret_ref = (uint64_t)ret_var.inner;
15675         if (ret_var.is_owned) {
15676                 ret_ref |= 1;
15677         }
15678         return ret_ref;
15679 }
15680
15681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15682         LDKStaticPaymentOutputDescriptor obj_conv;
15683         obj_conv.inner = (void*)(obj & (~1));
15684         obj_conv.is_owned = false;
15685         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15686         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15687         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15688         CVec_u8Z_free(ret_var);
15689         return ret_arr;
15690 }
15691
15692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15693         LDKu8slice ser_ref;
15694         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15695         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15696         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15697         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15698         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15699         return (uint64_t)ret_conv;
15700 }
15701
15702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15703         if ((this_ptr & 1) != 0) return;
15704         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15705         FREE((void*)this_ptr);
15706         SpendableOutputDescriptor_free(this_ptr_conv);
15707 }
15708
15709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15710         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15711         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15712         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15713         uint64_t ret_ref = (uint64_t)ret_copy;
15714         return ret_ref;
15715 }
15716
15717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
15718         LDKOutPoint outpoint_conv;
15719         outpoint_conv.inner = (void*)(outpoint & (~1));
15720         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
15721         outpoint_conv = OutPoint_clone(&outpoint_conv);
15722         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
15723         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15724         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
15725         uint64_t ret_ref = (uint64_t)ret_copy;
15726         return ret_ref;
15727 }
15728
15729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
15730         LDKDelayedPaymentOutputDescriptor a_conv;
15731         a_conv.inner = (void*)(a & (~1));
15732         a_conv.is_owned = (a & 1) || (a == 0);
15733         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
15734         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15735         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
15736         uint64_t ret_ref = (uint64_t)ret_copy;
15737         return ret_ref;
15738 }
15739
15740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
15741         LDKStaticPaymentOutputDescriptor a_conv;
15742         a_conv.inner = (void*)(a & (~1));
15743         a_conv.is_owned = (a & 1) || (a == 0);
15744         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
15745         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15746         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
15747         uint64_t ret_ref = (uint64_t)ret_copy;
15748         return ret_ref;
15749 }
15750
15751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15752         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15753         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15756         CVec_u8Z_free(ret_var);
15757         return ret_arr;
15758 }
15759
15760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15761         LDKu8slice ser_ref;
15762         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15763         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15764         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15765         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15766         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15767         return (uint64_t)ret_conv;
15768 }
15769
15770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15771         if ((this_ptr & 1) != 0) return;
15772         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15773         FREE((void*)this_ptr);
15774         BaseSign_free(this_ptr_conv);
15775 }
15776
15777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15778         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15779         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15780         *ret = Sign_clone(orig_conv);
15781         return (uint64_t)ret;
15782 }
15783
15784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15785         if ((this_ptr & 1) != 0) return;
15786         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15787         FREE((void*)this_ptr);
15788         Sign_free(this_ptr_conv);
15789 }
15790
15791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15792         if ((this_ptr & 1) != 0) return;
15793         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15794         FREE((void*)this_ptr);
15795         KeysInterface_free(this_ptr_conv);
15796 }
15797
15798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15799         LDKInMemorySigner this_obj_conv;
15800         this_obj_conv.inner = (void*)(this_obj & (~1));
15801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15802         InMemorySigner_free(this_obj_conv);
15803 }
15804
15805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15806         LDKInMemorySigner this_ptr_conv;
15807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15808         this_ptr_conv.is_owned = false;
15809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
15811         return ret_arr;
15812 }
15813
15814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15815         LDKInMemorySigner this_ptr_conv;
15816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15817         this_ptr_conv.is_owned = false;
15818         LDKSecretKey val_ref;
15819         CHECK((*env)->GetArrayLength(env, val) == 32);
15820         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15821         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15822 }
15823
15824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15825         LDKInMemorySigner this_ptr_conv;
15826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15827         this_ptr_conv.is_owned = false;
15828         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
15830         return ret_arr;
15831 }
15832
15833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15834         LDKInMemorySigner this_ptr_conv;
15835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15836         this_ptr_conv.is_owned = false;
15837         LDKSecretKey val_ref;
15838         CHECK((*env)->GetArrayLength(env, val) == 32);
15839         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15840         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15841 }
15842
15843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15844         LDKInMemorySigner this_ptr_conv;
15845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15846         this_ptr_conv.is_owned = false;
15847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
15849         return ret_arr;
15850 }
15851
15852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15853         LDKInMemorySigner this_ptr_conv;
15854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15855         this_ptr_conv.is_owned = false;
15856         LDKSecretKey val_ref;
15857         CHECK((*env)->GetArrayLength(env, val) == 32);
15858         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15859         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15860 }
15861
15862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15863         LDKInMemorySigner this_ptr_conv;
15864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15865         this_ptr_conv.is_owned = false;
15866         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15867         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
15868         return ret_arr;
15869 }
15870
15871 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) {
15872         LDKInMemorySigner this_ptr_conv;
15873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15874         this_ptr_conv.is_owned = false;
15875         LDKSecretKey val_ref;
15876         CHECK((*env)->GetArrayLength(env, val) == 32);
15877         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15878         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15879 }
15880
15881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15882         LDKInMemorySigner this_ptr_conv;
15883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15884         this_ptr_conv.is_owned = false;
15885         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
15887         return ret_arr;
15888 }
15889
15890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15891         LDKInMemorySigner this_ptr_conv;
15892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15893         this_ptr_conv.is_owned = false;
15894         LDKSecretKey val_ref;
15895         CHECK((*env)->GetArrayLength(env, val) == 32);
15896         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15897         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15898 }
15899
15900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15901         LDKInMemorySigner this_ptr_conv;
15902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15903         this_ptr_conv.is_owned = false;
15904         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15905         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
15906         return ret_arr;
15907 }
15908
15909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15910         LDKInMemorySigner this_ptr_conv;
15911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15912         this_ptr_conv.is_owned = false;
15913         LDKThirtyTwoBytes val_ref;
15914         CHECK((*env)->GetArrayLength(env, val) == 32);
15915         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15916         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15917 }
15918
15919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15920         LDKInMemorySigner orig_conv;
15921         orig_conv.inner = (void*)(orig & (~1));
15922         orig_conv.is_owned = false;
15923         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15924         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15925         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15926         uint64_t ret_ref = (uint64_t)ret_var.inner;
15927         if (ret_var.is_owned) {
15928                 ret_ref |= 1;
15929         }
15930         return ret_ref;
15931 }
15932
15933 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) {
15934         LDKSecretKey funding_key_ref;
15935         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
15936         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
15937         LDKSecretKey revocation_base_key_ref;
15938         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
15939         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
15940         LDKSecretKey payment_key_ref;
15941         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
15942         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
15943         LDKSecretKey delayed_payment_base_key_ref;
15944         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
15945         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
15946         LDKSecretKey htlc_base_key_ref;
15947         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
15948         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
15949         LDKThirtyTwoBytes commitment_seed_ref;
15950         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
15951         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
15952         LDKThirtyTwoBytes channel_keys_id_ref;
15953         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
15954         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
15955         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);
15956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15958         uint64_t ret_ref = (uint64_t)ret_var.inner;
15959         if (ret_var.is_owned) {
15960                 ret_ref |= 1;
15961         }
15962         return ret_ref;
15963 }
15964
15965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
15966         LDKInMemorySigner this_arg_conv;
15967         this_arg_conv.inner = (void*)(this_arg & (~1));
15968         this_arg_conv.is_owned = false;
15969         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15972         uint64_t ret_ref = (uint64_t)ret_var.inner;
15973         if (ret_var.is_owned) {
15974                 ret_ref |= 1;
15975         }
15976         return ret_ref;
15977 }
15978
15979 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15980         LDKInMemorySigner this_arg_conv;
15981         this_arg_conv.inner = (void*)(this_arg & (~1));
15982         this_arg_conv.is_owned = false;
15983         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15984         return ret_val;
15985 }
15986
15987 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15988         LDKInMemorySigner this_arg_conv;
15989         this_arg_conv.inner = (void*)(this_arg & (~1));
15990         this_arg_conv.is_owned = false;
15991         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15992         return ret_val;
15993 }
15994
15995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
15996         LDKInMemorySigner this_arg_conv;
15997         this_arg_conv.inner = (void*)(this_arg & (~1));
15998         this_arg_conv.is_owned = false;
15999         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
16000         return ret_val;
16001 }
16002
16003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
16004         LDKInMemorySigner this_arg_conv;
16005         this_arg_conv.inner = (void*)(this_arg & (~1));
16006         this_arg_conv.is_owned = false;
16007         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
16008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16010         uint64_t ret_ref = (uint64_t)ret_var.inner;
16011         if (ret_var.is_owned) {
16012                 ret_ref |= 1;
16013         }
16014         return ret_ref;
16015 }
16016
16017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
16018         LDKInMemorySigner this_arg_conv;
16019         this_arg_conv.inner = (void*)(this_arg & (~1));
16020         this_arg_conv.is_owned = false;
16021         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
16022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16024         uint64_t ret_ref = (uint64_t)ret_var.inner;
16025         if (ret_var.is_owned) {
16026                 ret_ref |= 1;
16027         }
16028         return ret_ref;
16029 }
16030
16031 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) {
16032         LDKInMemorySigner this_arg_conv;
16033         this_arg_conv.inner = (void*)(this_arg & (~1));
16034         this_arg_conv.is_owned = false;
16035         LDKTransaction spend_tx_ref;
16036         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16037         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16038         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16039         spend_tx_ref.data_is_owned = true;
16040         LDKStaticPaymentOutputDescriptor descriptor_conv;
16041         descriptor_conv.inner = (void*)(descriptor & (~1));
16042         descriptor_conv.is_owned = false;
16043         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16044         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16045         return (uint64_t)ret_conv;
16046 }
16047
16048 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) {
16049         LDKInMemorySigner this_arg_conv;
16050         this_arg_conv.inner = (void*)(this_arg & (~1));
16051         this_arg_conv.is_owned = false;
16052         LDKTransaction spend_tx_ref;
16053         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16054         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16055         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16056         spend_tx_ref.data_is_owned = true;
16057         LDKDelayedPaymentOutputDescriptor descriptor_conv;
16058         descriptor_conv.inner = (void*)(descriptor & (~1));
16059         descriptor_conv.is_owned = false;
16060         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16061         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16062         return (uint64_t)ret_conv;
16063 }
16064
16065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
16066         LDKInMemorySigner this_arg_conv;
16067         this_arg_conv.inner = (void*)(this_arg & (~1));
16068         this_arg_conv.is_owned = false;
16069         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
16070         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
16071         return (uint64_t)ret;
16072 }
16073
16074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
16075         LDKInMemorySigner this_arg_conv;
16076         this_arg_conv.inner = (void*)(this_arg & (~1));
16077         this_arg_conv.is_owned = false;
16078         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
16079         *ret = InMemorySigner_as_Sign(&this_arg_conv);
16080         return (uint64_t)ret;
16081 }
16082
16083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
16084         LDKInMemorySigner obj_conv;
16085         obj_conv.inner = (void*)(obj & (~1));
16086         obj_conv.is_owned = false;
16087         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
16088         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16089         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16090         CVec_u8Z_free(ret_var);
16091         return ret_arr;
16092 }
16093
16094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16095         LDKu8slice ser_ref;
16096         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16097         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16098         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16099         *ret_conv = InMemorySigner_read(ser_ref);
16100         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16101         return (uint64_t)ret_conv;
16102 }
16103
16104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16105         LDKKeysManager this_obj_conv;
16106         this_obj_conv.inner = (void*)(this_obj & (~1));
16107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16108         KeysManager_free(this_obj_conv);
16109 }
16110
16111 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) {
16112         unsigned char seed_arr[32];
16113         CHECK((*env)->GetArrayLength(env, seed) == 32);
16114         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
16115         unsigned char (*seed_ref)[32] = &seed_arr;
16116         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
16117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16119         uint64_t ret_ref = (uint64_t)ret_var.inner;
16120         if (ret_var.is_owned) {
16121                 ret_ref |= 1;
16122         }
16123         return ret_ref;
16124 }
16125
16126 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) {
16127         LDKKeysManager this_arg_conv;
16128         this_arg_conv.inner = (void*)(this_arg & (~1));
16129         this_arg_conv.is_owned = false;
16130         unsigned char params_arr[32];
16131         CHECK((*env)->GetArrayLength(env, params) == 32);
16132         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
16133         unsigned char (*params_ref)[32] = &params_arr;
16134         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
16135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16137         uint64_t ret_ref = (uint64_t)ret_var.inner;
16138         if (ret_var.is_owned) {
16139                 ret_ref |= 1;
16140         }
16141         return ret_ref;
16142 }
16143
16144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
16145         LDKKeysManager this_arg_conv;
16146         this_arg_conv.inner = (void*)(this_arg & (~1));
16147         this_arg_conv.is_owned = false;
16148         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
16149         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
16150         if (descriptors_constr.datalen > 0)
16151                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16152         else
16153                 descriptors_constr.data = NULL;
16154         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
16155         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
16156                 int64_t descriptors_conv_27 = descriptors_vals[b];
16157                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
16158                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
16159                 descriptors_constr.data[b] = descriptors_conv_27_conv;
16160         }
16161         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
16162         LDKCVec_TxOutZ outputs_constr;
16163         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
16164         if (outputs_constr.datalen > 0)
16165                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16166         else
16167                 outputs_constr.data = NULL;
16168         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
16169         for (size_t h = 0; h < outputs_constr.datalen; h++) {
16170                 int64_t outputs_conv_7 = outputs_vals[h];
16171                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
16172                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
16173                 outputs_constr.data[h] = outputs_conv_7_conv;
16174         }
16175         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
16176         LDKCVec_u8Z change_destination_script_ref;
16177         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
16178         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
16179         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
16180         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16181         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
16182         return (uint64_t)ret_conv;
16183 }
16184
16185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
16186         LDKKeysManager this_arg_conv;
16187         this_arg_conv.inner = (void*)(this_arg & (~1));
16188         this_arg_conv.is_owned = false;
16189         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
16190         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
16191         return (uint64_t)ret;
16192 }
16193
16194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16195         LDKChannelManager this_obj_conv;
16196         this_obj_conv.inner = (void*)(this_obj & (~1));
16197         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16198         ChannelManager_free(this_obj_conv);
16199 }
16200
16201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16202         LDKChainParameters this_obj_conv;
16203         this_obj_conv.inner = (void*)(this_obj & (~1));
16204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16205         ChainParameters_free(this_obj_conv);
16206 }
16207
16208 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
16209         LDKChainParameters this_ptr_conv;
16210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16211         this_ptr_conv.is_owned = false;
16212         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
16213         return ret_conv;
16214 }
16215
16216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
16217         LDKChainParameters this_ptr_conv;
16218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16219         this_ptr_conv.is_owned = false;
16220         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
16221         ChainParameters_set_network(&this_ptr_conv, val_conv);
16222 }
16223
16224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
16225         LDKChainParameters this_ptr_conv;
16226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16227         this_ptr_conv.is_owned = false;
16228         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
16229         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16230         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16231         uint64_t ret_ref = (uint64_t)ret_var.inner;
16232         if (ret_var.is_owned) {
16233                 ret_ref |= 1;
16234         }
16235         return ret_ref;
16236 }
16237
16238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16239         LDKChainParameters this_ptr_conv;
16240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16241         this_ptr_conv.is_owned = false;
16242         LDKBestBlock val_conv;
16243         val_conv.inner = (void*)(val & (~1));
16244         val_conv.is_owned = (val & 1) || (val == 0);
16245         val_conv = BestBlock_clone(&val_conv);
16246         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
16247 }
16248
16249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
16250         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
16251         LDKBestBlock best_block_arg_conv;
16252         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
16253         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
16254         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
16255         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
16256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16258         uint64_t ret_ref = (uint64_t)ret_var.inner;
16259         if (ret_var.is_owned) {
16260                 ret_ref |= 1;
16261         }
16262         return ret_ref;
16263 }
16264
16265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16266         LDKChainParameters orig_conv;
16267         orig_conv.inner = (void*)(orig & (~1));
16268         orig_conv.is_owned = false;
16269         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
16270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16272         uint64_t ret_ref = (uint64_t)ret_var.inner;
16273         if (ret_var.is_owned) {
16274                 ret_ref |= 1;
16275         }
16276         return ret_ref;
16277 }
16278
16279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16280         LDKChannelCounterparty this_obj_conv;
16281         this_obj_conv.inner = (void*)(this_obj & (~1));
16282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16283         ChannelCounterparty_free(this_obj_conv);
16284 }
16285
16286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16287         LDKChannelCounterparty this_ptr_conv;
16288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16289         this_ptr_conv.is_owned = false;
16290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
16292         return ret_arr;
16293 }
16294
16295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16296         LDKChannelCounterparty this_ptr_conv;
16297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16298         this_ptr_conv.is_owned = false;
16299         LDKPublicKey val_ref;
16300         CHECK((*env)->GetArrayLength(env, val) == 33);
16301         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16302         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
16303 }
16304
16305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16306         LDKChannelCounterparty this_ptr_conv;
16307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16308         this_ptr_conv.is_owned = false;
16309         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
16310         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16311         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16312         uint64_t ret_ref = (uint64_t)ret_var.inner;
16313         if (ret_var.is_owned) {
16314                 ret_ref |= 1;
16315         }
16316         return ret_ref;
16317 }
16318
16319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16320         LDKChannelCounterparty this_ptr_conv;
16321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16322         this_ptr_conv.is_owned = false;
16323         LDKInitFeatures val_conv;
16324         val_conv.inner = (void*)(val & (~1));
16325         val_conv.is_owned = (val & 1) || (val == 0);
16326         val_conv = InitFeatures_clone(&val_conv);
16327         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
16328 }
16329
16330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16331         LDKChannelCounterparty this_ptr_conv;
16332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16333         this_ptr_conv.is_owned = false;
16334         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
16335         return ret_val;
16336 }
16337
16338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16339         LDKChannelCounterparty this_ptr_conv;
16340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16341         this_ptr_conv.is_owned = false;
16342         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
16343 }
16344
16345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16346         LDKChannelCounterparty orig_conv;
16347         orig_conv.inner = (void*)(orig & (~1));
16348         orig_conv.is_owned = false;
16349         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
16350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16352         uint64_t ret_ref = (uint64_t)ret_var.inner;
16353         if (ret_var.is_owned) {
16354                 ret_ref |= 1;
16355         }
16356         return ret_ref;
16357 }
16358
16359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16360         LDKChannelDetails this_obj_conv;
16361         this_obj_conv.inner = (void*)(this_obj & (~1));
16362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16363         ChannelDetails_free(this_obj_conv);
16364 }
16365
16366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16367         LDKChannelDetails this_ptr_conv;
16368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16369         this_ptr_conv.is_owned = false;
16370         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16371         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
16372         return ret_arr;
16373 }
16374
16375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16376         LDKChannelDetails this_ptr_conv;
16377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16378         this_ptr_conv.is_owned = false;
16379         LDKThirtyTwoBytes val_ref;
16380         CHECK((*env)->GetArrayLength(env, val) == 32);
16381         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16382         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
16383 }
16384
16385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
16386         LDKChannelDetails this_ptr_conv;
16387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16388         this_ptr_conv.is_owned = false;
16389         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
16390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16392         uint64_t ret_ref = (uint64_t)ret_var.inner;
16393         if (ret_var.is_owned) {
16394                 ret_ref |= 1;
16395         }
16396         return ret_ref;
16397 }
16398
16399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16400         LDKChannelDetails this_ptr_conv;
16401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16402         this_ptr_conv.is_owned = false;
16403         LDKChannelCounterparty val_conv;
16404         val_conv.inner = (void*)(val & (~1));
16405         val_conv.is_owned = (val & 1) || (val == 0);
16406         val_conv = ChannelCounterparty_clone(&val_conv);
16407         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
16408 }
16409
16410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
16411         LDKChannelDetails this_ptr_conv;
16412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16413         this_ptr_conv.is_owned = false;
16414         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
16415         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16416         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16417         uint64_t ret_ref = (uint64_t)ret_var.inner;
16418         if (ret_var.is_owned) {
16419                 ret_ref |= 1;
16420         }
16421         return ret_ref;
16422 }
16423
16424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16425         LDKChannelDetails this_ptr_conv;
16426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16427         this_ptr_conv.is_owned = false;
16428         LDKOutPoint val_conv;
16429         val_conv.inner = (void*)(val & (~1));
16430         val_conv.is_owned = (val & 1) || (val == 0);
16431         val_conv = OutPoint_clone(&val_conv);
16432         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
16433 }
16434
16435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16436         LDKChannelDetails this_ptr_conv;
16437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16438         this_ptr_conv.is_owned = false;
16439         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16440         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
16441         uint64_t ret_ref = (uint64_t)ret_copy;
16442         return ret_ref;
16443 }
16444
16445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16446         LDKChannelDetails this_ptr_conv;
16447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16448         this_ptr_conv.is_owned = false;
16449         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16450         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
16451 }
16452
16453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16454         LDKChannelDetails this_ptr_conv;
16455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16456         this_ptr_conv.is_owned = false;
16457         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
16458         return ret_val;
16459 }
16460
16461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16462         LDKChannelDetails this_ptr_conv;
16463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16464         this_ptr_conv.is_owned = false;
16465         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
16466 }
16467
16468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16469         LDKChannelDetails this_ptr_conv;
16470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16471         this_ptr_conv.is_owned = false;
16472         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16473         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16474         uint64_t ret_ref = (uint64_t)ret_copy;
16475         return ret_ref;
16476 }
16477
16478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16479         LDKChannelDetails this_ptr_conv;
16480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16481         this_ptr_conv.is_owned = false;
16482         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16483         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16484 }
16485
16486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16487         LDKChannelDetails this_ptr_conv;
16488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16489         this_ptr_conv.is_owned = false;
16490         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
16491         return ret_val;
16492 }
16493
16494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16495         LDKChannelDetails this_ptr_conv;
16496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16497         this_ptr_conv.is_owned = false;
16498         ChannelDetails_set_user_id(&this_ptr_conv, val);
16499 }
16500
16501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16502         LDKChannelDetails this_ptr_conv;
16503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16504         this_ptr_conv.is_owned = false;
16505         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16506         return ret_val;
16507 }
16508
16509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16510         LDKChannelDetails this_ptr_conv;
16511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16512         this_ptr_conv.is_owned = false;
16513         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16514 }
16515
16516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16517         LDKChannelDetails this_ptr_conv;
16518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16519         this_ptr_conv.is_owned = false;
16520         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16521         return ret_val;
16522 }
16523
16524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16525         LDKChannelDetails this_ptr_conv;
16526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16527         this_ptr_conv.is_owned = false;
16528         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16529 }
16530
16531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16532         LDKChannelDetails this_ptr_conv;
16533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16534         this_ptr_conv.is_owned = false;
16535         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16536         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16537         uint64_t ret_ref = (uint64_t)ret_copy;
16538         return ret_ref;
16539 }
16540
16541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16542         LDKChannelDetails this_ptr_conv;
16543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16544         this_ptr_conv.is_owned = false;
16545         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16546         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16547 }
16548
16549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16550         LDKChannelDetails this_ptr_conv;
16551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16552         this_ptr_conv.is_owned = false;
16553         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16554         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16555         uint64_t ret_ref = (uint64_t)ret_copy;
16556         return ret_ref;
16557 }
16558
16559 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) {
16560         LDKChannelDetails this_ptr_conv;
16561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16562         this_ptr_conv.is_owned = false;
16563         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16564         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16565 }
16566
16567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16568         LDKChannelDetails this_ptr_conv;
16569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16570         this_ptr_conv.is_owned = false;
16571         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16572         return ret_val;
16573 }
16574
16575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16576         LDKChannelDetails this_ptr_conv;
16577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16578         this_ptr_conv.is_owned = false;
16579         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16580 }
16581
16582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16583         LDKChannelDetails this_ptr_conv;
16584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16585         this_ptr_conv.is_owned = false;
16586         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16587         return ret_val;
16588 }
16589
16590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16591         LDKChannelDetails this_ptr_conv;
16592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16593         this_ptr_conv.is_owned = false;
16594         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16595 }
16596
16597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16598         LDKChannelDetails this_ptr_conv;
16599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16600         this_ptr_conv.is_owned = false;
16601         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16602         return ret_val;
16603 }
16604
16605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16606         LDKChannelDetails this_ptr_conv;
16607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16608         this_ptr_conv.is_owned = false;
16609         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16610 }
16611
16612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16613         LDKChannelDetails this_ptr_conv;
16614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16615         this_ptr_conv.is_owned = false;
16616         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16617         return ret_val;
16618 }
16619
16620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16621         LDKChannelDetails this_ptr_conv;
16622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16623         this_ptr_conv.is_owned = false;
16624         ChannelDetails_set_is_public(&this_ptr_conv, val);
16625 }
16626
16627 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) {
16628         LDKThirtyTwoBytes channel_id_arg_ref;
16629         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16630         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16631         LDKChannelCounterparty counterparty_arg_conv;
16632         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16633         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16634         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16635         LDKOutPoint funding_txo_arg_conv;
16636         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16637         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16638         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16639         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16640         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16641         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16642         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16643         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);
16644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16646         uint64_t ret_ref = (uint64_t)ret_var.inner;
16647         if (ret_var.is_owned) {
16648                 ret_ref |= 1;
16649         }
16650         return ret_ref;
16651 }
16652
16653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16654         LDKChannelDetails orig_conv;
16655         orig_conv.inner = (void*)(orig & (~1));
16656         orig_conv.is_owned = false;
16657         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16660         uint64_t ret_ref = (uint64_t)ret_var.inner;
16661         if (ret_var.is_owned) {
16662                 ret_ref |= 1;
16663         }
16664         return ret_ref;
16665 }
16666
16667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16668         if ((this_ptr & 1) != 0) return;
16669         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16670         FREE((void*)this_ptr);
16671         PaymentSendFailure_free(this_ptr_conv);
16672 }
16673
16674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16675         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16676         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16677         *ret_copy = PaymentSendFailure_clone(orig_conv);
16678         uint64_t ret_ref = (uint64_t)ret_copy;
16679         return ret_ref;
16680 }
16681
16682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
16683         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
16684         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16685         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
16686         uint64_t ret_ref = (uint64_t)ret_copy;
16687         return ret_ref;
16688 }
16689
16690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
16691         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
16692         a_constr.datalen = (*env)->GetArrayLength(env, a);
16693         if (a_constr.datalen > 0)
16694                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16695         else
16696                 a_constr.data = NULL;
16697         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
16698         for (size_t w = 0; w < a_constr.datalen; w++) {
16699                 int64_t a_conv_22 = a_vals[w];
16700                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
16701                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
16702                 a_constr.data[w] = a_conv_22_conv;
16703         }
16704         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
16705         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16706         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
16707         uint64_t ret_ref = (uint64_t)ret_copy;
16708         return ret_ref;
16709 }
16710
16711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
16712         LDKCVec_APIErrorZ a_constr;
16713         a_constr.datalen = (*env)->GetArrayLength(env, a);
16714         if (a_constr.datalen > 0)
16715                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
16716         else
16717                 a_constr.data = NULL;
16718         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
16719         for (size_t k = 0; k < a_constr.datalen; k++) {
16720                 int64_t a_conv_10 = a_vals[k];
16721                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
16722                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
16723                 a_constr.data[k] = a_conv_10_conv;
16724         }
16725         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
16726         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16727         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
16728         uint64_t ret_ref = (uint64_t)ret_copy;
16729         return ret_ref;
16730 }
16731
16732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
16733         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
16734         a_constr.datalen = (*env)->GetArrayLength(env, a);
16735         if (a_constr.datalen > 0)
16736                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16737         else
16738                 a_constr.data = NULL;
16739         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
16740         for (size_t w = 0; w < a_constr.datalen; w++) {
16741                 int64_t a_conv_22 = a_vals[w];
16742                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
16743                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
16744                 a_constr.data[w] = a_conv_22_conv;
16745         }
16746         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
16747         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16748         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
16749         uint64_t ret_ref = (uint64_t)ret_copy;
16750         return ret_ref;
16751 }
16752
16753 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) {
16754         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16755         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
16756                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16757                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
16758         }
16759         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16760         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16761                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16762                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
16763         }
16764         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16765         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16766                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16767                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
16768         }
16769         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16770         if (logger_conv.free == LDKLogger_JCalls_free) {
16771                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16772                 LDKLogger_JCalls_cloned(&logger_conv);
16773         }
16774         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16775         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16776                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16777                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
16778         }
16779         LDKUserConfig config_conv;
16780         config_conv.inner = (void*)(config & (~1));
16781         config_conv.is_owned = (config & 1) || (config == 0);
16782         config_conv = UserConfig_clone(&config_conv);
16783         LDKChainParameters params_conv;
16784         params_conv.inner = (void*)(params & (~1));
16785         params_conv.is_owned = (params & 1) || (params == 0);
16786         params_conv = ChainParameters_clone(&params_conv);
16787         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16790         uint64_t ret_ref = (uint64_t)ret_var.inner;
16791         if (ret_var.is_owned) {
16792                 ret_ref |= 1;
16793         }
16794         return ret_ref;
16795 }
16796
16797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
16798         LDKChannelManager this_arg_conv;
16799         this_arg_conv.inner = (void*)(this_arg & (~1));
16800         this_arg_conv.is_owned = false;
16801         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16804         uint64_t ret_ref = (uint64_t)ret_var.inner;
16805         if (ret_var.is_owned) {
16806                 ret_ref |= 1;
16807         }
16808         return ret_ref;
16809 }
16810
16811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
16812         LDKChannelManager this_arg_conv;
16813         this_arg_conv.inner = (void*)(this_arg & (~1));
16814         this_arg_conv.is_owned = false;
16815         LDKPublicKey their_network_key_ref;
16816         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
16817         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
16818         LDKUserConfig override_config_conv;
16819         override_config_conv.inner = (void*)(override_config & (~1));
16820         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16821         override_config_conv = UserConfig_clone(&override_config_conv);
16822         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16823         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
16824         return (uint64_t)ret_conv;
16825 }
16826
16827 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16828         LDKChannelManager this_arg_conv;
16829         this_arg_conv.inner = (void*)(this_arg & (~1));
16830         this_arg_conv.is_owned = false;
16831         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16832         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16833         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16834         for (size_t q = 0; q < ret_var.datalen; q++) {
16835                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16836                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16837                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16838                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16839                 if (ret_conv_16_var.is_owned) {
16840                         ret_conv_16_ref |= 1;
16841                 }
16842                 ret_arr_ptr[q] = ret_conv_16_ref;
16843         }
16844         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16845         FREE(ret_var.data);
16846         return ret_arr;
16847 }
16848
16849 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16850         LDKChannelManager this_arg_conv;
16851         this_arg_conv.inner = (void*)(this_arg & (~1));
16852         this_arg_conv.is_owned = false;
16853         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16854         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16855         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16856         for (size_t q = 0; q < ret_var.datalen; q++) {
16857                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16858                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16859                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16860                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16861                 if (ret_conv_16_var.is_owned) {
16862                         ret_conv_16_ref |= 1;
16863                 }
16864                 ret_arr_ptr[q] = ret_conv_16_ref;
16865         }
16866         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16867         FREE(ret_var.data);
16868         return ret_arr;
16869 }
16870
16871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16872         LDKChannelManager this_arg_conv;
16873         this_arg_conv.inner = (void*)(this_arg & (~1));
16874         this_arg_conv.is_owned = false;
16875         unsigned char channel_id_arr[32];
16876         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16877         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16878         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16879         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16880         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16881         return (uint64_t)ret_conv;
16882 }
16883
16884 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) {
16885         LDKChannelManager this_arg_conv;
16886         this_arg_conv.inner = (void*)(this_arg & (~1));
16887         this_arg_conv.is_owned = false;
16888         unsigned char channel_id_arr[32];
16889         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16890         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16891         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16892         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16893         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16894         return (uint64_t)ret_conv;
16895 }
16896
16897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16898         LDKChannelManager this_arg_conv;
16899         this_arg_conv.inner = (void*)(this_arg & (~1));
16900         this_arg_conv.is_owned = false;
16901         ChannelManager_force_close_all_channels(&this_arg_conv);
16902 }
16903
16904 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) {
16905         LDKChannelManager this_arg_conv;
16906         this_arg_conv.inner = (void*)(this_arg & (~1));
16907         this_arg_conv.is_owned = false;
16908         LDKRoute route_conv;
16909         route_conv.inner = (void*)(route & (~1));
16910         route_conv.is_owned = false;
16911         LDKThirtyTwoBytes payment_hash_ref;
16912         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16913         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16914         LDKThirtyTwoBytes payment_secret_ref;
16915         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
16916         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
16917         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16918         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16919         return (uint64_t)ret_conv;
16920 }
16921
16922 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) {
16923         LDKChannelManager this_arg_conv;
16924         this_arg_conv.inner = (void*)(this_arg & (~1));
16925         this_arg_conv.is_owned = false;
16926         unsigned char temporary_channel_id_arr[32];
16927         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
16928         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
16929         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16930         LDKTransaction funding_transaction_ref;
16931         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
16932         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16933         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
16934         funding_transaction_ref.data_is_owned = true;
16935         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16936         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16937         return (uint64_t)ret_conv;
16938 }
16939
16940 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) {
16941         LDKChannelManager this_arg_conv;
16942         this_arg_conv.inner = (void*)(this_arg & (~1));
16943         this_arg_conv.is_owned = false;
16944         LDKThreeBytes rgb_ref;
16945         CHECK((*env)->GetArrayLength(env, rgb) == 3);
16946         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
16947         LDKThirtyTwoBytes alias_ref;
16948         CHECK((*env)->GetArrayLength(env, alias) == 32);
16949         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
16950         LDKCVec_NetAddressZ addresses_constr;
16951         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
16952         if (addresses_constr.datalen > 0)
16953                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16954         else
16955                 addresses_constr.data = NULL;
16956         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
16957         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16958                 int64_t addresses_conv_12 = addresses_vals[m];
16959                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16960                 addresses_constr.data[m] = addresses_conv_12_conv;
16961         }
16962         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
16963         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16964 }
16965
16966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
16967         LDKChannelManager this_arg_conv;
16968         this_arg_conv.inner = (void*)(this_arg & (~1));
16969         this_arg_conv.is_owned = false;
16970         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16971 }
16972
16973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
16974         LDKChannelManager this_arg_conv;
16975         this_arg_conv.inner = (void*)(this_arg & (~1));
16976         this_arg_conv.is_owned = false;
16977         ChannelManager_timer_tick_occurred(&this_arg_conv);
16978 }
16979
16980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
16981         LDKChannelManager this_arg_conv;
16982         this_arg_conv.inner = (void*)(this_arg & (~1));
16983         this_arg_conv.is_owned = false;
16984         unsigned char payment_hash_arr[32];
16985         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16986         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
16987         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16988         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16989         return ret_val;
16990 }
16991
16992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
16993         LDKChannelManager this_arg_conv;
16994         this_arg_conv.inner = (void*)(this_arg & (~1));
16995         this_arg_conv.is_owned = false;
16996         LDKThirtyTwoBytes payment_preimage_ref;
16997         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16998         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16999         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
17000         return ret_val;
17001 }
17002
17003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17004         LDKChannelManager this_arg_conv;
17005         this_arg_conv.inner = (void*)(this_arg & (~1));
17006         this_arg_conv.is_owned = false;
17007         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17008         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
17009         return ret_arr;
17010 }
17011
17012 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) {
17013         LDKChannelManager this_arg_conv;
17014         this_arg_conv.inner = (void*)(this_arg & (~1));
17015         this_arg_conv.is_owned = false;
17016         LDKOutPoint funding_txo_conv;
17017         funding_txo_conv.inner = (void*)(funding_txo & (~1));
17018         funding_txo_conv.is_owned = false;
17019         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
17020 }
17021
17022 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) {
17023         LDKChannelManager this_arg_conv;
17024         this_arg_conv.inner = (void*)(this_arg & (~1));
17025         this_arg_conv.is_owned = false;
17026         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17027         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17028         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
17029         return (uint64_t)ret_ref;
17030 }
17031
17032 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) {
17033         LDKChannelManager this_arg_conv;
17034         this_arg_conv.inner = (void*)(this_arg & (~1));
17035         this_arg_conv.is_owned = false;
17036         LDKThirtyTwoBytes payment_hash_ref;
17037         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17038         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17039         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17040         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17041         *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);
17042         return (uint64_t)ret_conv;
17043 }
17044
17045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17046         LDKChannelManager this_arg_conv;
17047         this_arg_conv.inner = (void*)(this_arg & (~1));
17048         this_arg_conv.is_owned = false;
17049         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17050         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
17051         return (uint64_t)ret;
17052 }
17053
17054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17055         LDKChannelManager this_arg_conv;
17056         this_arg_conv.inner = (void*)(this_arg & (~1));
17057         this_arg_conv.is_owned = false;
17058         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
17059         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
17060         return (uint64_t)ret;
17061 }
17062
17063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
17064         LDKChannelManager this_arg_conv;
17065         this_arg_conv.inner = (void*)(this_arg & (~1));
17066         this_arg_conv.is_owned = false;
17067         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
17068         *ret = ChannelManager_as_Listen(&this_arg_conv);
17069         return (uint64_t)ret;
17070 }
17071
17072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
17073         LDKChannelManager this_arg_conv;
17074         this_arg_conv.inner = (void*)(this_arg & (~1));
17075         this_arg_conv.is_owned = false;
17076         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
17077         *ret = ChannelManager_as_Confirm(&this_arg_conv);
17078         return (uint64_t)ret;
17079 }
17080
17081 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) {
17082         LDKChannelManager this_arg_conv;
17083         this_arg_conv.inner = (void*)(this_arg & (~1));
17084         this_arg_conv.is_owned = false;
17085         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
17086         return ret_val;
17087 }
17088
17089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
17090         LDKChannelManager this_arg_conv;
17091         this_arg_conv.inner = (void*)(this_arg & (~1));
17092         this_arg_conv.is_owned = false;
17093         ChannelManager_await_persistable_update(&this_arg_conv);
17094 }
17095
17096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
17097         LDKChannelManager this_arg_conv;
17098         this_arg_conv.inner = (void*)(this_arg & (~1));
17099         this_arg_conv.is_owned = false;
17100         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
17101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17103         uint64_t ret_ref = (uint64_t)ret_var.inner;
17104         if (ret_var.is_owned) {
17105                 ret_ref |= 1;
17106         }
17107         return ret_ref;
17108 }
17109
17110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17111         LDKChannelManager this_arg_conv;
17112         this_arg_conv.inner = (void*)(this_arg & (~1));
17113         this_arg_conv.is_owned = false;
17114         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
17115         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
17116         return (uint64_t)ret;
17117 }
17118
17119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
17120         LDKChannelManager obj_conv;
17121         obj_conv.inner = (void*)(obj & (~1));
17122         obj_conv.is_owned = false;
17123         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
17124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17126         CVec_u8Z_free(ret_var);
17127         return ret_arr;
17128 }
17129
17130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17131         LDKChannelManagerReadArgs this_obj_conv;
17132         this_obj_conv.inner = (void*)(this_obj & (~1));
17133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17134         ChannelManagerReadArgs_free(this_obj_conv);
17135 }
17136
17137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
17138         LDKChannelManagerReadArgs this_ptr_conv;
17139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17140         this_ptr_conv.is_owned = false;
17141         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
17142         return ret_ret;
17143 }
17144
17145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17146         LDKChannelManagerReadArgs this_ptr_conv;
17147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17148         this_ptr_conv.is_owned = false;
17149         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
17150         if (val_conv.free == LDKKeysInterface_JCalls_free) {
17151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17152                 LDKKeysInterface_JCalls_cloned(&val_conv);
17153         }
17154         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
17155 }
17156
17157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
17158         LDKChannelManagerReadArgs this_ptr_conv;
17159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17160         this_ptr_conv.is_owned = false;
17161         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
17162         return ret_ret;
17163 }
17164
17165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17166         LDKChannelManagerReadArgs this_ptr_conv;
17167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17168         this_ptr_conv.is_owned = false;
17169         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
17170         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
17171                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17172                 LDKFeeEstimator_JCalls_cloned(&val_conv);
17173         }
17174         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
17175 }
17176
17177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
17178         LDKChannelManagerReadArgs this_ptr_conv;
17179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17180         this_ptr_conv.is_owned = false;
17181         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
17182         return ret_ret;
17183 }
17184
17185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17186         LDKChannelManagerReadArgs this_ptr_conv;
17187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17188         this_ptr_conv.is_owned = false;
17189         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
17190         if (val_conv.free == LDKWatch_JCalls_free) {
17191                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17192                 LDKWatch_JCalls_cloned(&val_conv);
17193         }
17194         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
17195 }
17196
17197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
17198         LDKChannelManagerReadArgs this_ptr_conv;
17199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17200         this_ptr_conv.is_owned = false;
17201         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
17202         return ret_ret;
17203 }
17204
17205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17206         LDKChannelManagerReadArgs this_ptr_conv;
17207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17208         this_ptr_conv.is_owned = false;
17209         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
17210         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
17211                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17212                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
17213         }
17214         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
17215 }
17216
17217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
17218         LDKChannelManagerReadArgs this_ptr_conv;
17219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17220         this_ptr_conv.is_owned = false;
17221         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
17222         return ret_ret;
17223 }
17224
17225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17226         LDKChannelManagerReadArgs this_ptr_conv;
17227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17228         this_ptr_conv.is_owned = false;
17229         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
17230         if (val_conv.free == LDKLogger_JCalls_free) {
17231                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17232                 LDKLogger_JCalls_cloned(&val_conv);
17233         }
17234         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
17235 }
17236
17237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
17238         LDKChannelManagerReadArgs this_ptr_conv;
17239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17240         this_ptr_conv.is_owned = false;
17241         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
17242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17244         uint64_t ret_ref = (uint64_t)ret_var.inner;
17245         if (ret_var.is_owned) {
17246                 ret_ref |= 1;
17247         }
17248         return ret_ref;
17249 }
17250
17251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17252         LDKChannelManagerReadArgs this_ptr_conv;
17253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17254         this_ptr_conv.is_owned = false;
17255         LDKUserConfig val_conv;
17256         val_conv.inner = (void*)(val & (~1));
17257         val_conv.is_owned = (val & 1) || (val == 0);
17258         val_conv = UserConfig_clone(&val_conv);
17259         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
17260 }
17261
17262 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) {
17263         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
17264         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
17265                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17266                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
17267         }
17268         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17269         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17270                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17271                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17272         }
17273         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
17274         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
17275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17276                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
17277         }
17278         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
17279         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17280                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17281                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
17282         }
17283         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17284         if (logger_conv.free == LDKLogger_JCalls_free) {
17285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17286                 LDKLogger_JCalls_cloned(&logger_conv);
17287         }
17288         LDKUserConfig default_config_conv;
17289         default_config_conv.inner = (void*)(default_config & (~1));
17290         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
17291         default_config_conv = UserConfig_clone(&default_config_conv);
17292         LDKCVec_ChannelMonitorZ channel_monitors_constr;
17293         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
17294         if (channel_monitors_constr.datalen > 0)
17295                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
17296         else
17297                 channel_monitors_constr.data = NULL;
17298         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
17299         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
17300                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
17301                 LDKChannelMonitor channel_monitors_conv_16_conv;
17302                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
17303                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
17304                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
17305         }
17306         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
17307         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);
17308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17310         uint64_t ret_ref = (uint64_t)ret_var.inner;
17311         if (ret_var.is_owned) {
17312                 ret_ref |= 1;
17313         }
17314         return ret_ref;
17315 }
17316
17317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
17318         LDKu8slice ser_ref;
17319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17321         LDKChannelManagerReadArgs arg_conv;
17322         arg_conv.inner = (void*)(arg & (~1));
17323         arg_conv.is_owned = (arg & 1) || (arg == 0);
17324         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
17325         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
17326         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
17327         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17328         return (uint64_t)ret_conv;
17329 }
17330
17331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17332         LDKDecodeError this_obj_conv;
17333         this_obj_conv.inner = (void*)(this_obj & (~1));
17334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17335         DecodeError_free(this_obj_conv);
17336 }
17337
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17339         LDKDecodeError orig_conv;
17340         orig_conv.inner = (void*)(orig & (~1));
17341         orig_conv.is_owned = false;
17342         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
17343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17345         uint64_t ret_ref = (uint64_t)ret_var.inner;
17346         if (ret_var.is_owned) {
17347                 ret_ref |= 1;
17348         }
17349         return ret_ref;
17350 }
17351
17352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17353         LDKInit this_obj_conv;
17354         this_obj_conv.inner = (void*)(this_obj & (~1));
17355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17356         Init_free(this_obj_conv);
17357 }
17358
17359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
17360         LDKInit this_ptr_conv;
17361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17362         this_ptr_conv.is_owned = false;
17363         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
17364         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17365         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17366         uint64_t ret_ref = (uint64_t)ret_var.inner;
17367         if (ret_var.is_owned) {
17368                 ret_ref |= 1;
17369         }
17370         return ret_ref;
17371 }
17372
17373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17374         LDKInit this_ptr_conv;
17375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17376         this_ptr_conv.is_owned = false;
17377         LDKInitFeatures val_conv;
17378         val_conv.inner = (void*)(val & (~1));
17379         val_conv.is_owned = (val & 1) || (val == 0);
17380         val_conv = InitFeatures_clone(&val_conv);
17381         Init_set_features(&this_ptr_conv, val_conv);
17382 }
17383
17384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
17385         LDKInitFeatures features_arg_conv;
17386         features_arg_conv.inner = (void*)(features_arg & (~1));
17387         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17388         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17389         LDKInit ret_var = Init_new(features_arg_conv);
17390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17392         uint64_t ret_ref = (uint64_t)ret_var.inner;
17393         if (ret_var.is_owned) {
17394                 ret_ref |= 1;
17395         }
17396         return ret_ref;
17397 }
17398
17399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17400         LDKInit orig_conv;
17401         orig_conv.inner = (void*)(orig & (~1));
17402         orig_conv.is_owned = false;
17403         LDKInit ret_var = Init_clone(&orig_conv);
17404         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17405         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17406         uint64_t ret_ref = (uint64_t)ret_var.inner;
17407         if (ret_var.is_owned) {
17408                 ret_ref |= 1;
17409         }
17410         return ret_ref;
17411 }
17412
17413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17414         LDKErrorMessage this_obj_conv;
17415         this_obj_conv.inner = (void*)(this_obj & (~1));
17416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17417         ErrorMessage_free(this_obj_conv);
17418 }
17419
17420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17421         LDKErrorMessage this_ptr_conv;
17422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17423         this_ptr_conv.is_owned = false;
17424         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17425         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
17426         return ret_arr;
17427 }
17428
17429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17430         LDKErrorMessage this_ptr_conv;
17431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17432         this_ptr_conv.is_owned = false;
17433         LDKThirtyTwoBytes val_ref;
17434         CHECK((*env)->GetArrayLength(env, val) == 32);
17435         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17436         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
17437 }
17438
17439 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
17440         LDKErrorMessage this_ptr_conv;
17441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17442         this_ptr_conv.is_owned = false;
17443         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
17444         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
17445         Str_free(ret_str);
17446         return ret_conv;
17447 }
17448
17449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
17450         LDKErrorMessage this_ptr_conv;
17451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17452         this_ptr_conv.is_owned = false;
17453         LDKStr val_conv = java_to_owned_str(env, val);
17454         ErrorMessage_set_data(&this_ptr_conv, val_conv);
17455 }
17456
17457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
17458         LDKThirtyTwoBytes channel_id_arg_ref;
17459         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17460         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17461         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
17462         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
17463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17465         uint64_t ret_ref = (uint64_t)ret_var.inner;
17466         if (ret_var.is_owned) {
17467                 ret_ref |= 1;
17468         }
17469         return ret_ref;
17470 }
17471
17472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17473         LDKErrorMessage orig_conv;
17474         orig_conv.inner = (void*)(orig & (~1));
17475         orig_conv.is_owned = false;
17476         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
17477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17479         uint64_t ret_ref = (uint64_t)ret_var.inner;
17480         if (ret_var.is_owned) {
17481                 ret_ref |= 1;
17482         }
17483         return ret_ref;
17484 }
17485
17486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17487         LDKPing this_obj_conv;
17488         this_obj_conv.inner = (void*)(this_obj & (~1));
17489         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17490         Ping_free(this_obj_conv);
17491 }
17492
17493 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17494         LDKPing this_ptr_conv;
17495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17496         this_ptr_conv.is_owned = false;
17497         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17498         return ret_val;
17499 }
17500
17501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17502         LDKPing this_ptr_conv;
17503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17504         this_ptr_conv.is_owned = false;
17505         Ping_set_ponglen(&this_ptr_conv, val);
17506 }
17507
17508 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17509         LDKPing this_ptr_conv;
17510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17511         this_ptr_conv.is_owned = false;
17512         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17513         return ret_val;
17514 }
17515
17516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17517         LDKPing this_ptr_conv;
17518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17519         this_ptr_conv.is_owned = false;
17520         Ping_set_byteslen(&this_ptr_conv, val);
17521 }
17522
17523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
17524         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17527         uint64_t ret_ref = (uint64_t)ret_var.inner;
17528         if (ret_var.is_owned) {
17529                 ret_ref |= 1;
17530         }
17531         return ret_ref;
17532 }
17533
17534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17535         LDKPing orig_conv;
17536         orig_conv.inner = (void*)(orig & (~1));
17537         orig_conv.is_owned = false;
17538         LDKPing ret_var = Ping_clone(&orig_conv);
17539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17541         uint64_t ret_ref = (uint64_t)ret_var.inner;
17542         if (ret_var.is_owned) {
17543                 ret_ref |= 1;
17544         }
17545         return ret_ref;
17546 }
17547
17548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17549         LDKPong this_obj_conv;
17550         this_obj_conv.inner = (void*)(this_obj & (~1));
17551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17552         Pong_free(this_obj_conv);
17553 }
17554
17555 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17556         LDKPong this_ptr_conv;
17557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17558         this_ptr_conv.is_owned = false;
17559         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17560         return ret_val;
17561 }
17562
17563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17564         LDKPong this_ptr_conv;
17565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17566         this_ptr_conv.is_owned = false;
17567         Pong_set_byteslen(&this_ptr_conv, val);
17568 }
17569
17570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
17571         LDKPong ret_var = Pong_new(byteslen_arg);
17572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17574         uint64_t ret_ref = (uint64_t)ret_var.inner;
17575         if (ret_var.is_owned) {
17576                 ret_ref |= 1;
17577         }
17578         return ret_ref;
17579 }
17580
17581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17582         LDKPong orig_conv;
17583         orig_conv.inner = (void*)(orig & (~1));
17584         orig_conv.is_owned = false;
17585         LDKPong ret_var = Pong_clone(&orig_conv);
17586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17588         uint64_t ret_ref = (uint64_t)ret_var.inner;
17589         if (ret_var.is_owned) {
17590                 ret_ref |= 1;
17591         }
17592         return ret_ref;
17593 }
17594
17595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17596         LDKOpenChannel this_obj_conv;
17597         this_obj_conv.inner = (void*)(this_obj & (~1));
17598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17599         OpenChannel_free(this_obj_conv);
17600 }
17601
17602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17603         LDKOpenChannel this_ptr_conv;
17604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17605         this_ptr_conv.is_owned = false;
17606         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17607         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17608         return ret_arr;
17609 }
17610
17611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17612         LDKOpenChannel this_ptr_conv;
17613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17614         this_ptr_conv.is_owned = false;
17615         LDKThirtyTwoBytes val_ref;
17616         CHECK((*env)->GetArrayLength(env, val) == 32);
17617         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17618         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17619 }
17620
17621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17622         LDKOpenChannel this_ptr_conv;
17623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17624         this_ptr_conv.is_owned = false;
17625         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
17627         return ret_arr;
17628 }
17629
17630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17631         LDKOpenChannel this_ptr_conv;
17632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17633         this_ptr_conv.is_owned = false;
17634         LDKThirtyTwoBytes val_ref;
17635         CHECK((*env)->GetArrayLength(env, val) == 32);
17636         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17637         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17638 }
17639
17640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17641         LDKOpenChannel this_ptr_conv;
17642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17643         this_ptr_conv.is_owned = false;
17644         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17645         return ret_val;
17646 }
17647
17648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17649         LDKOpenChannel this_ptr_conv;
17650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17651         this_ptr_conv.is_owned = false;
17652         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17653 }
17654
17655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17656         LDKOpenChannel this_ptr_conv;
17657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17658         this_ptr_conv.is_owned = false;
17659         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17660         return ret_val;
17661 }
17662
17663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17664         LDKOpenChannel this_ptr_conv;
17665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17666         this_ptr_conv.is_owned = false;
17667         OpenChannel_set_push_msat(&this_ptr_conv, val);
17668 }
17669
17670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17671         LDKOpenChannel this_ptr_conv;
17672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17673         this_ptr_conv.is_owned = false;
17674         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17675         return ret_val;
17676 }
17677
17678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17679         LDKOpenChannel this_ptr_conv;
17680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17681         this_ptr_conv.is_owned = false;
17682         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17683 }
17684
17685 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) {
17686         LDKOpenChannel this_ptr_conv;
17687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17688         this_ptr_conv.is_owned = false;
17689         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17690         return ret_val;
17691 }
17692
17693 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) {
17694         LDKOpenChannel this_ptr_conv;
17695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17696         this_ptr_conv.is_owned = false;
17697         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17698 }
17699
17700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17701         LDKOpenChannel this_ptr_conv;
17702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17703         this_ptr_conv.is_owned = false;
17704         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17705         return ret_val;
17706 }
17707
17708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17709         LDKOpenChannel this_ptr_conv;
17710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17711         this_ptr_conv.is_owned = false;
17712         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17713 }
17714
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17716         LDKOpenChannel this_ptr_conv;
17717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17718         this_ptr_conv.is_owned = false;
17719         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17720         return ret_val;
17721 }
17722
17723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17724         LDKOpenChannel this_ptr_conv;
17725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17726         this_ptr_conv.is_owned = false;
17727         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17728 }
17729
17730 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17731         LDKOpenChannel this_ptr_conv;
17732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17733         this_ptr_conv.is_owned = false;
17734         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17735         return ret_val;
17736 }
17737
17738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17739         LDKOpenChannel this_ptr_conv;
17740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17741         this_ptr_conv.is_owned = false;
17742         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17743 }
17744
17745 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17746         LDKOpenChannel this_ptr_conv;
17747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17748         this_ptr_conv.is_owned = false;
17749         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17750         return ret_val;
17751 }
17752
17753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17754         LDKOpenChannel this_ptr_conv;
17755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17756         this_ptr_conv.is_owned = false;
17757         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17758 }
17759
17760 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17761         LDKOpenChannel this_ptr_conv;
17762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17763         this_ptr_conv.is_owned = false;
17764         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17765         return ret_val;
17766 }
17767
17768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17769         LDKOpenChannel this_ptr_conv;
17770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17771         this_ptr_conv.is_owned = false;
17772         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17773 }
17774
17775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17776         LDKOpenChannel this_ptr_conv;
17777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17778         this_ptr_conv.is_owned = false;
17779         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17781         return ret_arr;
17782 }
17783
17784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17785         LDKOpenChannel this_ptr_conv;
17786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17787         this_ptr_conv.is_owned = false;
17788         LDKPublicKey val_ref;
17789         CHECK((*env)->GetArrayLength(env, val) == 33);
17790         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17791         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17792 }
17793
17794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17795         LDKOpenChannel this_ptr_conv;
17796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17797         this_ptr_conv.is_owned = false;
17798         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17800         return ret_arr;
17801 }
17802
17803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17804         LDKOpenChannel this_ptr_conv;
17805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17806         this_ptr_conv.is_owned = false;
17807         LDKPublicKey val_ref;
17808         CHECK((*env)->GetArrayLength(env, val) == 33);
17809         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17810         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17811 }
17812
17813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17814         LDKOpenChannel this_ptr_conv;
17815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17816         this_ptr_conv.is_owned = false;
17817         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
17819         return ret_arr;
17820 }
17821
17822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17823         LDKOpenChannel this_ptr_conv;
17824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17825         this_ptr_conv.is_owned = false;
17826         LDKPublicKey val_ref;
17827         CHECK((*env)->GetArrayLength(env, val) == 33);
17828         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17829         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17830 }
17831
17832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17833         LDKOpenChannel this_ptr_conv;
17834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17835         this_ptr_conv.is_owned = false;
17836         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17838         return ret_arr;
17839 }
17840
17841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17842         LDKOpenChannel this_ptr_conv;
17843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17844         this_ptr_conv.is_owned = false;
17845         LDKPublicKey val_ref;
17846         CHECK((*env)->GetArrayLength(env, val) == 33);
17847         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17848         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17849 }
17850
17851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17852         LDKOpenChannel this_ptr_conv;
17853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17854         this_ptr_conv.is_owned = false;
17855         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17857         return ret_arr;
17858 }
17859
17860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17861         LDKOpenChannel this_ptr_conv;
17862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17863         this_ptr_conv.is_owned = false;
17864         LDKPublicKey val_ref;
17865         CHECK((*env)->GetArrayLength(env, val) == 33);
17866         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17867         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17868 }
17869
17870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17871         LDKOpenChannel this_ptr_conv;
17872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17873         this_ptr_conv.is_owned = false;
17874         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17876         return ret_arr;
17877 }
17878
17879 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) {
17880         LDKOpenChannel this_ptr_conv;
17881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17882         this_ptr_conv.is_owned = false;
17883         LDKPublicKey val_ref;
17884         CHECK((*env)->GetArrayLength(env, val) == 33);
17885         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17886         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17887 }
17888
17889 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
17890         LDKOpenChannel this_ptr_conv;
17891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17892         this_ptr_conv.is_owned = false;
17893         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17894         return ret_val;
17895 }
17896
17897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
17898         LDKOpenChannel this_ptr_conv;
17899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17900         this_ptr_conv.is_owned = false;
17901         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17902 }
17903
17904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17905         LDKOpenChannel orig_conv;
17906         orig_conv.inner = (void*)(orig & (~1));
17907         orig_conv.is_owned = false;
17908         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17909         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17910         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17911         uint64_t ret_ref = (uint64_t)ret_var.inner;
17912         if (ret_var.is_owned) {
17913                 ret_ref |= 1;
17914         }
17915         return ret_ref;
17916 }
17917
17918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17919         LDKAcceptChannel this_obj_conv;
17920         this_obj_conv.inner = (void*)(this_obj & (~1));
17921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17922         AcceptChannel_free(this_obj_conv);
17923 }
17924
17925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17926         LDKAcceptChannel this_ptr_conv;
17927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17928         this_ptr_conv.is_owned = false;
17929         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
17931         return ret_arr;
17932 }
17933
17934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17935         LDKAcceptChannel this_ptr_conv;
17936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17937         this_ptr_conv.is_owned = false;
17938         LDKThirtyTwoBytes val_ref;
17939         CHECK((*env)->GetArrayLength(env, val) == 32);
17940         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17941         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17942 }
17943
17944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17945         LDKAcceptChannel this_ptr_conv;
17946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17947         this_ptr_conv.is_owned = false;
17948         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17949         return ret_val;
17950 }
17951
17952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17953         LDKAcceptChannel this_ptr_conv;
17954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17955         this_ptr_conv.is_owned = false;
17956         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17957 }
17958
17959 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) {
17960         LDKAcceptChannel this_ptr_conv;
17961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17962         this_ptr_conv.is_owned = false;
17963         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17964         return ret_val;
17965 }
17966
17967 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) {
17968         LDKAcceptChannel this_ptr_conv;
17969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17970         this_ptr_conv.is_owned = false;
17971         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17972 }
17973
17974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17975         LDKAcceptChannel this_ptr_conv;
17976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17977         this_ptr_conv.is_owned = false;
17978         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17979         return ret_val;
17980 }
17981
17982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17983         LDKAcceptChannel this_ptr_conv;
17984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17985         this_ptr_conv.is_owned = false;
17986         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17987 }
17988
17989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17990         LDKAcceptChannel this_ptr_conv;
17991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17992         this_ptr_conv.is_owned = false;
17993         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17994         return ret_val;
17995 }
17996
17997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17998         LDKAcceptChannel this_ptr_conv;
17999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18000         this_ptr_conv.is_owned = false;
18001         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
18002 }
18003
18004 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
18005         LDKAcceptChannel this_ptr_conv;
18006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18007         this_ptr_conv.is_owned = false;
18008         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
18009         return ret_val;
18010 }
18011
18012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18013         LDKAcceptChannel this_ptr_conv;
18014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18015         this_ptr_conv.is_owned = false;
18016         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
18017 }
18018
18019 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18020         LDKAcceptChannel this_ptr_conv;
18021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18022         this_ptr_conv.is_owned = false;
18023         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
18024         return ret_val;
18025 }
18026
18027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18028         LDKAcceptChannel this_ptr_conv;
18029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18030         this_ptr_conv.is_owned = false;
18031         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
18032 }
18033
18034 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
18035         LDKAcceptChannel this_ptr_conv;
18036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18037         this_ptr_conv.is_owned = false;
18038         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
18039         return ret_val;
18040 }
18041
18042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18043         LDKAcceptChannel this_ptr_conv;
18044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18045         this_ptr_conv.is_owned = false;
18046         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
18047 }
18048
18049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18050         LDKAcceptChannel this_ptr_conv;
18051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18052         this_ptr_conv.is_owned = false;
18053         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18054         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
18055         return ret_arr;
18056 }
18057
18058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18059         LDKAcceptChannel this_ptr_conv;
18060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18061         this_ptr_conv.is_owned = false;
18062         LDKPublicKey val_ref;
18063         CHECK((*env)->GetArrayLength(env, val) == 33);
18064         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18065         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
18066 }
18067
18068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18069         LDKAcceptChannel this_ptr_conv;
18070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18071         this_ptr_conv.is_owned = false;
18072         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18073         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18074         return ret_arr;
18075 }
18076
18077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18078         LDKAcceptChannel this_ptr_conv;
18079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18080         this_ptr_conv.is_owned = false;
18081         LDKPublicKey val_ref;
18082         CHECK((*env)->GetArrayLength(env, val) == 33);
18083         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18084         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
18085 }
18086
18087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18088         LDKAcceptChannel this_ptr_conv;
18089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18090         this_ptr_conv.is_owned = false;
18091         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18092         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
18093         return ret_arr;
18094 }
18095
18096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18097         LDKAcceptChannel this_ptr_conv;
18098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18099         this_ptr_conv.is_owned = false;
18100         LDKPublicKey val_ref;
18101         CHECK((*env)->GetArrayLength(env, val) == 33);
18102         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18103         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
18104 }
18105
18106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18107         LDKAcceptChannel this_ptr_conv;
18108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18109         this_ptr_conv.is_owned = false;
18110         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18111         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18112         return ret_arr;
18113 }
18114
18115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18116         LDKAcceptChannel this_ptr_conv;
18117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18118         this_ptr_conv.is_owned = false;
18119         LDKPublicKey val_ref;
18120         CHECK((*env)->GetArrayLength(env, val) == 33);
18121         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18122         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18123 }
18124
18125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18126         LDKAcceptChannel this_ptr_conv;
18127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18128         this_ptr_conv.is_owned = false;
18129         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18130         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18131         return ret_arr;
18132 }
18133
18134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18135         LDKAcceptChannel this_ptr_conv;
18136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18137         this_ptr_conv.is_owned = false;
18138         LDKPublicKey val_ref;
18139         CHECK((*env)->GetArrayLength(env, val) == 33);
18140         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18141         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
18142 }
18143
18144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18145         LDKAcceptChannel this_ptr_conv;
18146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18147         this_ptr_conv.is_owned = false;
18148         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
18150         return ret_arr;
18151 }
18152
18153 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) {
18154         LDKAcceptChannel this_ptr_conv;
18155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18156         this_ptr_conv.is_owned = false;
18157         LDKPublicKey val_ref;
18158         CHECK((*env)->GetArrayLength(env, val) == 33);
18159         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18160         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
18161 }
18162
18163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18164         LDKAcceptChannel orig_conv;
18165         orig_conv.inner = (void*)(orig & (~1));
18166         orig_conv.is_owned = false;
18167         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
18168         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18169         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18170         uint64_t ret_ref = (uint64_t)ret_var.inner;
18171         if (ret_var.is_owned) {
18172                 ret_ref |= 1;
18173         }
18174         return ret_ref;
18175 }
18176
18177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18178         LDKFundingCreated this_obj_conv;
18179         this_obj_conv.inner = (void*)(this_obj & (~1));
18180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18181         FundingCreated_free(this_obj_conv);
18182 }
18183
18184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18185         LDKFundingCreated this_ptr_conv;
18186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18187         this_ptr_conv.is_owned = false;
18188         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
18190         return ret_arr;
18191 }
18192
18193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18194         LDKFundingCreated this_ptr_conv;
18195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18196         this_ptr_conv.is_owned = false;
18197         LDKThirtyTwoBytes val_ref;
18198         CHECK((*env)->GetArrayLength(env, val) == 32);
18199         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18200         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
18201 }
18202
18203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18204         LDKFundingCreated this_ptr_conv;
18205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18206         this_ptr_conv.is_owned = false;
18207         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18208         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
18209         return ret_arr;
18210 }
18211
18212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18213         LDKFundingCreated this_ptr_conv;
18214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18215         this_ptr_conv.is_owned = false;
18216         LDKThirtyTwoBytes val_ref;
18217         CHECK((*env)->GetArrayLength(env, val) == 32);
18218         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18219         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
18220 }
18221
18222 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18223         LDKFundingCreated this_ptr_conv;
18224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18225         this_ptr_conv.is_owned = false;
18226         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
18227         return ret_val;
18228 }
18229
18230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18231         LDKFundingCreated this_ptr_conv;
18232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18233         this_ptr_conv.is_owned = false;
18234         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
18235 }
18236
18237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18238         LDKFundingCreated this_ptr_conv;
18239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18240         this_ptr_conv.is_owned = false;
18241         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
18243         return ret_arr;
18244 }
18245
18246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18247         LDKFundingCreated this_ptr_conv;
18248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18249         this_ptr_conv.is_owned = false;
18250         LDKSignature val_ref;
18251         CHECK((*env)->GetArrayLength(env, val) == 64);
18252         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18253         FundingCreated_set_signature(&this_ptr_conv, val_ref);
18254 }
18255
18256 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) {
18257         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
18258         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
18259         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
18260         LDKThirtyTwoBytes funding_txid_arg_ref;
18261         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
18262         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
18263         LDKSignature signature_arg_ref;
18264         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18265         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18266         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
18267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18269         uint64_t ret_ref = (uint64_t)ret_var.inner;
18270         if (ret_var.is_owned) {
18271                 ret_ref |= 1;
18272         }
18273         return ret_ref;
18274 }
18275
18276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18277         LDKFundingCreated orig_conv;
18278         orig_conv.inner = (void*)(orig & (~1));
18279         orig_conv.is_owned = false;
18280         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
18281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18283         uint64_t ret_ref = (uint64_t)ret_var.inner;
18284         if (ret_var.is_owned) {
18285                 ret_ref |= 1;
18286         }
18287         return ret_ref;
18288 }
18289
18290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18291         LDKFundingSigned this_obj_conv;
18292         this_obj_conv.inner = (void*)(this_obj & (~1));
18293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18294         FundingSigned_free(this_obj_conv);
18295 }
18296
18297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18298         LDKFundingSigned this_ptr_conv;
18299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18300         this_ptr_conv.is_owned = false;
18301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
18303         return ret_arr;
18304 }
18305
18306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18307         LDKFundingSigned this_ptr_conv;
18308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18309         this_ptr_conv.is_owned = false;
18310         LDKThirtyTwoBytes val_ref;
18311         CHECK((*env)->GetArrayLength(env, val) == 32);
18312         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18313         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
18314 }
18315
18316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18317         LDKFundingSigned this_ptr_conv;
18318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18319         this_ptr_conv.is_owned = false;
18320         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
18322         return ret_arr;
18323 }
18324
18325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18326         LDKFundingSigned this_ptr_conv;
18327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18328         this_ptr_conv.is_owned = false;
18329         LDKSignature val_ref;
18330         CHECK((*env)->GetArrayLength(env, val) == 64);
18331         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18332         FundingSigned_set_signature(&this_ptr_conv, val_ref);
18333 }
18334
18335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
18336         LDKThirtyTwoBytes channel_id_arg_ref;
18337         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18338         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18339         LDKSignature signature_arg_ref;
18340         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18341         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18342         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
18343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18345         uint64_t ret_ref = (uint64_t)ret_var.inner;
18346         if (ret_var.is_owned) {
18347                 ret_ref |= 1;
18348         }
18349         return ret_ref;
18350 }
18351
18352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18353         LDKFundingSigned orig_conv;
18354         orig_conv.inner = (void*)(orig & (~1));
18355         orig_conv.is_owned = false;
18356         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
18357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18359         uint64_t ret_ref = (uint64_t)ret_var.inner;
18360         if (ret_var.is_owned) {
18361                 ret_ref |= 1;
18362         }
18363         return ret_ref;
18364 }
18365
18366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18367         LDKFundingLocked this_obj_conv;
18368         this_obj_conv.inner = (void*)(this_obj & (~1));
18369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18370         FundingLocked_free(this_obj_conv);
18371 }
18372
18373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18374         LDKFundingLocked this_ptr_conv;
18375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18376         this_ptr_conv.is_owned = false;
18377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
18379         return ret_arr;
18380 }
18381
18382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18383         LDKFundingLocked this_ptr_conv;
18384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18385         this_ptr_conv.is_owned = false;
18386         LDKThirtyTwoBytes val_ref;
18387         CHECK((*env)->GetArrayLength(env, val) == 32);
18388         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18389         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
18390 }
18391
18392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18393         LDKFundingLocked this_ptr_conv;
18394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18395         this_ptr_conv.is_owned = false;
18396         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18398         return ret_arr;
18399 }
18400
18401 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) {
18402         LDKFundingLocked this_ptr_conv;
18403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18404         this_ptr_conv.is_owned = false;
18405         LDKPublicKey val_ref;
18406         CHECK((*env)->GetArrayLength(env, val) == 33);
18407         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18408         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18409 }
18410
18411 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) {
18412         LDKThirtyTwoBytes channel_id_arg_ref;
18413         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18414         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18415         LDKPublicKey next_per_commitment_point_arg_ref;
18416         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18417         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18418         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
18419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18421         uint64_t ret_ref = (uint64_t)ret_var.inner;
18422         if (ret_var.is_owned) {
18423                 ret_ref |= 1;
18424         }
18425         return ret_ref;
18426 }
18427
18428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18429         LDKFundingLocked orig_conv;
18430         orig_conv.inner = (void*)(orig & (~1));
18431         orig_conv.is_owned = false;
18432         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
18433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18435         uint64_t ret_ref = (uint64_t)ret_var.inner;
18436         if (ret_var.is_owned) {
18437                 ret_ref |= 1;
18438         }
18439         return ret_ref;
18440 }
18441
18442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18443         LDKShutdown this_obj_conv;
18444         this_obj_conv.inner = (void*)(this_obj & (~1));
18445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18446         Shutdown_free(this_obj_conv);
18447 }
18448
18449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18450         LDKShutdown this_ptr_conv;
18451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18452         this_ptr_conv.is_owned = false;
18453         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
18455         return ret_arr;
18456 }
18457
18458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18459         LDKShutdown this_ptr_conv;
18460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18461         this_ptr_conv.is_owned = false;
18462         LDKThirtyTwoBytes val_ref;
18463         CHECK((*env)->GetArrayLength(env, val) == 32);
18464         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18465         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
18466 }
18467
18468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18469         LDKShutdown this_ptr_conv;
18470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18471         this_ptr_conv.is_owned = false;
18472         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
18473         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18474         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18475         return ret_arr;
18476 }
18477
18478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18479         LDKShutdown this_ptr_conv;
18480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18481         this_ptr_conv.is_owned = false;
18482         LDKCVec_u8Z val_ref;
18483         val_ref.datalen = (*env)->GetArrayLength(env, val);
18484         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18485         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18486         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18487 }
18488
18489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18490         LDKThirtyTwoBytes channel_id_arg_ref;
18491         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18492         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18493         LDKCVec_u8Z scriptpubkey_arg_ref;
18494         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
18495         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18496         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
18497         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18498         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18499         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18500         uint64_t ret_ref = (uint64_t)ret_var.inner;
18501         if (ret_var.is_owned) {
18502                 ret_ref |= 1;
18503         }
18504         return ret_ref;
18505 }
18506
18507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18508         LDKShutdown orig_conv;
18509         orig_conv.inner = (void*)(orig & (~1));
18510         orig_conv.is_owned = false;
18511         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18513         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18514         uint64_t ret_ref = (uint64_t)ret_var.inner;
18515         if (ret_var.is_owned) {
18516                 ret_ref |= 1;
18517         }
18518         return ret_ref;
18519 }
18520
18521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18522         LDKClosingSigned this_obj_conv;
18523         this_obj_conv.inner = (void*)(this_obj & (~1));
18524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18525         ClosingSigned_free(this_obj_conv);
18526 }
18527
18528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18529         LDKClosingSigned this_ptr_conv;
18530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18531         this_ptr_conv.is_owned = false;
18532         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18533         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
18534         return ret_arr;
18535 }
18536
18537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18538         LDKClosingSigned this_ptr_conv;
18539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18540         this_ptr_conv.is_owned = false;
18541         LDKThirtyTwoBytes val_ref;
18542         CHECK((*env)->GetArrayLength(env, val) == 32);
18543         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18544         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18545 }
18546
18547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18548         LDKClosingSigned this_ptr_conv;
18549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18550         this_ptr_conv.is_owned = false;
18551         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18552         return ret_val;
18553 }
18554
18555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18556         LDKClosingSigned this_ptr_conv;
18557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18558         this_ptr_conv.is_owned = false;
18559         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
18560 }
18561
18562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18563         LDKClosingSigned this_ptr_conv;
18564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18565         this_ptr_conv.is_owned = false;
18566         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18567         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
18568         return ret_arr;
18569 }
18570
18571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18572         LDKClosingSigned this_ptr_conv;
18573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18574         this_ptr_conv.is_owned = false;
18575         LDKSignature val_ref;
18576         CHECK((*env)->GetArrayLength(env, val) == 64);
18577         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18578         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
18579 }
18580
18581 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) {
18582         LDKThirtyTwoBytes channel_id_arg_ref;
18583         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18584         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18585         LDKSignature signature_arg_ref;
18586         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18587         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18588         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
18589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18591         uint64_t ret_ref = (uint64_t)ret_var.inner;
18592         if (ret_var.is_owned) {
18593                 ret_ref |= 1;
18594         }
18595         return ret_ref;
18596 }
18597
18598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18599         LDKClosingSigned orig_conv;
18600         orig_conv.inner = (void*)(orig & (~1));
18601         orig_conv.is_owned = false;
18602         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18605         uint64_t ret_ref = (uint64_t)ret_var.inner;
18606         if (ret_var.is_owned) {
18607                 ret_ref |= 1;
18608         }
18609         return ret_ref;
18610 }
18611
18612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18613         LDKUpdateAddHTLC this_obj_conv;
18614         this_obj_conv.inner = (void*)(this_obj & (~1));
18615         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18616         UpdateAddHTLC_free(this_obj_conv);
18617 }
18618
18619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18620         LDKUpdateAddHTLC this_ptr_conv;
18621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18622         this_ptr_conv.is_owned = false;
18623         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
18625         return ret_arr;
18626 }
18627
18628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18629         LDKUpdateAddHTLC this_ptr_conv;
18630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18631         this_ptr_conv.is_owned = false;
18632         LDKThirtyTwoBytes val_ref;
18633         CHECK((*env)->GetArrayLength(env, val) == 32);
18634         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18635         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18636 }
18637
18638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18639         LDKUpdateAddHTLC this_ptr_conv;
18640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18641         this_ptr_conv.is_owned = false;
18642         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18643         return ret_val;
18644 }
18645
18646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18647         LDKUpdateAddHTLC this_ptr_conv;
18648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18649         this_ptr_conv.is_owned = false;
18650         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18651 }
18652
18653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18654         LDKUpdateAddHTLC this_ptr_conv;
18655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18656         this_ptr_conv.is_owned = false;
18657         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18658         return ret_val;
18659 }
18660
18661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18662         LDKUpdateAddHTLC this_ptr_conv;
18663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18664         this_ptr_conv.is_owned = false;
18665         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18666 }
18667
18668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18669         LDKUpdateAddHTLC this_ptr_conv;
18670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18671         this_ptr_conv.is_owned = false;
18672         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
18674         return ret_arr;
18675 }
18676
18677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18678         LDKUpdateAddHTLC this_ptr_conv;
18679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18680         this_ptr_conv.is_owned = false;
18681         LDKThirtyTwoBytes val_ref;
18682         CHECK((*env)->GetArrayLength(env, val) == 32);
18683         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18684         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18685 }
18686
18687 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18688         LDKUpdateAddHTLC this_ptr_conv;
18689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18690         this_ptr_conv.is_owned = false;
18691         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18692         return ret_val;
18693 }
18694
18695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18696         LDKUpdateAddHTLC this_ptr_conv;
18697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18698         this_ptr_conv.is_owned = false;
18699         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18700 }
18701
18702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18703         LDKUpdateAddHTLC orig_conv;
18704         orig_conv.inner = (void*)(orig & (~1));
18705         orig_conv.is_owned = false;
18706         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18709         uint64_t ret_ref = (uint64_t)ret_var.inner;
18710         if (ret_var.is_owned) {
18711                 ret_ref |= 1;
18712         }
18713         return ret_ref;
18714 }
18715
18716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18717         LDKUpdateFulfillHTLC this_obj_conv;
18718         this_obj_conv.inner = (void*)(this_obj & (~1));
18719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18720         UpdateFulfillHTLC_free(this_obj_conv);
18721 }
18722
18723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18724         LDKUpdateFulfillHTLC this_ptr_conv;
18725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18726         this_ptr_conv.is_owned = false;
18727         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
18729         return ret_arr;
18730 }
18731
18732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18733         LDKUpdateFulfillHTLC this_ptr_conv;
18734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18735         this_ptr_conv.is_owned = false;
18736         LDKThirtyTwoBytes val_ref;
18737         CHECK((*env)->GetArrayLength(env, val) == 32);
18738         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18739         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18740 }
18741
18742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18743         LDKUpdateFulfillHTLC this_ptr_conv;
18744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18745         this_ptr_conv.is_owned = false;
18746         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18747         return ret_val;
18748 }
18749
18750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18751         LDKUpdateFulfillHTLC this_ptr_conv;
18752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18753         this_ptr_conv.is_owned = false;
18754         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18755 }
18756
18757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
18758         LDKUpdateFulfillHTLC this_ptr_conv;
18759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18760         this_ptr_conv.is_owned = false;
18761         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18762         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
18763         return ret_arr;
18764 }
18765
18766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18767         LDKUpdateFulfillHTLC this_ptr_conv;
18768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18769         this_ptr_conv.is_owned = false;
18770         LDKThirtyTwoBytes val_ref;
18771         CHECK((*env)->GetArrayLength(env, val) == 32);
18772         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18773         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18774 }
18775
18776 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) {
18777         LDKThirtyTwoBytes channel_id_arg_ref;
18778         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18779         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18780         LDKThirtyTwoBytes payment_preimage_arg_ref;
18781         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
18782         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
18783         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18786         uint64_t ret_ref = (uint64_t)ret_var.inner;
18787         if (ret_var.is_owned) {
18788                 ret_ref |= 1;
18789         }
18790         return ret_ref;
18791 }
18792
18793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18794         LDKUpdateFulfillHTLC orig_conv;
18795         orig_conv.inner = (void*)(orig & (~1));
18796         orig_conv.is_owned = false;
18797         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18798         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18799         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18800         uint64_t ret_ref = (uint64_t)ret_var.inner;
18801         if (ret_var.is_owned) {
18802                 ret_ref |= 1;
18803         }
18804         return ret_ref;
18805 }
18806
18807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18808         LDKUpdateFailHTLC this_obj_conv;
18809         this_obj_conv.inner = (void*)(this_obj & (~1));
18810         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18811         UpdateFailHTLC_free(this_obj_conv);
18812 }
18813
18814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18815         LDKUpdateFailHTLC this_ptr_conv;
18816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18817         this_ptr_conv.is_owned = false;
18818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
18820         return ret_arr;
18821 }
18822
18823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18824         LDKUpdateFailHTLC this_ptr_conv;
18825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18826         this_ptr_conv.is_owned = false;
18827         LDKThirtyTwoBytes val_ref;
18828         CHECK((*env)->GetArrayLength(env, val) == 32);
18829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18830         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18831 }
18832
18833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18834         LDKUpdateFailHTLC this_ptr_conv;
18835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18836         this_ptr_conv.is_owned = false;
18837         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18838         return ret_val;
18839 }
18840
18841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18842         LDKUpdateFailHTLC this_ptr_conv;
18843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18844         this_ptr_conv.is_owned = false;
18845         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18846 }
18847
18848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18849         LDKUpdateFailHTLC orig_conv;
18850         orig_conv.inner = (void*)(orig & (~1));
18851         orig_conv.is_owned = false;
18852         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
18853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18855         uint64_t ret_ref = (uint64_t)ret_var.inner;
18856         if (ret_var.is_owned) {
18857                 ret_ref |= 1;
18858         }
18859         return ret_ref;
18860 }
18861
18862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18863         LDKUpdateFailMalformedHTLC this_obj_conv;
18864         this_obj_conv.inner = (void*)(this_obj & (~1));
18865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18866         UpdateFailMalformedHTLC_free(this_obj_conv);
18867 }
18868
18869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18870         LDKUpdateFailMalformedHTLC this_ptr_conv;
18871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18872         this_ptr_conv.is_owned = false;
18873         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
18875         return ret_arr;
18876 }
18877
18878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18879         LDKUpdateFailMalformedHTLC this_ptr_conv;
18880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18881         this_ptr_conv.is_owned = false;
18882         LDKThirtyTwoBytes val_ref;
18883         CHECK((*env)->GetArrayLength(env, val) == 32);
18884         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18885         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18886 }
18887
18888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18889         LDKUpdateFailMalformedHTLC this_ptr_conv;
18890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18891         this_ptr_conv.is_owned = false;
18892         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18893         return ret_val;
18894 }
18895
18896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18897         LDKUpdateFailMalformedHTLC this_ptr_conv;
18898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18899         this_ptr_conv.is_owned = false;
18900         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18901 }
18902
18903 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
18904         LDKUpdateFailMalformedHTLC this_ptr_conv;
18905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18906         this_ptr_conv.is_owned = false;
18907         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18908         return ret_val;
18909 }
18910
18911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18912         LDKUpdateFailMalformedHTLC this_ptr_conv;
18913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18914         this_ptr_conv.is_owned = false;
18915         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18916 }
18917
18918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18919         LDKUpdateFailMalformedHTLC orig_conv;
18920         orig_conv.inner = (void*)(orig & (~1));
18921         orig_conv.is_owned = false;
18922         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18923         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18924         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18925         uint64_t ret_ref = (uint64_t)ret_var.inner;
18926         if (ret_var.is_owned) {
18927                 ret_ref |= 1;
18928         }
18929         return ret_ref;
18930 }
18931
18932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18933         LDKCommitmentSigned this_obj_conv;
18934         this_obj_conv.inner = (void*)(this_obj & (~1));
18935         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18936         CommitmentSigned_free(this_obj_conv);
18937 }
18938
18939 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18940         LDKCommitmentSigned this_ptr_conv;
18941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18942         this_ptr_conv.is_owned = false;
18943         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18944         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
18945         return ret_arr;
18946 }
18947
18948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18949         LDKCommitmentSigned this_ptr_conv;
18950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18951         this_ptr_conv.is_owned = false;
18952         LDKThirtyTwoBytes val_ref;
18953         CHECK((*env)->GetArrayLength(env, val) == 32);
18954         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18955         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18956 }
18957
18958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18959         LDKCommitmentSigned this_ptr_conv;
18960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18961         this_ptr_conv.is_owned = false;
18962         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18963         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
18964         return ret_arr;
18965 }
18966
18967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18968         LDKCommitmentSigned this_ptr_conv;
18969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18970         this_ptr_conv.is_owned = false;
18971         LDKSignature val_ref;
18972         CHECK((*env)->GetArrayLength(env, val) == 64);
18973         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18974         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18975 }
18976
18977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18978         LDKCommitmentSigned this_ptr_conv;
18979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18980         this_ptr_conv.is_owned = false;
18981         LDKCVec_SignatureZ val_constr;
18982         val_constr.datalen = (*env)->GetArrayLength(env, val);
18983         if (val_constr.datalen > 0)
18984                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18985         else
18986                 val_constr.data = NULL;
18987         for (size_t i = 0; i < val_constr.datalen; i++) {
18988                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18989                 LDKSignature val_conv_8_ref;
18990                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18991                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18992                 val_constr.data[i] = val_conv_8_ref;
18993         }
18994         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18995 }
18996
18997 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) {
18998         LDKThirtyTwoBytes channel_id_arg_ref;
18999         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19000         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19001         LDKSignature signature_arg_ref;
19002         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19003         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19004         LDKCVec_SignatureZ htlc_signatures_arg_constr;
19005         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
19006         if (htlc_signatures_arg_constr.datalen > 0)
19007                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19008         else
19009                 htlc_signatures_arg_constr.data = NULL;
19010         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
19011                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
19012                 LDKSignature htlc_signatures_arg_conv_8_ref;
19013                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
19014                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
19015                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
19016         }
19017         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
19018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19020         uint64_t ret_ref = (uint64_t)ret_var.inner;
19021         if (ret_var.is_owned) {
19022                 ret_ref |= 1;
19023         }
19024         return ret_ref;
19025 }
19026
19027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19028         LDKCommitmentSigned orig_conv;
19029         orig_conv.inner = (void*)(orig & (~1));
19030         orig_conv.is_owned = false;
19031         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
19032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19034         uint64_t ret_ref = (uint64_t)ret_var.inner;
19035         if (ret_var.is_owned) {
19036                 ret_ref |= 1;
19037         }
19038         return ret_ref;
19039 }
19040
19041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19042         LDKRevokeAndACK this_obj_conv;
19043         this_obj_conv.inner = (void*)(this_obj & (~1));
19044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19045         RevokeAndACK_free(this_obj_conv);
19046 }
19047
19048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19049         LDKRevokeAndACK this_ptr_conv;
19050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19051         this_ptr_conv.is_owned = false;
19052         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
19054         return ret_arr;
19055 }
19056
19057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19058         LDKRevokeAndACK this_ptr_conv;
19059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19060         this_ptr_conv.is_owned = false;
19061         LDKThirtyTwoBytes val_ref;
19062         CHECK((*env)->GetArrayLength(env, val) == 32);
19063         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19064         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
19065 }
19066
19067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19068         LDKRevokeAndACK this_ptr_conv;
19069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19070         this_ptr_conv.is_owned = false;
19071         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19072         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
19073         return ret_arr;
19074 }
19075
19076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19077         LDKRevokeAndACK this_ptr_conv;
19078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19079         this_ptr_conv.is_owned = false;
19080         LDKThirtyTwoBytes val_ref;
19081         CHECK((*env)->GetArrayLength(env, val) == 32);
19082         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19083         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
19084 }
19085
19086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19087         LDKRevokeAndACK this_ptr_conv;
19088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19089         this_ptr_conv.is_owned = false;
19090         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19091         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
19092         return ret_arr;
19093 }
19094
19095 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) {
19096         LDKRevokeAndACK this_ptr_conv;
19097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19098         this_ptr_conv.is_owned = false;
19099         LDKPublicKey val_ref;
19100         CHECK((*env)->GetArrayLength(env, val) == 33);
19101         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19102         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
19103 }
19104
19105 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) {
19106         LDKThirtyTwoBytes channel_id_arg_ref;
19107         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19108         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19109         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
19110         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
19111         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
19112         LDKPublicKey next_per_commitment_point_arg_ref;
19113         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
19114         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
19115         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
19116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19118         uint64_t ret_ref = (uint64_t)ret_var.inner;
19119         if (ret_var.is_owned) {
19120                 ret_ref |= 1;
19121         }
19122         return ret_ref;
19123 }
19124
19125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19126         LDKRevokeAndACK orig_conv;
19127         orig_conv.inner = (void*)(orig & (~1));
19128         orig_conv.is_owned = false;
19129         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
19130         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19131         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19132         uint64_t ret_ref = (uint64_t)ret_var.inner;
19133         if (ret_var.is_owned) {
19134                 ret_ref |= 1;
19135         }
19136         return ret_ref;
19137 }
19138
19139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19140         LDKUpdateFee this_obj_conv;
19141         this_obj_conv.inner = (void*)(this_obj & (~1));
19142         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19143         UpdateFee_free(this_obj_conv);
19144 }
19145
19146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19147         LDKUpdateFee this_ptr_conv;
19148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19149         this_ptr_conv.is_owned = false;
19150         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19151         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
19152         return ret_arr;
19153 }
19154
19155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19156         LDKUpdateFee this_ptr_conv;
19157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19158         this_ptr_conv.is_owned = false;
19159         LDKThirtyTwoBytes val_ref;
19160         CHECK((*env)->GetArrayLength(env, val) == 32);
19161         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19162         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
19163 }
19164
19165 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
19166         LDKUpdateFee this_ptr_conv;
19167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19168         this_ptr_conv.is_owned = false;
19169         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
19170         return ret_val;
19171 }
19172
19173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19174         LDKUpdateFee this_ptr_conv;
19175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19176         this_ptr_conv.is_owned = false;
19177         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
19178 }
19179
19180 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) {
19181         LDKThirtyTwoBytes channel_id_arg_ref;
19182         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19183         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19184         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
19185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19187         uint64_t ret_ref = (uint64_t)ret_var.inner;
19188         if (ret_var.is_owned) {
19189                 ret_ref |= 1;
19190         }
19191         return ret_ref;
19192 }
19193
19194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19195         LDKUpdateFee orig_conv;
19196         orig_conv.inner = (void*)(orig & (~1));
19197         orig_conv.is_owned = false;
19198         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
19199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19201         uint64_t ret_ref = (uint64_t)ret_var.inner;
19202         if (ret_var.is_owned) {
19203                 ret_ref |= 1;
19204         }
19205         return ret_ref;
19206 }
19207
19208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19209         LDKDataLossProtect this_obj_conv;
19210         this_obj_conv.inner = (void*)(this_obj & (~1));
19211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19212         DataLossProtect_free(this_obj_conv);
19213 }
19214
19215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19216         LDKDataLossProtect this_ptr_conv;
19217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19218         this_ptr_conv.is_owned = false;
19219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
19221         return ret_arr;
19222 }
19223
19224 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) {
19225         LDKDataLossProtect this_ptr_conv;
19226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19227         this_ptr_conv.is_owned = false;
19228         LDKThirtyTwoBytes val_ref;
19229         CHECK((*env)->GetArrayLength(env, val) == 32);
19230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19231         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
19232 }
19233
19234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19235         LDKDataLossProtect this_ptr_conv;
19236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19237         this_ptr_conv.is_owned = false;
19238         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
19240         return ret_arr;
19241 }
19242
19243 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) {
19244         LDKDataLossProtect this_ptr_conv;
19245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19246         this_ptr_conv.is_owned = false;
19247         LDKPublicKey val_ref;
19248         CHECK((*env)->GetArrayLength(env, val) == 33);
19249         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19250         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
19251 }
19252
19253 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) {
19254         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
19255         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
19256         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
19257         LDKPublicKey my_current_per_commitment_point_arg_ref;
19258         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
19259         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
19260         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
19261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19263         uint64_t ret_ref = (uint64_t)ret_var.inner;
19264         if (ret_var.is_owned) {
19265                 ret_ref |= 1;
19266         }
19267         return ret_ref;
19268 }
19269
19270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19271         LDKDataLossProtect orig_conv;
19272         orig_conv.inner = (void*)(orig & (~1));
19273         orig_conv.is_owned = false;
19274         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
19275         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19276         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19277         uint64_t ret_ref = (uint64_t)ret_var.inner;
19278         if (ret_var.is_owned) {
19279                 ret_ref |= 1;
19280         }
19281         return ret_ref;
19282 }
19283
19284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19285         LDKChannelReestablish this_obj_conv;
19286         this_obj_conv.inner = (void*)(this_obj & (~1));
19287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19288         ChannelReestablish_free(this_obj_conv);
19289 }
19290
19291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19292         LDKChannelReestablish this_ptr_conv;
19293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19294         this_ptr_conv.is_owned = false;
19295         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19296         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
19297         return ret_arr;
19298 }
19299
19300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19301         LDKChannelReestablish this_ptr_conv;
19302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19303         this_ptr_conv.is_owned = false;
19304         LDKThirtyTwoBytes val_ref;
19305         CHECK((*env)->GetArrayLength(env, val) == 32);
19306         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19307         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
19308 }
19309
19310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19311         LDKChannelReestablish this_ptr_conv;
19312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19313         this_ptr_conv.is_owned = false;
19314         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
19315         return ret_val;
19316 }
19317
19318 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) {
19319         LDKChannelReestablish this_ptr_conv;
19320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19321         this_ptr_conv.is_owned = false;
19322         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
19323 }
19324
19325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19326         LDKChannelReestablish this_ptr_conv;
19327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19328         this_ptr_conv.is_owned = false;
19329         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
19330         return ret_val;
19331 }
19332
19333 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) {
19334         LDKChannelReestablish this_ptr_conv;
19335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19336         this_ptr_conv.is_owned = false;
19337         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
19338 }
19339
19340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19341         LDKChannelReestablish orig_conv;
19342         orig_conv.inner = (void*)(orig & (~1));
19343         orig_conv.is_owned = false;
19344         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
19345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19347         uint64_t ret_ref = (uint64_t)ret_var.inner;
19348         if (ret_var.is_owned) {
19349                 ret_ref |= 1;
19350         }
19351         return ret_ref;
19352 }
19353
19354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19355         LDKAnnouncementSignatures this_obj_conv;
19356         this_obj_conv.inner = (void*)(this_obj & (~1));
19357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19358         AnnouncementSignatures_free(this_obj_conv);
19359 }
19360
19361 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19362         LDKAnnouncementSignatures this_ptr_conv;
19363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19364         this_ptr_conv.is_owned = false;
19365         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19366         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
19367         return ret_arr;
19368 }
19369
19370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19371         LDKAnnouncementSignatures this_ptr_conv;
19372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19373         this_ptr_conv.is_owned = false;
19374         LDKThirtyTwoBytes val_ref;
19375         CHECK((*env)->GetArrayLength(env, val) == 32);
19376         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19377         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
19378 }
19379
19380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19381         LDKAnnouncementSignatures this_ptr_conv;
19382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19383         this_ptr_conv.is_owned = false;
19384         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
19385         return ret_val;
19386 }
19387
19388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19389         LDKAnnouncementSignatures this_ptr_conv;
19390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19391         this_ptr_conv.is_owned = false;
19392         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19393 }
19394
19395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19396         LDKAnnouncementSignatures this_ptr_conv;
19397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19398         this_ptr_conv.is_owned = false;
19399         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
19401         return ret_arr;
19402 }
19403
19404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19405         LDKAnnouncementSignatures this_ptr_conv;
19406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19407         this_ptr_conv.is_owned = false;
19408         LDKSignature val_ref;
19409         CHECK((*env)->GetArrayLength(env, val) == 64);
19410         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19411         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19412 }
19413
19414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19415         LDKAnnouncementSignatures this_ptr_conv;
19416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19417         this_ptr_conv.is_owned = false;
19418         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19419         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
19420         return ret_arr;
19421 }
19422
19423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19424         LDKAnnouncementSignatures this_ptr_conv;
19425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19426         this_ptr_conv.is_owned = false;
19427         LDKSignature val_ref;
19428         CHECK((*env)->GetArrayLength(env, val) == 64);
19429         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19430         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19431 }
19432
19433 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) {
19434         LDKThirtyTwoBytes channel_id_arg_ref;
19435         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19436         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19437         LDKSignature node_signature_arg_ref;
19438         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
19439         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
19440         LDKSignature bitcoin_signature_arg_ref;
19441         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
19442         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
19443         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19446         uint64_t ret_ref = (uint64_t)ret_var.inner;
19447         if (ret_var.is_owned) {
19448                 ret_ref |= 1;
19449         }
19450         return ret_ref;
19451 }
19452
19453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19454         LDKAnnouncementSignatures orig_conv;
19455         orig_conv.inner = (void*)(orig & (~1));
19456         orig_conv.is_owned = false;
19457         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19460         uint64_t ret_ref = (uint64_t)ret_var.inner;
19461         if (ret_var.is_owned) {
19462                 ret_ref |= 1;
19463         }
19464         return ret_ref;
19465 }
19466
19467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19468         if ((this_ptr & 1) != 0) return;
19469         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19470         FREE((void*)this_ptr);
19471         NetAddress_free(this_ptr_conv);
19472 }
19473
19474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19475         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19476         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19477         *ret_copy = NetAddress_clone(orig_conv);
19478         uint64_t ret_ref = (uint64_t)ret_copy;
19479         return ret_ref;
19480 }
19481
19482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19483         LDKFourBytes addr_ref;
19484         CHECK((*env)->GetArrayLength(env, addr) == 4);
19485         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
19486         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19487         *ret_copy = NetAddress_ipv4(addr_ref, port);
19488         uint64_t ret_ref = (uint64_t)ret_copy;
19489         return ret_ref;
19490 }
19491
19492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19493         LDKSixteenBytes addr_ref;
19494         CHECK((*env)->GetArrayLength(env, addr) == 16);
19495         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
19496         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19497         *ret_copy = NetAddress_ipv6(addr_ref, port);
19498         uint64_t ret_ref = (uint64_t)ret_copy;
19499         return ret_ref;
19500 }
19501
19502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19503         LDKTenBytes addr_ref;
19504         CHECK((*env)->GetArrayLength(env, addr) == 10);
19505         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
19506         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19507         *ret_copy = NetAddress_onion_v2(addr_ref, port);
19508         uint64_t ret_ref = (uint64_t)ret_copy;
19509         return ret_ref;
19510 }
19511
19512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
19513         LDKThirtyTwoBytes ed25519_pubkey_ref;
19514         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
19515         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
19516         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19517         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
19518         uint64_t ret_ref = (uint64_t)ret_copy;
19519         return ret_ref;
19520 }
19521
19522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
19523         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19524         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19525         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19526         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19527         CVec_u8Z_free(ret_var);
19528         return ret_arr;
19529 }
19530
19531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19532         LDKu8slice ser_ref;
19533         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19534         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19535         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
19536         *ret_conv = Result_read(ser_ref);
19537         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19538         return (uint64_t)ret_conv;
19539 }
19540
19541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19542         LDKu8slice ser_ref;
19543         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19544         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19545         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19546         *ret_conv = NetAddress_read(ser_ref);
19547         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19548         return (uint64_t)ret_conv;
19549 }
19550
19551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19552         LDKUnsignedNodeAnnouncement this_obj_conv;
19553         this_obj_conv.inner = (void*)(this_obj & (~1));
19554         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19555         UnsignedNodeAnnouncement_free(this_obj_conv);
19556 }
19557
19558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19559         LDKUnsignedNodeAnnouncement this_ptr_conv;
19560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19561         this_ptr_conv.is_owned = false;
19562         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
19563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19565         uint64_t ret_ref = (uint64_t)ret_var.inner;
19566         if (ret_var.is_owned) {
19567                 ret_ref |= 1;
19568         }
19569         return ret_ref;
19570 }
19571
19572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19573         LDKUnsignedNodeAnnouncement this_ptr_conv;
19574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19575         this_ptr_conv.is_owned = false;
19576         LDKNodeFeatures val_conv;
19577         val_conv.inner = (void*)(val & (~1));
19578         val_conv.is_owned = (val & 1) || (val == 0);
19579         val_conv = NodeFeatures_clone(&val_conv);
19580         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
19581 }
19582
19583 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19584         LDKUnsignedNodeAnnouncement this_ptr_conv;
19585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19586         this_ptr_conv.is_owned = false;
19587         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
19588         return ret_val;
19589 }
19590
19591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19592         LDKUnsignedNodeAnnouncement this_ptr_conv;
19593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19594         this_ptr_conv.is_owned = false;
19595         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
19596 }
19597
19598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19599         LDKUnsignedNodeAnnouncement this_ptr_conv;
19600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19601         this_ptr_conv.is_owned = false;
19602         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
19604         return ret_arr;
19605 }
19606
19607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19608         LDKUnsignedNodeAnnouncement this_ptr_conv;
19609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19610         this_ptr_conv.is_owned = false;
19611         LDKPublicKey val_ref;
19612         CHECK((*env)->GetArrayLength(env, val) == 33);
19613         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19614         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
19615 }
19616
19617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
19618         LDKUnsignedNodeAnnouncement this_ptr_conv;
19619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19620         this_ptr_conv.is_owned = false;
19621         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
19622         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
19623         return ret_arr;
19624 }
19625
19626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19627         LDKUnsignedNodeAnnouncement this_ptr_conv;
19628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19629         this_ptr_conv.is_owned = false;
19630         LDKThreeBytes val_ref;
19631         CHECK((*env)->GetArrayLength(env, val) == 3);
19632         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19633         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
19634 }
19635
19636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19637         LDKUnsignedNodeAnnouncement this_ptr_conv;
19638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19639         this_ptr_conv.is_owned = false;
19640         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
19642         return ret_arr;
19643 }
19644
19645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19646         LDKUnsignedNodeAnnouncement this_ptr_conv;
19647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19648         this_ptr_conv.is_owned = false;
19649         LDKThirtyTwoBytes val_ref;
19650         CHECK((*env)->GetArrayLength(env, val) == 32);
19651         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19652         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19653 }
19654
19655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19656         LDKUnsignedNodeAnnouncement this_ptr_conv;
19657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19658         this_ptr_conv.is_owned = false;
19659         LDKCVec_NetAddressZ val_constr;
19660         val_constr.datalen = (*env)->GetArrayLength(env, val);
19661         if (val_constr.datalen > 0)
19662                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19663         else
19664                 val_constr.data = NULL;
19665         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19666         for (size_t m = 0; m < val_constr.datalen; m++) {
19667                 int64_t val_conv_12 = val_vals[m];
19668                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19669                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19670                 val_constr.data[m] = val_conv_12_conv;
19671         }
19672         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19673         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19674 }
19675
19676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19677         LDKUnsignedNodeAnnouncement orig_conv;
19678         orig_conv.inner = (void*)(orig & (~1));
19679         orig_conv.is_owned = false;
19680         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19683         uint64_t ret_ref = (uint64_t)ret_var.inner;
19684         if (ret_var.is_owned) {
19685                 ret_ref |= 1;
19686         }
19687         return ret_ref;
19688 }
19689
19690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19691         LDKNodeAnnouncement this_obj_conv;
19692         this_obj_conv.inner = (void*)(this_obj & (~1));
19693         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19694         NodeAnnouncement_free(this_obj_conv);
19695 }
19696
19697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19698         LDKNodeAnnouncement this_ptr_conv;
19699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19700         this_ptr_conv.is_owned = false;
19701         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19702         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
19703         return ret_arr;
19704 }
19705
19706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19707         LDKNodeAnnouncement this_ptr_conv;
19708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19709         this_ptr_conv.is_owned = false;
19710         LDKSignature val_ref;
19711         CHECK((*env)->GetArrayLength(env, val) == 64);
19712         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19713         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19714 }
19715
19716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19717         LDKNodeAnnouncement this_ptr_conv;
19718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19719         this_ptr_conv.is_owned = false;
19720         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19723         uint64_t ret_ref = (uint64_t)ret_var.inner;
19724         if (ret_var.is_owned) {
19725                 ret_ref |= 1;
19726         }
19727         return ret_ref;
19728 }
19729
19730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19731         LDKNodeAnnouncement this_ptr_conv;
19732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19733         this_ptr_conv.is_owned = false;
19734         LDKUnsignedNodeAnnouncement val_conv;
19735         val_conv.inner = (void*)(val & (~1));
19736         val_conv.is_owned = (val & 1) || (val == 0);
19737         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19738         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19739 }
19740
19741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19742         LDKSignature signature_arg_ref;
19743         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19744         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19745         LDKUnsignedNodeAnnouncement contents_arg_conv;
19746         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19747         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19748         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19749         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19750         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19751         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19752         uint64_t ret_ref = (uint64_t)ret_var.inner;
19753         if (ret_var.is_owned) {
19754                 ret_ref |= 1;
19755         }
19756         return ret_ref;
19757 }
19758
19759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19760         LDKNodeAnnouncement orig_conv;
19761         orig_conv.inner = (void*)(orig & (~1));
19762         orig_conv.is_owned = false;
19763         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19766         uint64_t ret_ref = (uint64_t)ret_var.inner;
19767         if (ret_var.is_owned) {
19768                 ret_ref |= 1;
19769         }
19770         return ret_ref;
19771 }
19772
19773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19774         LDKUnsignedChannelAnnouncement this_obj_conv;
19775         this_obj_conv.inner = (void*)(this_obj & (~1));
19776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19777         UnsignedChannelAnnouncement_free(this_obj_conv);
19778 }
19779
19780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19781         LDKUnsignedChannelAnnouncement this_ptr_conv;
19782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19783         this_ptr_conv.is_owned = false;
19784         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19785         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19786         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19787         uint64_t ret_ref = (uint64_t)ret_var.inner;
19788         if (ret_var.is_owned) {
19789                 ret_ref |= 1;
19790         }
19791         return ret_ref;
19792 }
19793
19794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19795         LDKUnsignedChannelAnnouncement this_ptr_conv;
19796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19797         this_ptr_conv.is_owned = false;
19798         LDKChannelFeatures val_conv;
19799         val_conv.inner = (void*)(val & (~1));
19800         val_conv.is_owned = (val & 1) || (val == 0);
19801         val_conv = ChannelFeatures_clone(&val_conv);
19802         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19803 }
19804
19805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19806         LDKUnsignedChannelAnnouncement this_ptr_conv;
19807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19808         this_ptr_conv.is_owned = false;
19809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
19811         return ret_arr;
19812 }
19813
19814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19815         LDKUnsignedChannelAnnouncement this_ptr_conv;
19816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19817         this_ptr_conv.is_owned = false;
19818         LDKThirtyTwoBytes val_ref;
19819         CHECK((*env)->GetArrayLength(env, val) == 32);
19820         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19821         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19822 }
19823
19824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19825         LDKUnsignedChannelAnnouncement this_ptr_conv;
19826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19827         this_ptr_conv.is_owned = false;
19828         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19829         return ret_val;
19830 }
19831
19832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19833         LDKUnsignedChannelAnnouncement this_ptr_conv;
19834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19835         this_ptr_conv.is_owned = false;
19836         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19837 }
19838
19839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19840         LDKUnsignedChannelAnnouncement this_ptr_conv;
19841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19842         this_ptr_conv.is_owned = false;
19843         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19844         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
19845         return ret_arr;
19846 }
19847
19848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19849         LDKUnsignedChannelAnnouncement this_ptr_conv;
19850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19851         this_ptr_conv.is_owned = false;
19852         LDKPublicKey val_ref;
19853         CHECK((*env)->GetArrayLength(env, val) == 33);
19854         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19855         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19856 }
19857
19858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19859         LDKUnsignedChannelAnnouncement this_ptr_conv;
19860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19861         this_ptr_conv.is_owned = false;
19862         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19863         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
19864         return ret_arr;
19865 }
19866
19867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19868         LDKUnsignedChannelAnnouncement this_ptr_conv;
19869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19870         this_ptr_conv.is_owned = false;
19871         LDKPublicKey val_ref;
19872         CHECK((*env)->GetArrayLength(env, val) == 33);
19873         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19874         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19875 }
19876
19877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19878         LDKUnsignedChannelAnnouncement this_ptr_conv;
19879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19880         this_ptr_conv.is_owned = false;
19881         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
19883         return ret_arr;
19884 }
19885
19886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19887         LDKUnsignedChannelAnnouncement this_ptr_conv;
19888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19889         this_ptr_conv.is_owned = false;
19890         LDKPublicKey val_ref;
19891         CHECK((*env)->GetArrayLength(env, val) == 33);
19892         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19893         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19894 }
19895
19896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19897         LDKUnsignedChannelAnnouncement this_ptr_conv;
19898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19899         this_ptr_conv.is_owned = false;
19900         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19901         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
19902         return ret_arr;
19903 }
19904
19905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19906         LDKUnsignedChannelAnnouncement this_ptr_conv;
19907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19908         this_ptr_conv.is_owned = false;
19909         LDKPublicKey val_ref;
19910         CHECK((*env)->GetArrayLength(env, val) == 33);
19911         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19912         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19913 }
19914
19915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19916         LDKUnsignedChannelAnnouncement orig_conv;
19917         orig_conv.inner = (void*)(orig & (~1));
19918         orig_conv.is_owned = false;
19919         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19922         uint64_t ret_ref = (uint64_t)ret_var.inner;
19923         if (ret_var.is_owned) {
19924                 ret_ref |= 1;
19925         }
19926         return ret_ref;
19927 }
19928
19929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19930         LDKChannelAnnouncement this_obj_conv;
19931         this_obj_conv.inner = (void*)(this_obj & (~1));
19932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19933         ChannelAnnouncement_free(this_obj_conv);
19934 }
19935
19936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19937         LDKChannelAnnouncement this_ptr_conv;
19938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19939         this_ptr_conv.is_owned = false;
19940         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
19942         return ret_arr;
19943 }
19944
19945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19946         LDKChannelAnnouncement this_ptr_conv;
19947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19948         this_ptr_conv.is_owned = false;
19949         LDKSignature val_ref;
19950         CHECK((*env)->GetArrayLength(env, val) == 64);
19951         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19952         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19953 }
19954
19955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19956         LDKChannelAnnouncement this_ptr_conv;
19957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19958         this_ptr_conv.is_owned = false;
19959         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19960         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
19961         return ret_arr;
19962 }
19963
19964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19965         LDKChannelAnnouncement this_ptr_conv;
19966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19967         this_ptr_conv.is_owned = false;
19968         LDKSignature val_ref;
19969         CHECK((*env)->GetArrayLength(env, val) == 64);
19970         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19971         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19972 }
19973
19974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19975         LDKChannelAnnouncement this_ptr_conv;
19976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19977         this_ptr_conv.is_owned = false;
19978         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
19980         return ret_arr;
19981 }
19982
19983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19984         LDKChannelAnnouncement this_ptr_conv;
19985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19986         this_ptr_conv.is_owned = false;
19987         LDKSignature val_ref;
19988         CHECK((*env)->GetArrayLength(env, val) == 64);
19989         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19990         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19991 }
19992
19993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19994         LDKChannelAnnouncement this_ptr_conv;
19995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19996         this_ptr_conv.is_owned = false;
19997         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
19999         return ret_arr;
20000 }
20001
20002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20003         LDKChannelAnnouncement this_ptr_conv;
20004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20005         this_ptr_conv.is_owned = false;
20006         LDKSignature val_ref;
20007         CHECK((*env)->GetArrayLength(env, val) == 64);
20008         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20009         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
20010 }
20011
20012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20013         LDKChannelAnnouncement this_ptr_conv;
20014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20015         this_ptr_conv.is_owned = false;
20016         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
20017         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20018         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20019         uint64_t ret_ref = (uint64_t)ret_var.inner;
20020         if (ret_var.is_owned) {
20021                 ret_ref |= 1;
20022         }
20023         return ret_ref;
20024 }
20025
20026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20027         LDKChannelAnnouncement this_ptr_conv;
20028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20029         this_ptr_conv.is_owned = false;
20030         LDKUnsignedChannelAnnouncement val_conv;
20031         val_conv.inner = (void*)(val & (~1));
20032         val_conv.is_owned = (val & 1) || (val == 0);
20033         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
20034         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
20035 }
20036
20037 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) {
20038         LDKSignature node_signature_1_arg_ref;
20039         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
20040         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
20041         LDKSignature node_signature_2_arg_ref;
20042         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
20043         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
20044         LDKSignature bitcoin_signature_1_arg_ref;
20045         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
20046         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
20047         LDKSignature bitcoin_signature_2_arg_ref;
20048         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
20049         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
20050         LDKUnsignedChannelAnnouncement contents_arg_conv;
20051         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20052         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20053         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
20054         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);
20055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20057         uint64_t ret_ref = (uint64_t)ret_var.inner;
20058         if (ret_var.is_owned) {
20059                 ret_ref |= 1;
20060         }
20061         return ret_ref;
20062 }
20063
20064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20065         LDKChannelAnnouncement orig_conv;
20066         orig_conv.inner = (void*)(orig & (~1));
20067         orig_conv.is_owned = false;
20068         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
20069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20071         uint64_t ret_ref = (uint64_t)ret_var.inner;
20072         if (ret_var.is_owned) {
20073                 ret_ref |= 1;
20074         }
20075         return ret_ref;
20076 }
20077
20078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20079         LDKUnsignedChannelUpdate this_obj_conv;
20080         this_obj_conv.inner = (void*)(this_obj & (~1));
20081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20082         UnsignedChannelUpdate_free(this_obj_conv);
20083 }
20084
20085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20086         LDKUnsignedChannelUpdate this_ptr_conv;
20087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20088         this_ptr_conv.is_owned = false;
20089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
20091         return ret_arr;
20092 }
20093
20094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20095         LDKUnsignedChannelUpdate this_ptr_conv;
20096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20097         this_ptr_conv.is_owned = false;
20098         LDKThirtyTwoBytes val_ref;
20099         CHECK((*env)->GetArrayLength(env, val) == 32);
20100         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20101         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
20102 }
20103
20104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20105         LDKUnsignedChannelUpdate this_ptr_conv;
20106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20107         this_ptr_conv.is_owned = false;
20108         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
20109         return ret_val;
20110 }
20111
20112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20113         LDKUnsignedChannelUpdate this_ptr_conv;
20114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20115         this_ptr_conv.is_owned = false;
20116         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
20117 }
20118
20119 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20120         LDKUnsignedChannelUpdate this_ptr_conv;
20121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20122         this_ptr_conv.is_owned = false;
20123         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
20124         return ret_val;
20125 }
20126
20127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20128         LDKUnsignedChannelUpdate this_ptr_conv;
20129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20130         this_ptr_conv.is_owned = false;
20131         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
20132 }
20133
20134 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
20135         LDKUnsignedChannelUpdate this_ptr_conv;
20136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20137         this_ptr_conv.is_owned = false;
20138         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
20139         return ret_val;
20140 }
20141
20142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
20143         LDKUnsignedChannelUpdate this_ptr_conv;
20144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20145         this_ptr_conv.is_owned = false;
20146         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
20147 }
20148
20149 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20150         LDKUnsignedChannelUpdate this_ptr_conv;
20151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20152         this_ptr_conv.is_owned = false;
20153         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
20154         return ret_val;
20155 }
20156
20157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20158         LDKUnsignedChannelUpdate this_ptr_conv;
20159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20160         this_ptr_conv.is_owned = false;
20161         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
20162 }
20163
20164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20165         LDKUnsignedChannelUpdate this_ptr_conv;
20166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20167         this_ptr_conv.is_owned = false;
20168         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
20169         return ret_val;
20170 }
20171
20172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20173         LDKUnsignedChannelUpdate this_ptr_conv;
20174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20175         this_ptr_conv.is_owned = false;
20176         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
20177 }
20178
20179 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20180         LDKUnsignedChannelUpdate this_ptr_conv;
20181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20182         this_ptr_conv.is_owned = false;
20183         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
20184         return ret_val;
20185 }
20186
20187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20188         LDKUnsignedChannelUpdate this_ptr_conv;
20189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20190         this_ptr_conv.is_owned = false;
20191         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
20192 }
20193
20194 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20195         LDKUnsignedChannelUpdate this_ptr_conv;
20196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20197         this_ptr_conv.is_owned = false;
20198         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
20199         return ret_val;
20200 }
20201
20202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20203         LDKUnsignedChannelUpdate this_ptr_conv;
20204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20205         this_ptr_conv.is_owned = false;
20206         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
20207 }
20208
20209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20210         LDKUnsignedChannelUpdate orig_conv;
20211         orig_conv.inner = (void*)(orig & (~1));
20212         orig_conv.is_owned = false;
20213         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
20214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20216         uint64_t ret_ref = (uint64_t)ret_var.inner;
20217         if (ret_var.is_owned) {
20218                 ret_ref |= 1;
20219         }
20220         return ret_ref;
20221 }
20222
20223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20224         LDKChannelUpdate this_obj_conv;
20225         this_obj_conv.inner = (void*)(this_obj & (~1));
20226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20227         ChannelUpdate_free(this_obj_conv);
20228 }
20229
20230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20231         LDKChannelUpdate this_ptr_conv;
20232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20233         this_ptr_conv.is_owned = false;
20234         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20235         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
20236         return ret_arr;
20237 }
20238
20239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20240         LDKChannelUpdate this_ptr_conv;
20241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20242         this_ptr_conv.is_owned = false;
20243         LDKSignature val_ref;
20244         CHECK((*env)->GetArrayLength(env, val) == 64);
20245         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20246         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
20247 }
20248
20249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20250         LDKChannelUpdate this_ptr_conv;
20251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20252         this_ptr_conv.is_owned = false;
20253         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
20254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20256         uint64_t ret_ref = (uint64_t)ret_var.inner;
20257         if (ret_var.is_owned) {
20258                 ret_ref |= 1;
20259         }
20260         return ret_ref;
20261 }
20262
20263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20264         LDKChannelUpdate this_ptr_conv;
20265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20266         this_ptr_conv.is_owned = false;
20267         LDKUnsignedChannelUpdate val_conv;
20268         val_conv.inner = (void*)(val & (~1));
20269         val_conv.is_owned = (val & 1) || (val == 0);
20270         val_conv = UnsignedChannelUpdate_clone(&val_conv);
20271         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
20272 }
20273
20274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
20275         LDKSignature signature_arg_ref;
20276         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20277         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20278         LDKUnsignedChannelUpdate contents_arg_conv;
20279         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20280         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20281         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
20282         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
20283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20285         uint64_t ret_ref = (uint64_t)ret_var.inner;
20286         if (ret_var.is_owned) {
20287                 ret_ref |= 1;
20288         }
20289         return ret_ref;
20290 }
20291
20292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20293         LDKChannelUpdate orig_conv;
20294         orig_conv.inner = (void*)(orig & (~1));
20295         orig_conv.is_owned = false;
20296         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
20297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20299         uint64_t ret_ref = (uint64_t)ret_var.inner;
20300         if (ret_var.is_owned) {
20301                 ret_ref |= 1;
20302         }
20303         return ret_ref;
20304 }
20305
20306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20307         LDKQueryChannelRange this_obj_conv;
20308         this_obj_conv.inner = (void*)(this_obj & (~1));
20309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20310         QueryChannelRange_free(this_obj_conv);
20311 }
20312
20313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20314         LDKQueryChannelRange this_ptr_conv;
20315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20316         this_ptr_conv.is_owned = false;
20317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
20319         return ret_arr;
20320 }
20321
20322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20323         LDKQueryChannelRange this_ptr_conv;
20324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20325         this_ptr_conv.is_owned = false;
20326         LDKThirtyTwoBytes val_ref;
20327         CHECK((*env)->GetArrayLength(env, val) == 32);
20328         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20329         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20330 }
20331
20332 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20333         LDKQueryChannelRange this_ptr_conv;
20334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20335         this_ptr_conv.is_owned = false;
20336         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
20337         return ret_val;
20338 }
20339
20340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20341         LDKQueryChannelRange this_ptr_conv;
20342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20343         this_ptr_conv.is_owned = false;
20344         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
20345 }
20346
20347 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20348         LDKQueryChannelRange this_ptr_conv;
20349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20350         this_ptr_conv.is_owned = false;
20351         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
20352         return ret_val;
20353 }
20354
20355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20356         LDKQueryChannelRange this_ptr_conv;
20357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20358         this_ptr_conv.is_owned = false;
20359         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20360 }
20361
20362 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) {
20363         LDKThirtyTwoBytes chain_hash_arg_ref;
20364         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20365         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20366         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
20367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20369         uint64_t ret_ref = (uint64_t)ret_var.inner;
20370         if (ret_var.is_owned) {
20371                 ret_ref |= 1;
20372         }
20373         return ret_ref;
20374 }
20375
20376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20377         LDKQueryChannelRange orig_conv;
20378         orig_conv.inner = (void*)(orig & (~1));
20379         orig_conv.is_owned = false;
20380         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
20381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20383         uint64_t ret_ref = (uint64_t)ret_var.inner;
20384         if (ret_var.is_owned) {
20385                 ret_ref |= 1;
20386         }
20387         return ret_ref;
20388 }
20389
20390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20391         LDKReplyChannelRange this_obj_conv;
20392         this_obj_conv.inner = (void*)(this_obj & (~1));
20393         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20394         ReplyChannelRange_free(this_obj_conv);
20395 }
20396
20397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20398         LDKReplyChannelRange this_ptr_conv;
20399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20400         this_ptr_conv.is_owned = false;
20401         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20402         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
20403         return ret_arr;
20404 }
20405
20406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20407         LDKReplyChannelRange this_ptr_conv;
20408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20409         this_ptr_conv.is_owned = false;
20410         LDKThirtyTwoBytes val_ref;
20411         CHECK((*env)->GetArrayLength(env, val) == 32);
20412         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20413         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20414 }
20415
20416 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20417         LDKReplyChannelRange this_ptr_conv;
20418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20419         this_ptr_conv.is_owned = false;
20420         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20421         return ret_val;
20422 }
20423
20424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20425         LDKReplyChannelRange this_ptr_conv;
20426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20427         this_ptr_conv.is_owned = false;
20428         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20429 }
20430
20431 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20432         LDKReplyChannelRange this_ptr_conv;
20433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20434         this_ptr_conv.is_owned = false;
20435         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20436         return ret_val;
20437 }
20438
20439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20440         LDKReplyChannelRange this_ptr_conv;
20441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20442         this_ptr_conv.is_owned = false;
20443         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20444 }
20445
20446 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
20447         LDKReplyChannelRange this_ptr_conv;
20448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20449         this_ptr_conv.is_owned = false;
20450         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20451         return ret_val;
20452 }
20453
20454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20455         LDKReplyChannelRange this_ptr_conv;
20456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20457         this_ptr_conv.is_owned = false;
20458         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20459 }
20460
20461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20462         LDKReplyChannelRange this_ptr_conv;
20463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20464         this_ptr_conv.is_owned = false;
20465         LDKCVec_u64Z val_constr;
20466         val_constr.datalen = (*env)->GetArrayLength(env, val);
20467         if (val_constr.datalen > 0)
20468                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20469         else
20470                 val_constr.data = NULL;
20471         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20472         for (size_t g = 0; g < val_constr.datalen; g++) {
20473                 int64_t val_conv_6 = val_vals[g];
20474                 val_constr.data[g] = val_conv_6;
20475         }
20476         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20477         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20478 }
20479
20480 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) {
20481         LDKThirtyTwoBytes chain_hash_arg_ref;
20482         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20483         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20484         LDKCVec_u64Z short_channel_ids_arg_constr;
20485         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20486         if (short_channel_ids_arg_constr.datalen > 0)
20487                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20488         else
20489                 short_channel_ids_arg_constr.data = NULL;
20490         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20491         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20492                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20493                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20494         }
20495         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20496         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20497         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20498         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20499         uint64_t ret_ref = (uint64_t)ret_var.inner;
20500         if (ret_var.is_owned) {
20501                 ret_ref |= 1;
20502         }
20503         return ret_ref;
20504 }
20505
20506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20507         LDKReplyChannelRange orig_conv;
20508         orig_conv.inner = (void*)(orig & (~1));
20509         orig_conv.is_owned = false;
20510         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20513         uint64_t ret_ref = (uint64_t)ret_var.inner;
20514         if (ret_var.is_owned) {
20515                 ret_ref |= 1;
20516         }
20517         return ret_ref;
20518 }
20519
20520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20521         LDKQueryShortChannelIds this_obj_conv;
20522         this_obj_conv.inner = (void*)(this_obj & (~1));
20523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20524         QueryShortChannelIds_free(this_obj_conv);
20525 }
20526
20527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20528         LDKQueryShortChannelIds this_ptr_conv;
20529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20530         this_ptr_conv.is_owned = false;
20531         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
20533         return ret_arr;
20534 }
20535
20536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20537         LDKQueryShortChannelIds this_ptr_conv;
20538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20539         this_ptr_conv.is_owned = false;
20540         LDKThirtyTwoBytes val_ref;
20541         CHECK((*env)->GetArrayLength(env, val) == 32);
20542         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20543         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
20544 }
20545
20546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20547         LDKQueryShortChannelIds this_ptr_conv;
20548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20549         this_ptr_conv.is_owned = false;
20550         LDKCVec_u64Z val_constr;
20551         val_constr.datalen = (*env)->GetArrayLength(env, val);
20552         if (val_constr.datalen > 0)
20553                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20554         else
20555                 val_constr.data = NULL;
20556         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20557         for (size_t g = 0; g < val_constr.datalen; g++) {
20558                 int64_t val_conv_6 = val_vals[g];
20559                 val_constr.data[g] = val_conv_6;
20560         }
20561         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20562         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
20563 }
20564
20565 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) {
20566         LDKThirtyTwoBytes chain_hash_arg_ref;
20567         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20568         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20569         LDKCVec_u64Z short_channel_ids_arg_constr;
20570         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20571         if (short_channel_ids_arg_constr.datalen > 0)
20572                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20573         else
20574                 short_channel_ids_arg_constr.data = NULL;
20575         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20576         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20577                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20578                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20579         }
20580         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20581         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
20582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20584         uint64_t ret_ref = (uint64_t)ret_var.inner;
20585         if (ret_var.is_owned) {
20586                 ret_ref |= 1;
20587         }
20588         return ret_ref;
20589 }
20590
20591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20592         LDKQueryShortChannelIds orig_conv;
20593         orig_conv.inner = (void*)(orig & (~1));
20594         orig_conv.is_owned = false;
20595         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
20596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20598         uint64_t ret_ref = (uint64_t)ret_var.inner;
20599         if (ret_var.is_owned) {
20600                 ret_ref |= 1;
20601         }
20602         return ret_ref;
20603 }
20604
20605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20606         LDKReplyShortChannelIdsEnd this_obj_conv;
20607         this_obj_conv.inner = (void*)(this_obj & (~1));
20608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20609         ReplyShortChannelIdsEnd_free(this_obj_conv);
20610 }
20611
20612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20613         LDKReplyShortChannelIdsEnd this_ptr_conv;
20614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20615         this_ptr_conv.is_owned = false;
20616         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20617         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
20618         return ret_arr;
20619 }
20620
20621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20622         LDKReplyShortChannelIdsEnd this_ptr_conv;
20623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20624         this_ptr_conv.is_owned = false;
20625         LDKThirtyTwoBytes val_ref;
20626         CHECK((*env)->GetArrayLength(env, val) == 32);
20627         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20628         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
20629 }
20630
20631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
20632         LDKReplyShortChannelIdsEnd this_ptr_conv;
20633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20634         this_ptr_conv.is_owned = false;
20635         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20636         return ret_val;
20637 }
20638
20639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20640         LDKReplyShortChannelIdsEnd this_ptr_conv;
20641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20642         this_ptr_conv.is_owned = false;
20643         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20644 }
20645
20646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
20647         LDKThirtyTwoBytes chain_hash_arg_ref;
20648         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20649         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20650         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20653         uint64_t ret_ref = (uint64_t)ret_var.inner;
20654         if (ret_var.is_owned) {
20655                 ret_ref |= 1;
20656         }
20657         return ret_ref;
20658 }
20659
20660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20661         LDKReplyShortChannelIdsEnd orig_conv;
20662         orig_conv.inner = (void*)(orig & (~1));
20663         orig_conv.is_owned = false;
20664         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20667         uint64_t ret_ref = (uint64_t)ret_var.inner;
20668         if (ret_var.is_owned) {
20669                 ret_ref |= 1;
20670         }
20671         return ret_ref;
20672 }
20673
20674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20675         LDKGossipTimestampFilter this_obj_conv;
20676         this_obj_conv.inner = (void*)(this_obj & (~1));
20677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20678         GossipTimestampFilter_free(this_obj_conv);
20679 }
20680
20681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20682         LDKGossipTimestampFilter this_ptr_conv;
20683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20684         this_ptr_conv.is_owned = false;
20685         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
20687         return ret_arr;
20688 }
20689
20690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20691         LDKGossipTimestampFilter this_ptr_conv;
20692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20693         this_ptr_conv.is_owned = false;
20694         LDKThirtyTwoBytes val_ref;
20695         CHECK((*env)->GetArrayLength(env, val) == 32);
20696         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20697         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20698 }
20699
20700 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20701         LDKGossipTimestampFilter this_ptr_conv;
20702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20703         this_ptr_conv.is_owned = false;
20704         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20705         return ret_val;
20706 }
20707
20708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20709         LDKGossipTimestampFilter this_ptr_conv;
20710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20711         this_ptr_conv.is_owned = false;
20712         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20713 }
20714
20715 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20716         LDKGossipTimestampFilter this_ptr_conv;
20717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20718         this_ptr_conv.is_owned = false;
20719         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20720         return ret_val;
20721 }
20722
20723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20724         LDKGossipTimestampFilter this_ptr_conv;
20725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20726         this_ptr_conv.is_owned = false;
20727         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20728 }
20729
20730 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) {
20731         LDKThirtyTwoBytes chain_hash_arg_ref;
20732         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20733         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20734         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20737         uint64_t ret_ref = (uint64_t)ret_var.inner;
20738         if (ret_var.is_owned) {
20739                 ret_ref |= 1;
20740         }
20741         return ret_ref;
20742 }
20743
20744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20745         LDKGossipTimestampFilter orig_conv;
20746         orig_conv.inner = (void*)(orig & (~1));
20747         orig_conv.is_owned = false;
20748         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20751         uint64_t ret_ref = (uint64_t)ret_var.inner;
20752         if (ret_var.is_owned) {
20753                 ret_ref |= 1;
20754         }
20755         return ret_ref;
20756 }
20757
20758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20759         if ((this_ptr & 1) != 0) return;
20760         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20761         FREE((void*)this_ptr);
20762         ErrorAction_free(this_ptr_conv);
20763 }
20764
20765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20766         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20767         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20768         *ret_copy = ErrorAction_clone(orig_conv);
20769         uint64_t ret_ref = (uint64_t)ret_copy;
20770         return ret_ref;
20771 }
20772
20773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
20774         LDKErrorMessage msg_conv;
20775         msg_conv.inner = (void*)(msg & (~1));
20776         msg_conv.is_owned = (msg & 1) || (msg == 0);
20777         msg_conv = ErrorMessage_clone(&msg_conv);
20778         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20779         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
20780         uint64_t ret_ref = (uint64_t)ret_copy;
20781         return ret_ref;
20782 }
20783
20784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
20785         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20786         *ret_copy = ErrorAction_ignore_error();
20787         uint64_t ret_ref = (uint64_t)ret_copy;
20788         return ret_ref;
20789 }
20790
20791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
20792         LDKLevel a_conv = LDKLevel_from_java(env, a);
20793         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20794         *ret_copy = ErrorAction_ignore_and_log(a_conv);
20795         uint64_t ret_ref = (uint64_t)ret_copy;
20796         return ret_ref;
20797 }
20798
20799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
20800         LDKErrorMessage msg_conv;
20801         msg_conv.inner = (void*)(msg & (~1));
20802         msg_conv.is_owned = (msg & 1) || (msg == 0);
20803         msg_conv = ErrorMessage_clone(&msg_conv);
20804         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20805         *ret_copy = ErrorAction_send_error_message(msg_conv);
20806         uint64_t ret_ref = (uint64_t)ret_copy;
20807         return ret_ref;
20808 }
20809
20810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20811         LDKLightningError this_obj_conv;
20812         this_obj_conv.inner = (void*)(this_obj & (~1));
20813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20814         LightningError_free(this_obj_conv);
20815 }
20816
20817 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
20818         LDKLightningError this_ptr_conv;
20819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20820         this_ptr_conv.is_owned = false;
20821         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20822         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20823         Str_free(ret_str);
20824         return ret_conv;
20825 }
20826
20827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20828         LDKLightningError this_ptr_conv;
20829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20830         this_ptr_conv.is_owned = false;
20831         LDKStr val_conv = java_to_owned_str(env, val);
20832         LightningError_set_err(&this_ptr_conv, val_conv);
20833 }
20834
20835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
20836         LDKLightningError this_ptr_conv;
20837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20838         this_ptr_conv.is_owned = false;
20839         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20840         *ret_copy = LightningError_get_action(&this_ptr_conv);
20841         uint64_t ret_ref = (uint64_t)ret_copy;
20842         return ret_ref;
20843 }
20844
20845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20846         LDKLightningError this_ptr_conv;
20847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20848         this_ptr_conv.is_owned = false;
20849         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20850         LightningError_set_action(&this_ptr_conv, val_conv);
20851 }
20852
20853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
20854         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
20855         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20856         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20859         uint64_t ret_ref = (uint64_t)ret_var.inner;
20860         if (ret_var.is_owned) {
20861                 ret_ref |= 1;
20862         }
20863         return ret_ref;
20864 }
20865
20866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20867         LDKLightningError orig_conv;
20868         orig_conv.inner = (void*)(orig & (~1));
20869         orig_conv.is_owned = false;
20870         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20871         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20872         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20873         uint64_t ret_ref = (uint64_t)ret_var.inner;
20874         if (ret_var.is_owned) {
20875                 ret_ref |= 1;
20876         }
20877         return ret_ref;
20878 }
20879
20880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20881         LDKCommitmentUpdate this_obj_conv;
20882         this_obj_conv.inner = (void*)(this_obj & (~1));
20883         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20884         CommitmentUpdate_free(this_obj_conv);
20885 }
20886
20887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20888         LDKCommitmentUpdate this_ptr_conv;
20889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20890         this_ptr_conv.is_owned = false;
20891         LDKCVec_UpdateAddHTLCZ val_constr;
20892         val_constr.datalen = (*env)->GetArrayLength(env, val);
20893         if (val_constr.datalen > 0)
20894                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20895         else
20896                 val_constr.data = NULL;
20897         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20898         for (size_t p = 0; p < val_constr.datalen; p++) {
20899                 int64_t val_conv_15 = val_vals[p];
20900                 LDKUpdateAddHTLC val_conv_15_conv;
20901                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20902                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20903                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20904                 val_constr.data[p] = val_conv_15_conv;
20905         }
20906         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20907         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20908 }
20909
20910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20911         LDKCommitmentUpdate this_ptr_conv;
20912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20913         this_ptr_conv.is_owned = false;
20914         LDKCVec_UpdateFulfillHTLCZ val_constr;
20915         val_constr.datalen = (*env)->GetArrayLength(env, val);
20916         if (val_constr.datalen > 0)
20917                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20918         else
20919                 val_constr.data = NULL;
20920         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20921         for (size_t t = 0; t < val_constr.datalen; t++) {
20922                 int64_t val_conv_19 = val_vals[t];
20923                 LDKUpdateFulfillHTLC val_conv_19_conv;
20924                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20925                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20926                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20927                 val_constr.data[t] = val_conv_19_conv;
20928         }
20929         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20930         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20931 }
20932
20933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20934         LDKCommitmentUpdate this_ptr_conv;
20935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20936         this_ptr_conv.is_owned = false;
20937         LDKCVec_UpdateFailHTLCZ val_constr;
20938         val_constr.datalen = (*env)->GetArrayLength(env, val);
20939         if (val_constr.datalen > 0)
20940                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20941         else
20942                 val_constr.data = NULL;
20943         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20944         for (size_t q = 0; q < val_constr.datalen; q++) {
20945                 int64_t val_conv_16 = val_vals[q];
20946                 LDKUpdateFailHTLC val_conv_16_conv;
20947                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20948                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20949                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20950                 val_constr.data[q] = val_conv_16_conv;
20951         }
20952         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20953         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20954 }
20955
20956 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) {
20957         LDKCommitmentUpdate this_ptr_conv;
20958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20959         this_ptr_conv.is_owned = false;
20960         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20961         val_constr.datalen = (*env)->GetArrayLength(env, val);
20962         if (val_constr.datalen > 0)
20963                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20964         else
20965                 val_constr.data = NULL;
20966         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20967         for (size_t z = 0; z < val_constr.datalen; z++) {
20968                 int64_t val_conv_25 = val_vals[z];
20969                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20970                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20971                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20972                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20973                 val_constr.data[z] = val_conv_25_conv;
20974         }
20975         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20976         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20977 }
20978
20979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
20980         LDKCommitmentUpdate this_ptr_conv;
20981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20982         this_ptr_conv.is_owned = false;
20983         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20986         uint64_t ret_ref = (uint64_t)ret_var.inner;
20987         if (ret_var.is_owned) {
20988                 ret_ref |= 1;
20989         }
20990         return ret_ref;
20991 }
20992
20993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20994         LDKCommitmentUpdate this_ptr_conv;
20995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20996         this_ptr_conv.is_owned = false;
20997         LDKUpdateFee val_conv;
20998         val_conv.inner = (void*)(val & (~1));
20999         val_conv.is_owned = (val & 1) || (val == 0);
21000         val_conv = UpdateFee_clone(&val_conv);
21001         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
21002 }
21003
21004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
21005         LDKCommitmentUpdate this_ptr_conv;
21006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21007         this_ptr_conv.is_owned = false;
21008         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
21009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21011         uint64_t ret_ref = (uint64_t)ret_var.inner;
21012         if (ret_var.is_owned) {
21013                 ret_ref |= 1;
21014         }
21015         return ret_ref;
21016 }
21017
21018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21019         LDKCommitmentUpdate this_ptr_conv;
21020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21021         this_ptr_conv.is_owned = false;
21022         LDKCommitmentSigned val_conv;
21023         val_conv.inner = (void*)(val & (~1));
21024         val_conv.is_owned = (val & 1) || (val == 0);
21025         val_conv = CommitmentSigned_clone(&val_conv);
21026         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
21027 }
21028
21029 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) {
21030         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
21031         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
21032         if (update_add_htlcs_arg_constr.datalen > 0)
21033                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21034         else
21035                 update_add_htlcs_arg_constr.data = NULL;
21036         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
21037         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
21038                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
21039                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
21040                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
21041                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
21042                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
21043                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
21044         }
21045         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
21046         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
21047         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
21048         if (update_fulfill_htlcs_arg_constr.datalen > 0)
21049                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21050         else
21051                 update_fulfill_htlcs_arg_constr.data = NULL;
21052         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
21053         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
21054                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
21055                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
21056                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
21057                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
21058                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
21059                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
21060         }
21061         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
21062         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
21063         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
21064         if (update_fail_htlcs_arg_constr.datalen > 0)
21065                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21066         else
21067                 update_fail_htlcs_arg_constr.data = NULL;
21068         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
21069         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
21070                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
21071                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
21072                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
21073                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
21074                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
21075                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
21076         }
21077         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
21078         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
21079         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
21080         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
21081                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21082         else
21083                 update_fail_malformed_htlcs_arg_constr.data = NULL;
21084         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
21085         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
21086                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
21087                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
21088                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
21089                 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);
21090                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
21091                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
21092         }
21093         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
21094         LDKUpdateFee update_fee_arg_conv;
21095         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
21096         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
21097         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
21098         LDKCommitmentSigned commitment_signed_arg_conv;
21099         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
21100         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
21101         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
21102         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);
21103         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21104         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21105         uint64_t ret_ref = (uint64_t)ret_var.inner;
21106         if (ret_var.is_owned) {
21107                 ret_ref |= 1;
21108         }
21109         return ret_ref;
21110 }
21111
21112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21113         LDKCommitmentUpdate orig_conv;
21114         orig_conv.inner = (void*)(orig & (~1));
21115         orig_conv.is_owned = false;
21116         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
21117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21119         uint64_t ret_ref = (uint64_t)ret_var.inner;
21120         if (ret_var.is_owned) {
21121                 ret_ref |= 1;
21122         }
21123         return ret_ref;
21124 }
21125
21126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21127         if ((this_ptr & 1) != 0) return;
21128         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
21129         FREE((void*)this_ptr);
21130         HTLCFailChannelUpdate_free(this_ptr_conv);
21131 }
21132
21133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21134         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
21135         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21136         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
21137         uint64_t ret_ref = (uint64_t)ret_copy;
21138         return ret_ref;
21139 }
21140
21141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
21142         LDKChannelUpdate msg_conv;
21143         msg_conv.inner = (void*)(msg & (~1));
21144         msg_conv.is_owned = (msg & 1) || (msg == 0);
21145         msg_conv = ChannelUpdate_clone(&msg_conv);
21146         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21147         *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv);
21148         uint64_t ret_ref = (uint64_t)ret_copy;
21149         return ret_ref;
21150 }
21151
21152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
21153         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21154         *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent);
21155         uint64_t ret_ref = (uint64_t)ret_copy;
21156         return ret_ref;
21157 }
21158
21159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
21160         LDKPublicKey node_id_ref;
21161         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21162         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21163         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21164         *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent);
21165         uint64_t ret_ref = (uint64_t)ret_copy;
21166         return ret_ref;
21167 }
21168
21169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21170         if ((this_ptr & 1) != 0) return;
21171         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
21172         FREE((void*)this_ptr);
21173         ChannelMessageHandler_free(this_ptr_conv);
21174 }
21175
21176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21177         if ((this_ptr & 1) != 0) return;
21178         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
21179         FREE((void*)this_ptr);
21180         RoutingMessageHandler_free(this_ptr_conv);
21181 }
21182
21183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21184         LDKAcceptChannel obj_conv;
21185         obj_conv.inner = (void*)(obj & (~1));
21186         obj_conv.is_owned = false;
21187         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
21188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21190         CVec_u8Z_free(ret_var);
21191         return ret_arr;
21192 }
21193
21194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21195         LDKu8slice ser_ref;
21196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21198         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21199         *ret_conv = AcceptChannel_read(ser_ref);
21200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21201         return (uint64_t)ret_conv;
21202 }
21203
21204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
21205         LDKAnnouncementSignatures obj_conv;
21206         obj_conv.inner = (void*)(obj & (~1));
21207         obj_conv.is_owned = false;
21208         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
21209         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21210         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21211         CVec_u8Z_free(ret_var);
21212         return ret_arr;
21213 }
21214
21215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21216         LDKu8slice ser_ref;
21217         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21218         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21219         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21220         *ret_conv = AnnouncementSignatures_read(ser_ref);
21221         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21222         return (uint64_t)ret_conv;
21223 }
21224
21225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
21226         LDKChannelReestablish obj_conv;
21227         obj_conv.inner = (void*)(obj & (~1));
21228         obj_conv.is_owned = false;
21229         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
21230         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21231         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21232         CVec_u8Z_free(ret_var);
21233         return ret_arr;
21234 }
21235
21236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21237         LDKu8slice ser_ref;
21238         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21239         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21240         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21241         *ret_conv = ChannelReestablish_read(ser_ref);
21242         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21243         return (uint64_t)ret_conv;
21244 }
21245
21246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21247         LDKClosingSigned obj_conv;
21248         obj_conv.inner = (void*)(obj & (~1));
21249         obj_conv.is_owned = false;
21250         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
21251         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21252         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21253         CVec_u8Z_free(ret_var);
21254         return ret_arr;
21255 }
21256
21257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21258         LDKu8slice ser_ref;
21259         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21260         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21261         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21262         *ret_conv = ClosingSigned_read(ser_ref);
21263         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21264         return (uint64_t)ret_conv;
21265 }
21266
21267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21268         LDKCommitmentSigned obj_conv;
21269         obj_conv.inner = (void*)(obj & (~1));
21270         obj_conv.is_owned = false;
21271         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
21272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21274         CVec_u8Z_free(ret_var);
21275         return ret_arr;
21276 }
21277
21278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21279         LDKu8slice ser_ref;
21280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21282         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21283         *ret_conv = CommitmentSigned_read(ser_ref);
21284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21285         return (uint64_t)ret_conv;
21286 }
21287
21288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
21289         LDKFundingCreated obj_conv;
21290         obj_conv.inner = (void*)(obj & (~1));
21291         obj_conv.is_owned = false;
21292         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
21293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21295         CVec_u8Z_free(ret_var);
21296         return ret_arr;
21297 }
21298
21299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21300         LDKu8slice ser_ref;
21301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21303         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21304         *ret_conv = FundingCreated_read(ser_ref);
21305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21306         return (uint64_t)ret_conv;
21307 }
21308
21309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21310         LDKFundingSigned obj_conv;
21311         obj_conv.inner = (void*)(obj & (~1));
21312         obj_conv.is_owned = false;
21313         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
21314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21316         CVec_u8Z_free(ret_var);
21317         return ret_arr;
21318 }
21319
21320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21321         LDKu8slice ser_ref;
21322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21324         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21325         *ret_conv = FundingSigned_read(ser_ref);
21326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21327         return (uint64_t)ret_conv;
21328 }
21329
21330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
21331         LDKFundingLocked obj_conv;
21332         obj_conv.inner = (void*)(obj & (~1));
21333         obj_conv.is_owned = false;
21334         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
21335         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21336         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21337         CVec_u8Z_free(ret_var);
21338         return ret_arr;
21339 }
21340
21341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21342         LDKu8slice ser_ref;
21343         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21344         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21345         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21346         *ret_conv = FundingLocked_read(ser_ref);
21347         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21348         return (uint64_t)ret_conv;
21349 }
21350
21351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
21352         LDKInit obj_conv;
21353         obj_conv.inner = (void*)(obj & (~1));
21354         obj_conv.is_owned = false;
21355         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
21356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21358         CVec_u8Z_free(ret_var);
21359         return ret_arr;
21360 }
21361
21362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21363         LDKu8slice ser_ref;
21364         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21365         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21366         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21367         *ret_conv = Init_read(ser_ref);
21368         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21369         return (uint64_t)ret_conv;
21370 }
21371
21372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21373         LDKOpenChannel obj_conv;
21374         obj_conv.inner = (void*)(obj & (~1));
21375         obj_conv.is_owned = false;
21376         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
21377         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21378         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21379         CVec_u8Z_free(ret_var);
21380         return ret_arr;
21381 }
21382
21383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21384         LDKu8slice ser_ref;
21385         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21386         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21387         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21388         *ret_conv = OpenChannel_read(ser_ref);
21389         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21390         return (uint64_t)ret_conv;
21391 }
21392
21393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
21394         LDKRevokeAndACK obj_conv;
21395         obj_conv.inner = (void*)(obj & (~1));
21396         obj_conv.is_owned = false;
21397         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
21398         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21399         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21400         CVec_u8Z_free(ret_var);
21401         return ret_arr;
21402 }
21403
21404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21405         LDKu8slice ser_ref;
21406         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21407         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21408         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21409         *ret_conv = RevokeAndACK_read(ser_ref);
21410         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21411         return (uint64_t)ret_conv;
21412 }
21413
21414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
21415         LDKShutdown obj_conv;
21416         obj_conv.inner = (void*)(obj & (~1));
21417         obj_conv.is_owned = false;
21418         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
21419         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21420         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21421         CVec_u8Z_free(ret_var);
21422         return ret_arr;
21423 }
21424
21425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21426         LDKu8slice ser_ref;
21427         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21428         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21429         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21430         *ret_conv = Shutdown_read(ser_ref);
21431         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21432         return (uint64_t)ret_conv;
21433 }
21434
21435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21436         LDKUpdateFailHTLC obj_conv;
21437         obj_conv.inner = (void*)(obj & (~1));
21438         obj_conv.is_owned = false;
21439         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
21440         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21441         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21442         CVec_u8Z_free(ret_var);
21443         return ret_arr;
21444 }
21445
21446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21447         LDKu8slice ser_ref;
21448         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21449         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21450         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21451         *ret_conv = UpdateFailHTLC_read(ser_ref);
21452         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21453         return (uint64_t)ret_conv;
21454 }
21455
21456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21457         LDKUpdateFailMalformedHTLC obj_conv;
21458         obj_conv.inner = (void*)(obj & (~1));
21459         obj_conv.is_owned = false;
21460         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
21461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21463         CVec_u8Z_free(ret_var);
21464         return ret_arr;
21465 }
21466
21467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21468         LDKu8slice ser_ref;
21469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21471         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21472         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21474         return (uint64_t)ret_conv;
21475 }
21476
21477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
21478         LDKUpdateFee obj_conv;
21479         obj_conv.inner = (void*)(obj & (~1));
21480         obj_conv.is_owned = false;
21481         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21484         CVec_u8Z_free(ret_var);
21485         return ret_arr;
21486 }
21487
21488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21489         LDKu8slice ser_ref;
21490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21492         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21493         *ret_conv = UpdateFee_read(ser_ref);
21494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21495         return (uint64_t)ret_conv;
21496 }
21497
21498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21499         LDKUpdateFulfillHTLC obj_conv;
21500         obj_conv.inner = (void*)(obj & (~1));
21501         obj_conv.is_owned = false;
21502         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21503         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21504         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21505         CVec_u8Z_free(ret_var);
21506         return ret_arr;
21507 }
21508
21509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21510         LDKu8slice ser_ref;
21511         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21512         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21513         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21514         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
21515         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21516         return (uint64_t)ret_conv;
21517 }
21518
21519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21520         LDKUpdateAddHTLC obj_conv;
21521         obj_conv.inner = (void*)(obj & (~1));
21522         obj_conv.is_owned = false;
21523         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
21524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21526         CVec_u8Z_free(ret_var);
21527         return ret_arr;
21528 }
21529
21530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21531         LDKu8slice ser_ref;
21532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21534         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21535         *ret_conv = UpdateAddHTLC_read(ser_ref);
21536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21537         return (uint64_t)ret_conv;
21538 }
21539
21540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
21541         LDKPing obj_conv;
21542         obj_conv.inner = (void*)(obj & (~1));
21543         obj_conv.is_owned = false;
21544         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
21545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21547         CVec_u8Z_free(ret_var);
21548         return ret_arr;
21549 }
21550
21551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21552         LDKu8slice ser_ref;
21553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21555         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21556         *ret_conv = Ping_read(ser_ref);
21557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21558         return (uint64_t)ret_conv;
21559 }
21560
21561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
21562         LDKPong obj_conv;
21563         obj_conv.inner = (void*)(obj & (~1));
21564         obj_conv.is_owned = false;
21565         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
21566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21568         CVec_u8Z_free(ret_var);
21569         return ret_arr;
21570 }
21571
21572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21573         LDKu8slice ser_ref;
21574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21576         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21577         *ret_conv = Pong_read(ser_ref);
21578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21579         return (uint64_t)ret_conv;
21580 }
21581
21582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21583         LDKUnsignedChannelAnnouncement obj_conv;
21584         obj_conv.inner = (void*)(obj & (~1));
21585         obj_conv.is_owned = false;
21586         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
21587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21589         CVec_u8Z_free(ret_var);
21590         return ret_arr;
21591 }
21592
21593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21594         LDKu8slice ser_ref;
21595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21597         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21598         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
21599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21600         return (uint64_t)ret_conv;
21601 }
21602
21603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21604         LDKChannelAnnouncement obj_conv;
21605         obj_conv.inner = (void*)(obj & (~1));
21606         obj_conv.is_owned = false;
21607         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
21608         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21609         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21610         CVec_u8Z_free(ret_var);
21611         return ret_arr;
21612 }
21613
21614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21615         LDKu8slice ser_ref;
21616         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21617         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21618         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21619         *ret_conv = ChannelAnnouncement_read(ser_ref);
21620         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21621         return (uint64_t)ret_conv;
21622 }
21623
21624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21625         LDKUnsignedChannelUpdate obj_conv;
21626         obj_conv.inner = (void*)(obj & (~1));
21627         obj_conv.is_owned = false;
21628         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
21629         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21630         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21631         CVec_u8Z_free(ret_var);
21632         return ret_arr;
21633 }
21634
21635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21636         LDKu8slice ser_ref;
21637         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21638         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21639         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21640         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
21641         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21642         return (uint64_t)ret_conv;
21643 }
21644
21645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21646         LDKChannelUpdate obj_conv;
21647         obj_conv.inner = (void*)(obj & (~1));
21648         obj_conv.is_owned = false;
21649         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
21650         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21651         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21652         CVec_u8Z_free(ret_var);
21653         return ret_arr;
21654 }
21655
21656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21657         LDKu8slice ser_ref;
21658         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21659         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21660         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21661         *ret_conv = ChannelUpdate_read(ser_ref);
21662         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21663         return (uint64_t)ret_conv;
21664 }
21665
21666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
21667         LDKErrorMessage obj_conv;
21668         obj_conv.inner = (void*)(obj & (~1));
21669         obj_conv.is_owned = false;
21670         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
21671         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21672         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21673         CVec_u8Z_free(ret_var);
21674         return ret_arr;
21675 }
21676
21677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21678         LDKu8slice ser_ref;
21679         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21680         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21681         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21682         *ret_conv = ErrorMessage_read(ser_ref);
21683         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21684         return (uint64_t)ret_conv;
21685 }
21686
21687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21688         LDKUnsignedNodeAnnouncement obj_conv;
21689         obj_conv.inner = (void*)(obj & (~1));
21690         obj_conv.is_owned = false;
21691         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
21692         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21693         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21694         CVec_u8Z_free(ret_var);
21695         return ret_arr;
21696 }
21697
21698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21699         LDKu8slice ser_ref;
21700         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21701         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21702         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21703         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21704         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21705         return (uint64_t)ret_conv;
21706 }
21707
21708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21709         LDKNodeAnnouncement obj_conv;
21710         obj_conv.inner = (void*)(obj & (~1));
21711         obj_conv.is_owned = false;
21712         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21713         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21714         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21715         CVec_u8Z_free(ret_var);
21716         return ret_arr;
21717 }
21718
21719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21720         LDKu8slice ser_ref;
21721         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21722         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21723         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21724         *ret_conv = NodeAnnouncement_read(ser_ref);
21725         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21726         return (uint64_t)ret_conv;
21727 }
21728
21729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21730         LDKu8slice ser_ref;
21731         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21732         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21733         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21734         *ret_conv = QueryShortChannelIds_read(ser_ref);
21735         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21736         return (uint64_t)ret_conv;
21737 }
21738
21739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
21740         LDKQueryShortChannelIds obj_conv;
21741         obj_conv.inner = (void*)(obj & (~1));
21742         obj_conv.is_owned = false;
21743         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21744         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21745         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21746         CVec_u8Z_free(ret_var);
21747         return ret_arr;
21748 }
21749
21750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21751         LDKu8slice ser_ref;
21752         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21753         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21754         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21755         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21756         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21757         return (uint64_t)ret_conv;
21758 }
21759
21760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
21761         LDKReplyShortChannelIdsEnd obj_conv;
21762         obj_conv.inner = (void*)(obj & (~1));
21763         obj_conv.is_owned = false;
21764         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21765         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21766         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21767         CVec_u8Z_free(ret_var);
21768         return ret_arr;
21769 }
21770
21771 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
21772         LDKQueryChannelRange this_arg_conv;
21773         this_arg_conv.inner = (void*)(this_arg & (~1));
21774         this_arg_conv.is_owned = false;
21775         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21776         return ret_val;
21777 }
21778
21779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21780         LDKu8slice ser_ref;
21781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21783         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21784         *ret_conv = QueryChannelRange_read(ser_ref);
21785         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21786         return (uint64_t)ret_conv;
21787 }
21788
21789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21790         LDKQueryChannelRange obj_conv;
21791         obj_conv.inner = (void*)(obj & (~1));
21792         obj_conv.is_owned = false;
21793         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21794         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21795         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21796         CVec_u8Z_free(ret_var);
21797         return ret_arr;
21798 }
21799
21800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21801         LDKu8slice ser_ref;
21802         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21803         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21804         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21805         *ret_conv = ReplyChannelRange_read(ser_ref);
21806         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21807         return (uint64_t)ret_conv;
21808 }
21809
21810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21811         LDKReplyChannelRange obj_conv;
21812         obj_conv.inner = (void*)(obj & (~1));
21813         obj_conv.is_owned = false;
21814         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21815         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21816         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21817         CVec_u8Z_free(ret_var);
21818         return ret_arr;
21819 }
21820
21821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21822         LDKu8slice ser_ref;
21823         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21824         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21825         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21826         *ret_conv = GossipTimestampFilter_read(ser_ref);
21827         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21828         return (uint64_t)ret_conv;
21829 }
21830
21831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
21832         LDKGossipTimestampFilter obj_conv;
21833         obj_conv.inner = (void*)(obj & (~1));
21834         obj_conv.is_owned = false;
21835         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21836         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21837         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21838         CVec_u8Z_free(ret_var);
21839         return ret_arr;
21840 }
21841
21842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21843         LDKIgnoringMessageHandler this_obj_conv;
21844         this_obj_conv.inner = (void*)(this_obj & (~1));
21845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21846         IgnoringMessageHandler_free(this_obj_conv);
21847 }
21848
21849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
21850         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21853         uint64_t ret_ref = (uint64_t)ret_var.inner;
21854         if (ret_var.is_owned) {
21855                 ret_ref |= 1;
21856         }
21857         return ret_ref;
21858 }
21859
21860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21861         LDKIgnoringMessageHandler this_arg_conv;
21862         this_arg_conv.inner = (void*)(this_arg & (~1));
21863         this_arg_conv.is_owned = false;
21864         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21865         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21866         return (uint64_t)ret;
21867 }
21868
21869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21870         LDKIgnoringMessageHandler this_arg_conv;
21871         this_arg_conv.inner = (void*)(this_arg & (~1));
21872         this_arg_conv.is_owned = false;
21873         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21874         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21875         return (uint64_t)ret;
21876 }
21877
21878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21879         LDKErroringMessageHandler this_obj_conv;
21880         this_obj_conv.inner = (void*)(this_obj & (~1));
21881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21882         ErroringMessageHandler_free(this_obj_conv);
21883 }
21884
21885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
21886         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21887         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21888         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21889         uint64_t ret_ref = (uint64_t)ret_var.inner;
21890         if (ret_var.is_owned) {
21891                 ret_ref |= 1;
21892         }
21893         return ret_ref;
21894 }
21895
21896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21897         LDKErroringMessageHandler this_arg_conv;
21898         this_arg_conv.inner = (void*)(this_arg & (~1));
21899         this_arg_conv.is_owned = false;
21900         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21901         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21902         return (uint64_t)ret;
21903 }
21904
21905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21906         LDKErroringMessageHandler this_arg_conv;
21907         this_arg_conv.inner = (void*)(this_arg & (~1));
21908         this_arg_conv.is_owned = false;
21909         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21910         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21911         return (uint64_t)ret;
21912 }
21913
21914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21915         LDKMessageHandler this_obj_conv;
21916         this_obj_conv.inner = (void*)(this_obj & (~1));
21917         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21918         MessageHandler_free(this_obj_conv);
21919 }
21920
21921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21922         LDKMessageHandler this_ptr_conv;
21923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21924         this_ptr_conv.is_owned = false;
21925         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21926         return ret_ret;
21927 }
21928
21929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21930         LDKMessageHandler this_ptr_conv;
21931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21932         this_ptr_conv.is_owned = false;
21933         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21934         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
21935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21936                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
21937         }
21938         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21939 }
21940
21941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21942         LDKMessageHandler this_ptr_conv;
21943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21944         this_ptr_conv.is_owned = false;
21945         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21946         return ret_ret;
21947 }
21948
21949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21950         LDKMessageHandler this_ptr_conv;
21951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21952         this_ptr_conv.is_owned = false;
21953         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21954         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21955                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21956                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
21957         }
21958         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21959 }
21960
21961 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) {
21962         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21963         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
21964                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21965                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
21966         }
21967         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21968         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21969                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21970                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
21971         }
21972         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21973         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21974         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21975         uint64_t ret_ref = (uint64_t)ret_var.inner;
21976         if (ret_var.is_owned) {
21977                 ret_ref |= 1;
21978         }
21979         return ret_ref;
21980 }
21981
21982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21983         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21984         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21985         *ret = SocketDescriptor_clone(orig_conv);
21986         return (uint64_t)ret;
21987 }
21988
21989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21990         if ((this_ptr & 1) != 0) return;
21991         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21992         FREE((void*)this_ptr);
21993         SocketDescriptor_free(this_ptr_conv);
21994 }
21995
21996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21997         LDKPeerHandleError this_obj_conv;
21998         this_obj_conv.inner = (void*)(this_obj & (~1));
21999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22000         PeerHandleError_free(this_obj_conv);
22001 }
22002
22003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
22004         LDKPeerHandleError this_ptr_conv;
22005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22006         this_ptr_conv.is_owned = false;
22007         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
22008         return ret_val;
22009 }
22010
22011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22012         LDKPeerHandleError this_ptr_conv;
22013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22014         this_ptr_conv.is_owned = false;
22015         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
22016 }
22017
22018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
22019         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
22020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22022         uint64_t ret_ref = (uint64_t)ret_var.inner;
22023         if (ret_var.is_owned) {
22024                 ret_ref |= 1;
22025         }
22026         return ret_ref;
22027 }
22028
22029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22030         LDKPeerHandleError orig_conv;
22031         orig_conv.inner = (void*)(orig & (~1));
22032         orig_conv.is_owned = false;
22033         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
22034         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22035         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22036         uint64_t ret_ref = (uint64_t)ret_var.inner;
22037         if (ret_var.is_owned) {
22038                 ret_ref |= 1;
22039         }
22040         return ret_ref;
22041 }
22042
22043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22044         LDKPeerManager this_obj_conv;
22045         this_obj_conv.inner = (void*)(this_obj & (~1));
22046         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22047         PeerManager_free(this_obj_conv);
22048 }
22049
22050 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) {
22051         LDKMessageHandler message_handler_conv;
22052         message_handler_conv.inner = (void*)(message_handler & (~1));
22053         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
22054         // Warning: we need a move here but no clone is available for LDKMessageHandler
22055         LDKSecretKey our_node_secret_ref;
22056         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
22057         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
22058         unsigned char ephemeral_random_data_arr[32];
22059         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
22060         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
22061         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
22062         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22063         if (logger_conv.free == LDKLogger_JCalls_free) {
22064                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22065                 LDKLogger_JCalls_cloned(&logger_conv);
22066         }
22067         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
22068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22070         uint64_t ret_ref = (uint64_t)ret_var.inner;
22071         if (ret_var.is_owned) {
22072                 ret_ref |= 1;
22073         }
22074         return ret_ref;
22075 }
22076
22077 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
22078         LDKPeerManager this_arg_conv;
22079         this_arg_conv.inner = (void*)(this_arg & (~1));
22080         this_arg_conv.is_owned = false;
22081         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
22082         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22083         ;
22084         for (size_t i = 0; i < ret_var.datalen; i++) {
22085                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
22086                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
22087                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22088         }
22089         FREE(ret_var.data);
22090         return ret_arr;
22091 }
22092
22093 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) {
22094         LDKPeerManager this_arg_conv;
22095         this_arg_conv.inner = (void*)(this_arg & (~1));
22096         this_arg_conv.is_owned = false;
22097         LDKPublicKey their_node_id_ref;
22098         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
22099         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
22100         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22101         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22103                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22104         }
22105         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22106         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
22107         return (uint64_t)ret_conv;
22108 }
22109
22110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22111         LDKPeerManager this_arg_conv;
22112         this_arg_conv.inner = (void*)(this_arg & (~1));
22113         this_arg_conv.is_owned = false;
22114         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22115         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22116                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22117                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22118         }
22119         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22120         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
22121         return (uint64_t)ret_conv;
22122 }
22123
22124 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) {
22125         LDKPeerManager this_arg_conv;
22126         this_arg_conv.inner = (void*)(this_arg & (~1));
22127         this_arg_conv.is_owned = false;
22128         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22129         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22130         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
22131         return (uint64_t)ret_conv;
22132 }
22133
22134 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) {
22135         LDKPeerManager this_arg_conv;
22136         this_arg_conv.inner = (void*)(this_arg & (~1));
22137         this_arg_conv.is_owned = false;
22138         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
22139         LDKu8slice data_ref;
22140         data_ref.datalen = (*env)->GetArrayLength(env, data);
22141         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
22142         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22143         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
22144         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
22145         return (uint64_t)ret_conv;
22146 }
22147
22148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22149         LDKPeerManager this_arg_conv;
22150         this_arg_conv.inner = (void*)(this_arg & (~1));
22151         this_arg_conv.is_owned = false;
22152         PeerManager_process_events(&this_arg_conv);
22153 }
22154
22155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22156         LDKPeerManager this_arg_conv;
22157         this_arg_conv.inner = (void*)(this_arg & (~1));
22158         this_arg_conv.is_owned = false;
22159         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22160         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
22161 }
22162
22163 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) {
22164         LDKPeerManager this_arg_conv;
22165         this_arg_conv.inner = (void*)(this_arg & (~1));
22166         this_arg_conv.is_owned = false;
22167         LDKPublicKey node_id_ref;
22168         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22169         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22170         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
22171 }
22172
22173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
22174         LDKPeerManager this_arg_conv;
22175         this_arg_conv.inner = (void*)(this_arg & (~1));
22176         this_arg_conv.is_owned = false;
22177         PeerManager_timer_tick_occurred(&this_arg_conv);
22178 }
22179
22180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
22181         unsigned char commitment_seed_arr[32];
22182         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
22183         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
22184         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
22185         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22186         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
22187         return ret_arr;
22188 }
22189
22190 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) {
22191         LDKPublicKey per_commitment_point_ref;
22192         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22193         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22194         unsigned char base_secret_arr[32];
22195         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
22196         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
22197         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
22198         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22199         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
22200         return (uint64_t)ret_conv;
22201 }
22202
22203 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) {
22204         LDKPublicKey per_commitment_point_ref;
22205         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22206         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22207         LDKPublicKey base_point_ref;
22208         CHECK((*env)->GetArrayLength(env, base_point) == 33);
22209         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
22210         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22211         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
22212         return (uint64_t)ret_conv;
22213 }
22214
22215 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) {
22216         unsigned char per_commitment_secret_arr[32];
22217         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
22218         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
22219         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
22220         unsigned char countersignatory_revocation_base_secret_arr[32];
22221         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
22222         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
22223         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
22224         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22225         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
22226         return (uint64_t)ret_conv;
22227 }
22228
22229 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) {
22230         LDKPublicKey per_commitment_point_ref;
22231         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22232         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22233         LDKPublicKey countersignatory_revocation_base_point_ref;
22234         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
22235         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
22236         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22237         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
22238         return (uint64_t)ret_conv;
22239 }
22240
22241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22242         LDKTxCreationKeys this_obj_conv;
22243         this_obj_conv.inner = (void*)(this_obj & (~1));
22244         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22245         TxCreationKeys_free(this_obj_conv);
22246 }
22247
22248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22249         LDKTxCreationKeys this_ptr_conv;
22250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22251         this_ptr_conv.is_owned = false;
22252         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
22254         return ret_arr;
22255 }
22256
22257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22258         LDKTxCreationKeys this_ptr_conv;
22259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22260         this_ptr_conv.is_owned = false;
22261         LDKPublicKey val_ref;
22262         CHECK((*env)->GetArrayLength(env, val) == 33);
22263         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22264         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
22265 }
22266
22267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22268         LDKTxCreationKeys this_ptr_conv;
22269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22270         this_ptr_conv.is_owned = false;
22271         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
22273         return ret_arr;
22274 }
22275
22276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22277         LDKTxCreationKeys this_ptr_conv;
22278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22279         this_ptr_conv.is_owned = false;
22280         LDKPublicKey val_ref;
22281         CHECK((*env)->GetArrayLength(env, val) == 33);
22282         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22283         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
22284 }
22285
22286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22287         LDKTxCreationKeys this_ptr_conv;
22288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22289         this_ptr_conv.is_owned = false;
22290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
22292         return ret_arr;
22293 }
22294
22295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22296         LDKTxCreationKeys this_ptr_conv;
22297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22298         this_ptr_conv.is_owned = false;
22299         LDKPublicKey val_ref;
22300         CHECK((*env)->GetArrayLength(env, val) == 33);
22301         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22302         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
22303 }
22304
22305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22306         LDKTxCreationKeys this_ptr_conv;
22307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22308         this_ptr_conv.is_owned = false;
22309         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
22311         return ret_arr;
22312 }
22313
22314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22315         LDKTxCreationKeys this_ptr_conv;
22316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22317         this_ptr_conv.is_owned = false;
22318         LDKPublicKey val_ref;
22319         CHECK((*env)->GetArrayLength(env, val) == 33);
22320         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22321         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
22322 }
22323
22324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22325         LDKTxCreationKeys this_ptr_conv;
22326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22327         this_ptr_conv.is_owned = false;
22328         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
22330         return ret_arr;
22331 }
22332
22333 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) {
22334         LDKTxCreationKeys this_ptr_conv;
22335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22336         this_ptr_conv.is_owned = false;
22337         LDKPublicKey val_ref;
22338         CHECK((*env)->GetArrayLength(env, val) == 33);
22339         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22340         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
22341 }
22342
22343 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) {
22344         LDKPublicKey per_commitment_point_arg_ref;
22345         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
22346         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
22347         LDKPublicKey revocation_key_arg_ref;
22348         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
22349         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
22350         LDKPublicKey broadcaster_htlc_key_arg_ref;
22351         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
22352         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
22353         LDKPublicKey countersignatory_htlc_key_arg_ref;
22354         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
22355         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
22356         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
22357         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
22358         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
22359         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);
22360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22362         uint64_t ret_ref = (uint64_t)ret_var.inner;
22363         if (ret_var.is_owned) {
22364                 ret_ref |= 1;
22365         }
22366         return ret_ref;
22367 }
22368
22369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22370         LDKTxCreationKeys orig_conv;
22371         orig_conv.inner = (void*)(orig & (~1));
22372         orig_conv.is_owned = false;
22373         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
22374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22376         uint64_t ret_ref = (uint64_t)ret_var.inner;
22377         if (ret_var.is_owned) {
22378                 ret_ref |= 1;
22379         }
22380         return ret_ref;
22381 }
22382
22383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22384         LDKTxCreationKeys obj_conv;
22385         obj_conv.inner = (void*)(obj & (~1));
22386         obj_conv.is_owned = false;
22387         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
22388         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22389         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22390         CVec_u8Z_free(ret_var);
22391         return ret_arr;
22392 }
22393
22394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22395         LDKu8slice ser_ref;
22396         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22397         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22398         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
22399         *ret_conv = TxCreationKeys_read(ser_ref);
22400         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22401         return (uint64_t)ret_conv;
22402 }
22403
22404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22405         LDKChannelPublicKeys this_obj_conv;
22406         this_obj_conv.inner = (void*)(this_obj & (~1));
22407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22408         ChannelPublicKeys_free(this_obj_conv);
22409 }
22410
22411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22412         LDKChannelPublicKeys this_ptr_conv;
22413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22414         this_ptr_conv.is_owned = false;
22415         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
22417         return ret_arr;
22418 }
22419
22420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22421         LDKChannelPublicKeys this_ptr_conv;
22422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22423         this_ptr_conv.is_owned = false;
22424         LDKPublicKey val_ref;
22425         CHECK((*env)->GetArrayLength(env, val) == 33);
22426         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22427         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
22428 }
22429
22430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22431         LDKChannelPublicKeys this_ptr_conv;
22432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22433         this_ptr_conv.is_owned = false;
22434         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
22436         return ret_arr;
22437 }
22438
22439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22440         LDKChannelPublicKeys this_ptr_conv;
22441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22442         this_ptr_conv.is_owned = false;
22443         LDKPublicKey val_ref;
22444         CHECK((*env)->GetArrayLength(env, val) == 33);
22445         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22446         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
22447 }
22448
22449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22450         LDKChannelPublicKeys this_ptr_conv;
22451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22452         this_ptr_conv.is_owned = false;
22453         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
22455         return ret_arr;
22456 }
22457
22458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22459         LDKChannelPublicKeys this_ptr_conv;
22460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22461         this_ptr_conv.is_owned = false;
22462         LDKPublicKey val_ref;
22463         CHECK((*env)->GetArrayLength(env, val) == 33);
22464         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22465         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
22466 }
22467
22468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22469         LDKChannelPublicKeys this_ptr_conv;
22470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22471         this_ptr_conv.is_owned = false;
22472         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22474         return ret_arr;
22475 }
22476
22477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22478         LDKChannelPublicKeys this_ptr_conv;
22479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22480         this_ptr_conv.is_owned = false;
22481         LDKPublicKey val_ref;
22482         CHECK((*env)->GetArrayLength(env, val) == 33);
22483         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22484         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22485 }
22486
22487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22488         LDKChannelPublicKeys this_ptr_conv;
22489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22490         this_ptr_conv.is_owned = false;
22491         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22493         return ret_arr;
22494 }
22495
22496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22497         LDKChannelPublicKeys this_ptr_conv;
22498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22499         this_ptr_conv.is_owned = false;
22500         LDKPublicKey val_ref;
22501         CHECK((*env)->GetArrayLength(env, val) == 33);
22502         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22503         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22504 }
22505
22506 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) {
22507         LDKPublicKey funding_pubkey_arg_ref;
22508         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
22509         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
22510         LDKPublicKey revocation_basepoint_arg_ref;
22511         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
22512         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
22513         LDKPublicKey payment_point_arg_ref;
22514         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
22515         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
22516         LDKPublicKey delayed_payment_basepoint_arg_ref;
22517         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
22518         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
22519         LDKPublicKey htlc_basepoint_arg_ref;
22520         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
22521         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
22522         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);
22523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22525         uint64_t ret_ref = (uint64_t)ret_var.inner;
22526         if (ret_var.is_owned) {
22527                 ret_ref |= 1;
22528         }
22529         return ret_ref;
22530 }
22531
22532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22533         LDKChannelPublicKeys orig_conv;
22534         orig_conv.inner = (void*)(orig & (~1));
22535         orig_conv.is_owned = false;
22536         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
22537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22539         uint64_t ret_ref = (uint64_t)ret_var.inner;
22540         if (ret_var.is_owned) {
22541                 ret_ref |= 1;
22542         }
22543         return ret_ref;
22544 }
22545
22546 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22547         LDKChannelPublicKeys obj_conv;
22548         obj_conv.inner = (void*)(obj & (~1));
22549         obj_conv.is_owned = false;
22550         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
22551         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22552         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22553         CVec_u8Z_free(ret_var);
22554         return ret_arr;
22555 }
22556
22557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22558         LDKu8slice ser_ref;
22559         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22560         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22561         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
22562         *ret_conv = ChannelPublicKeys_read(ser_ref);
22563         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22564         return (uint64_t)ret_conv;
22565 }
22566
22567 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) {
22568         LDKPublicKey per_commitment_point_ref;
22569         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22570         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22571         LDKPublicKey broadcaster_delayed_payment_base_ref;
22572         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
22573         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
22574         LDKPublicKey broadcaster_htlc_base_ref;
22575         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
22576         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
22577         LDKPublicKey countersignatory_revocation_base_ref;
22578         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
22579         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
22580         LDKPublicKey countersignatory_htlc_base_ref;
22581         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
22582         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
22583         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22584         *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);
22585         return (uint64_t)ret_conv;
22586 }
22587
22588 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) {
22589         LDKPublicKey per_commitment_point_ref;
22590         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22591         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22592         LDKChannelPublicKeys broadcaster_keys_conv;
22593         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22594         broadcaster_keys_conv.is_owned = false;
22595         LDKChannelPublicKeys countersignatory_keys_conv;
22596         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22597         countersignatory_keys_conv.is_owned = false;
22598         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22599         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
22600         return (uint64_t)ret_conv;
22601 }
22602
22603 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) {
22604         LDKPublicKey revocation_key_ref;
22605         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22606         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22607         LDKPublicKey broadcaster_delayed_payment_key_ref;
22608         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22609         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22610         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
22611         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22612         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22613         CVec_u8Z_free(ret_var);
22614         return ret_arr;
22615 }
22616
22617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22618         LDKHTLCOutputInCommitment this_obj_conv;
22619         this_obj_conv.inner = (void*)(this_obj & (~1));
22620         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22621         HTLCOutputInCommitment_free(this_obj_conv);
22622 }
22623
22624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
22625         LDKHTLCOutputInCommitment this_ptr_conv;
22626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22627         this_ptr_conv.is_owned = false;
22628         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
22629         return ret_val;
22630 }
22631
22632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22633         LDKHTLCOutputInCommitment this_ptr_conv;
22634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22635         this_ptr_conv.is_owned = false;
22636         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
22637 }
22638
22639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22640         LDKHTLCOutputInCommitment this_ptr_conv;
22641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22642         this_ptr_conv.is_owned = false;
22643         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
22644         return ret_val;
22645 }
22646
22647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22648         LDKHTLCOutputInCommitment this_ptr_conv;
22649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22650         this_ptr_conv.is_owned = false;
22651         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
22652 }
22653
22654 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
22655         LDKHTLCOutputInCommitment this_ptr_conv;
22656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22657         this_ptr_conv.is_owned = false;
22658         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
22659         return ret_val;
22660 }
22661
22662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22663         LDKHTLCOutputInCommitment this_ptr_conv;
22664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22665         this_ptr_conv.is_owned = false;
22666         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
22667 }
22668
22669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22670         LDKHTLCOutputInCommitment this_ptr_conv;
22671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22672         this_ptr_conv.is_owned = false;
22673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
22675         return ret_arr;
22676 }
22677
22678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22679         LDKHTLCOutputInCommitment this_ptr_conv;
22680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22681         this_ptr_conv.is_owned = false;
22682         LDKThirtyTwoBytes val_ref;
22683         CHECK((*env)->GetArrayLength(env, val) == 32);
22684         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22685         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
22686 }
22687
22688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22689         LDKHTLCOutputInCommitment this_ptr_conv;
22690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22691         this_ptr_conv.is_owned = false;
22692         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
22693         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
22694         uint64_t ret_ref = (uint64_t)ret_copy;
22695         return ret_ref;
22696 }
22697
22698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22699         LDKHTLCOutputInCommitment this_ptr_conv;
22700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22701         this_ptr_conv.is_owned = false;
22702         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22703         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22704 }
22705
22706 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) {
22707         LDKThirtyTwoBytes payment_hash_arg_ref;
22708         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
22709         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
22710         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22711         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22712         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22713         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22714         uint64_t ret_ref = (uint64_t)ret_var.inner;
22715         if (ret_var.is_owned) {
22716                 ret_ref |= 1;
22717         }
22718         return ret_ref;
22719 }
22720
22721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22722         LDKHTLCOutputInCommitment orig_conv;
22723         orig_conv.inner = (void*)(orig & (~1));
22724         orig_conv.is_owned = false;
22725         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22728         uint64_t ret_ref = (uint64_t)ret_var.inner;
22729         if (ret_var.is_owned) {
22730                 ret_ref |= 1;
22731         }
22732         return ret_ref;
22733 }
22734
22735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
22736         LDKHTLCOutputInCommitment obj_conv;
22737         obj_conv.inner = (void*)(obj & (~1));
22738         obj_conv.is_owned = false;
22739         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22740         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22741         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22742         CVec_u8Z_free(ret_var);
22743         return ret_arr;
22744 }
22745
22746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22747         LDKu8slice ser_ref;
22748         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22749         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22750         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22751         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22752         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22753         return (uint64_t)ret_conv;
22754 }
22755
22756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
22757         LDKHTLCOutputInCommitment htlc_conv;
22758         htlc_conv.inner = (void*)(htlc & (~1));
22759         htlc_conv.is_owned = false;
22760         LDKTxCreationKeys keys_conv;
22761         keys_conv.inner = (void*)(keys & (~1));
22762         keys_conv.is_owned = false;
22763         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22764         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22765         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22766         CVec_u8Z_free(ret_var);
22767         return ret_arr;
22768 }
22769
22770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
22771         LDKPublicKey broadcaster_ref;
22772         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
22773         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
22774         LDKPublicKey countersignatory_ref;
22775         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
22776         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
22777         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22778         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22779         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22780         CVec_u8Z_free(ret_var);
22781         return ret_arr;
22782 }
22783
22784 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) {
22785         unsigned char commitment_txid_arr[32];
22786         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
22787         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
22788         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22789         LDKHTLCOutputInCommitment htlc_conv;
22790         htlc_conv.inner = (void*)(htlc & (~1));
22791         htlc_conv.is_owned = false;
22792         LDKPublicKey broadcaster_delayed_payment_key_ref;
22793         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22794         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22795         LDKPublicKey revocation_key_ref;
22796         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22797         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22798         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22799         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22800         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22801         Transaction_free(ret_var);
22802         return ret_arr;
22803 }
22804
22805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22806         LDKChannelTransactionParameters this_obj_conv;
22807         this_obj_conv.inner = (void*)(this_obj & (~1));
22808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22809         ChannelTransactionParameters_free(this_obj_conv);
22810 }
22811
22812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22813         LDKChannelTransactionParameters this_ptr_conv;
22814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22815         this_ptr_conv.is_owned = false;
22816         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22817         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22818         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22819         uint64_t ret_ref = (uint64_t)ret_var.inner;
22820         if (ret_var.is_owned) {
22821                 ret_ref |= 1;
22822         }
22823         return ret_ref;
22824 }
22825
22826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22827         LDKChannelTransactionParameters this_ptr_conv;
22828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22829         this_ptr_conv.is_owned = false;
22830         LDKChannelPublicKeys val_conv;
22831         val_conv.inner = (void*)(val & (~1));
22832         val_conv.is_owned = (val & 1) || (val == 0);
22833         val_conv = ChannelPublicKeys_clone(&val_conv);
22834         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22835 }
22836
22837 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22838         LDKChannelTransactionParameters this_ptr_conv;
22839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22840         this_ptr_conv.is_owned = false;
22841         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22842         return ret_val;
22843 }
22844
22845 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) {
22846         LDKChannelTransactionParameters this_ptr_conv;
22847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22848         this_ptr_conv.is_owned = false;
22849         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22850 }
22851
22852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
22853         LDKChannelTransactionParameters this_ptr_conv;
22854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22855         this_ptr_conv.is_owned = false;
22856         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22857         return ret_val;
22858 }
22859
22860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22861         LDKChannelTransactionParameters this_ptr_conv;
22862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22863         this_ptr_conv.is_owned = false;
22864         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22865 }
22866
22867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
22868         LDKChannelTransactionParameters this_ptr_conv;
22869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22870         this_ptr_conv.is_owned = false;
22871         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22872         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22873         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22874         uint64_t ret_ref = (uint64_t)ret_var.inner;
22875         if (ret_var.is_owned) {
22876                 ret_ref |= 1;
22877         }
22878         return ret_ref;
22879 }
22880
22881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22882         LDKChannelTransactionParameters this_ptr_conv;
22883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22884         this_ptr_conv.is_owned = false;
22885         LDKCounterpartyChannelTransactionParameters val_conv;
22886         val_conv.inner = (void*)(val & (~1));
22887         val_conv.is_owned = (val & 1) || (val == 0);
22888         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22889         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22890 }
22891
22892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22893         LDKChannelTransactionParameters this_ptr_conv;
22894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22895         this_ptr_conv.is_owned = false;
22896         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22899         uint64_t ret_ref = (uint64_t)ret_var.inner;
22900         if (ret_var.is_owned) {
22901                 ret_ref |= 1;
22902         }
22903         return ret_ref;
22904 }
22905
22906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22907         LDKChannelTransactionParameters this_ptr_conv;
22908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22909         this_ptr_conv.is_owned = false;
22910         LDKOutPoint val_conv;
22911         val_conv.inner = (void*)(val & (~1));
22912         val_conv.is_owned = (val & 1) || (val == 0);
22913         val_conv = OutPoint_clone(&val_conv);
22914         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22915 }
22916
22917 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) {
22918         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22919         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22920         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22921         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22922         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22923         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22924         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22925         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22926         LDKOutPoint funding_outpoint_arg_conv;
22927         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22928         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22929         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22930         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);
22931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22933         uint64_t ret_ref = (uint64_t)ret_var.inner;
22934         if (ret_var.is_owned) {
22935                 ret_ref |= 1;
22936         }
22937         return ret_ref;
22938 }
22939
22940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22941         LDKChannelTransactionParameters orig_conv;
22942         orig_conv.inner = (void*)(orig & (~1));
22943         orig_conv.is_owned = false;
22944         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22947         uint64_t ret_ref = (uint64_t)ret_var.inner;
22948         if (ret_var.is_owned) {
22949                 ret_ref |= 1;
22950         }
22951         return ret_ref;
22952 }
22953
22954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22955         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22956         this_obj_conv.inner = (void*)(this_obj & (~1));
22957         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22958         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22959 }
22960
22961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22962         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22964         this_ptr_conv.is_owned = false;
22965         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22966         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22967         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22968         uint64_t ret_ref = (uint64_t)ret_var.inner;
22969         if (ret_var.is_owned) {
22970                 ret_ref |= 1;
22971         }
22972         return ret_ref;
22973 }
22974
22975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22976         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22978         this_ptr_conv.is_owned = false;
22979         LDKChannelPublicKeys val_conv;
22980         val_conv.inner = (void*)(val & (~1));
22981         val_conv.is_owned = (val & 1) || (val == 0);
22982         val_conv = ChannelPublicKeys_clone(&val_conv);
22983         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22984 }
22985
22986 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22987         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22989         this_ptr_conv.is_owned = false;
22990         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22991         return ret_val;
22992 }
22993
22994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22995         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22997         this_ptr_conv.is_owned = false;
22998         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22999 }
23000
23001 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) {
23002         LDKChannelPublicKeys pubkeys_arg_conv;
23003         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
23004         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
23005         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
23006         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
23007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23009         uint64_t ret_ref = (uint64_t)ret_var.inner;
23010         if (ret_var.is_owned) {
23011                 ret_ref |= 1;
23012         }
23013         return ret_ref;
23014 }
23015
23016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23017         LDKCounterpartyChannelTransactionParameters orig_conv;
23018         orig_conv.inner = (void*)(orig & (~1));
23019         orig_conv.is_owned = false;
23020         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
23021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23023         uint64_t ret_ref = (uint64_t)ret_var.inner;
23024         if (ret_var.is_owned) {
23025                 ret_ref |= 1;
23026         }
23027         return ret_ref;
23028 }
23029
23030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
23031         LDKChannelTransactionParameters this_arg_conv;
23032         this_arg_conv.inner = (void*)(this_arg & (~1));
23033         this_arg_conv.is_owned = false;
23034         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
23035         return ret_val;
23036 }
23037
23038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23039         LDKChannelTransactionParameters this_arg_conv;
23040         this_arg_conv.inner = (void*)(this_arg & (~1));
23041         this_arg_conv.is_owned = false;
23042         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
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_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23053         LDKChannelTransactionParameters this_arg_conv;
23054         this_arg_conv.inner = (void*)(this_arg & (~1));
23055         this_arg_conv.is_owned = false;
23056         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
23057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23059         uint64_t ret_ref = (uint64_t)ret_var.inner;
23060         if (ret_var.is_owned) {
23061                 ret_ref |= 1;
23062         }
23063         return ret_ref;
23064 }
23065
23066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23067         LDKCounterpartyChannelTransactionParameters obj_conv;
23068         obj_conv.inner = (void*)(obj & (~1));
23069         obj_conv.is_owned = false;
23070         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
23071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23073         CVec_u8Z_free(ret_var);
23074         return ret_arr;
23075 }
23076
23077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23078         LDKu8slice ser_ref;
23079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23081         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
23082         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
23083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23084         return (uint64_t)ret_conv;
23085 }
23086
23087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23088         LDKChannelTransactionParameters obj_conv;
23089         obj_conv.inner = (void*)(obj & (~1));
23090         obj_conv.is_owned = false;
23091         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
23092         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23093         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23094         CVec_u8Z_free(ret_var);
23095         return ret_arr;
23096 }
23097
23098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23099         LDKu8slice ser_ref;
23100         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23101         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23102         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
23103         *ret_conv = ChannelTransactionParameters_read(ser_ref);
23104         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23105         return (uint64_t)ret_conv;
23106 }
23107
23108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23109         LDKDirectedChannelTransactionParameters this_obj_conv;
23110         this_obj_conv.inner = (void*)(this_obj & (~1));
23111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23112         DirectedChannelTransactionParameters_free(this_obj_conv);
23113 }
23114
23115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23116         LDKDirectedChannelTransactionParameters this_arg_conv;
23117         this_arg_conv.inner = (void*)(this_arg & (~1));
23118         this_arg_conv.is_owned = false;
23119         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
23120         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23121         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23122         uint64_t ret_ref = (uint64_t)ret_var.inner;
23123         if (ret_var.is_owned) {
23124                 ret_ref |= 1;
23125         }
23126         return ret_ref;
23127 }
23128
23129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23130         LDKDirectedChannelTransactionParameters this_arg_conv;
23131         this_arg_conv.inner = (void*)(this_arg & (~1));
23132         this_arg_conv.is_owned = false;
23133         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
23134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23136         uint64_t ret_ref = (uint64_t)ret_var.inner;
23137         if (ret_var.is_owned) {
23138                 ret_ref |= 1;
23139         }
23140         return ret_ref;
23141 }
23142
23143 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23144         LDKDirectedChannelTransactionParameters this_arg_conv;
23145         this_arg_conv.inner = (void*)(this_arg & (~1));
23146         this_arg_conv.is_owned = false;
23147         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
23148         return ret_val;
23149 }
23150
23151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
23152         LDKDirectedChannelTransactionParameters this_arg_conv;
23153         this_arg_conv.inner = (void*)(this_arg & (~1));
23154         this_arg_conv.is_owned = false;
23155         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
23156         return ret_val;
23157 }
23158
23159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
23160         LDKDirectedChannelTransactionParameters this_arg_conv;
23161         this_arg_conv.inner = (void*)(this_arg & (~1));
23162         this_arg_conv.is_owned = false;
23163         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
23164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23166         uint64_t ret_ref = (uint64_t)ret_var.inner;
23167         if (ret_var.is_owned) {
23168                 ret_ref |= 1;
23169         }
23170         return ret_ref;
23171 }
23172
23173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23174         LDKHolderCommitmentTransaction this_obj_conv;
23175         this_obj_conv.inner = (void*)(this_obj & (~1));
23176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23177         HolderCommitmentTransaction_free(this_obj_conv);
23178 }
23179
23180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
23181         LDKHolderCommitmentTransaction this_ptr_conv;
23182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23183         this_ptr_conv.is_owned = false;
23184         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23185         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
23186         return ret_arr;
23187 }
23188
23189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23190         LDKHolderCommitmentTransaction this_ptr_conv;
23191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23192         this_ptr_conv.is_owned = false;
23193         LDKSignature val_ref;
23194         CHECK((*env)->GetArrayLength(env, val) == 64);
23195         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23196         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
23197 }
23198
23199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23200         LDKHolderCommitmentTransaction this_ptr_conv;
23201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23202         this_ptr_conv.is_owned = false;
23203         LDKCVec_SignatureZ val_constr;
23204         val_constr.datalen = (*env)->GetArrayLength(env, val);
23205         if (val_constr.datalen > 0)
23206                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23207         else
23208                 val_constr.data = NULL;
23209         for (size_t i = 0; i < val_constr.datalen; i++) {
23210                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
23211                 LDKSignature val_conv_8_ref;
23212                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
23213                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
23214                 val_constr.data[i] = val_conv_8_ref;
23215         }
23216         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
23217 }
23218
23219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23220         LDKHolderCommitmentTransaction orig_conv;
23221         orig_conv.inner = (void*)(orig & (~1));
23222         orig_conv.is_owned = false;
23223         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
23224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23226         uint64_t ret_ref = (uint64_t)ret_var.inner;
23227         if (ret_var.is_owned) {
23228                 ret_ref |= 1;
23229         }
23230         return ret_ref;
23231 }
23232
23233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23234         LDKHolderCommitmentTransaction obj_conv;
23235         obj_conv.inner = (void*)(obj & (~1));
23236         obj_conv.is_owned = false;
23237         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
23238         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23239         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23240         CVec_u8Z_free(ret_var);
23241         return ret_arr;
23242 }
23243
23244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23245         LDKu8slice ser_ref;
23246         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23247         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23248         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
23249         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
23250         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23251         return (uint64_t)ret_conv;
23252 }
23253
23254 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) {
23255         LDKCommitmentTransaction commitment_tx_conv;
23256         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
23257         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
23258         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
23259         LDKSignature counterparty_sig_ref;
23260         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
23261         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
23262         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
23263         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
23264         if (counterparty_htlc_sigs_constr.datalen > 0)
23265                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23266         else
23267                 counterparty_htlc_sigs_constr.data = NULL;
23268         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
23269                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
23270                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
23271                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
23272                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
23273                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
23274         }
23275         LDKPublicKey holder_funding_key_ref;
23276         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
23277         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
23278         LDKPublicKey counterparty_funding_key_ref;
23279         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
23280         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
23281         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
23282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23284         uint64_t ret_ref = (uint64_t)ret_var.inner;
23285         if (ret_var.is_owned) {
23286                 ret_ref |= 1;
23287         }
23288         return ret_ref;
23289 }
23290
23291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23292         LDKBuiltCommitmentTransaction this_obj_conv;
23293         this_obj_conv.inner = (void*)(this_obj & (~1));
23294         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23295         BuiltCommitmentTransaction_free(this_obj_conv);
23296 }
23297
23298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
23299         LDKBuiltCommitmentTransaction this_ptr_conv;
23300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23301         this_ptr_conv.is_owned = false;
23302         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
23303         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23304         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23305         Transaction_free(ret_var);
23306         return ret_arr;
23307 }
23308
23309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23310         LDKBuiltCommitmentTransaction this_ptr_conv;
23311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23312         this_ptr_conv.is_owned = false;
23313         LDKTransaction val_ref;
23314         val_ref.datalen = (*env)->GetArrayLength(env, val);
23315         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
23316         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
23317         val_ref.data_is_owned = true;
23318         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
23319 }
23320
23321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
23322         LDKBuiltCommitmentTransaction this_ptr_conv;
23323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23324         this_ptr_conv.is_owned = false;
23325         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
23327         return ret_arr;
23328 }
23329
23330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23331         LDKBuiltCommitmentTransaction this_ptr_conv;
23332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23333         this_ptr_conv.is_owned = false;
23334         LDKThirtyTwoBytes val_ref;
23335         CHECK((*env)->GetArrayLength(env, val) == 32);
23336         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23337         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
23338 }
23339
23340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
23341         LDKTransaction transaction_arg_ref;
23342         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
23343         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
23344         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
23345         transaction_arg_ref.data_is_owned = true;
23346         LDKThirtyTwoBytes txid_arg_ref;
23347         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
23348         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
23349         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
23350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23352         uint64_t ret_ref = (uint64_t)ret_var.inner;
23353         if (ret_var.is_owned) {
23354                 ret_ref |= 1;
23355         }
23356         return ret_ref;
23357 }
23358
23359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23360         LDKBuiltCommitmentTransaction orig_conv;
23361         orig_conv.inner = (void*)(orig & (~1));
23362         orig_conv.is_owned = false;
23363         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
23364         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23365         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23366         uint64_t ret_ref = (uint64_t)ret_var.inner;
23367         if (ret_var.is_owned) {
23368                 ret_ref |= 1;
23369         }
23370         return ret_ref;
23371 }
23372
23373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23374         LDKBuiltCommitmentTransaction obj_conv;
23375         obj_conv.inner = (void*)(obj & (~1));
23376         obj_conv.is_owned = false;
23377         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
23378         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23379         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23380         CVec_u8Z_free(ret_var);
23381         return ret_arr;
23382 }
23383
23384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23385         LDKu8slice ser_ref;
23386         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23387         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23388         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
23389         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
23390         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23391         return (uint64_t)ret_conv;
23392 }
23393
23394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
23395         LDKBuiltCommitmentTransaction this_arg_conv;
23396         this_arg_conv.inner = (void*)(this_arg & (~1));
23397         this_arg_conv.is_owned = false;
23398         LDKu8slice funding_redeemscript_ref;
23399         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23400         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23401         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23402         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
23403         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23404         return ret_arr;
23405 }
23406
23407 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) {
23408         LDKBuiltCommitmentTransaction this_arg_conv;
23409         this_arg_conv.inner = (void*)(this_arg & (~1));
23410         this_arg_conv.is_owned = false;
23411         unsigned char funding_key_arr[32];
23412         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
23413         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
23414         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
23415         LDKu8slice funding_redeemscript_ref;
23416         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23417         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23418         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23419         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
23420         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23421         return ret_arr;
23422 }
23423
23424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23425         LDKCommitmentTransaction this_obj_conv;
23426         this_obj_conv.inner = (void*)(this_obj & (~1));
23427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23428         CommitmentTransaction_free(this_obj_conv);
23429 }
23430
23431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23432         LDKCommitmentTransaction orig_conv;
23433         orig_conv.inner = (void*)(orig & (~1));
23434         orig_conv.is_owned = false;
23435         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
23436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23438         uint64_t ret_ref = (uint64_t)ret_var.inner;
23439         if (ret_var.is_owned) {
23440                 ret_ref |= 1;
23441         }
23442         return ret_ref;
23443 }
23444
23445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23446         LDKCommitmentTransaction obj_conv;
23447         obj_conv.inner = (void*)(obj & (~1));
23448         obj_conv.is_owned = false;
23449         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
23450         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23451         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23452         CVec_u8Z_free(ret_var);
23453         return ret_arr;
23454 }
23455
23456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23457         LDKu8slice ser_ref;
23458         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23459         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23460         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
23461         *ret_conv = CommitmentTransaction_read(ser_ref);
23462         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23463         return (uint64_t)ret_conv;
23464 }
23465
23466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
23467         LDKCommitmentTransaction this_arg_conv;
23468         this_arg_conv.inner = (void*)(this_arg & (~1));
23469         this_arg_conv.is_owned = false;
23470         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23471         return ret_val;
23472 }
23473
23474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23475         LDKCommitmentTransaction this_arg_conv;
23476         this_arg_conv.inner = (void*)(this_arg & (~1));
23477         this_arg_conv.is_owned = false;
23478         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23479         return ret_val;
23480 }
23481
23482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23483         LDKCommitmentTransaction this_arg_conv;
23484         this_arg_conv.inner = (void*)(this_arg & (~1));
23485         this_arg_conv.is_owned = false;
23486         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23487         return ret_val;
23488 }
23489
23490 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
23491         LDKCommitmentTransaction this_arg_conv;
23492         this_arg_conv.inner = (void*)(this_arg & (~1));
23493         this_arg_conv.is_owned = false;
23494         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23495         return ret_val;
23496 }
23497
23498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
23499         LDKCommitmentTransaction this_arg_conv;
23500         this_arg_conv.inner = (void*)(this_arg & (~1));
23501         this_arg_conv.is_owned = false;
23502         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23505         uint64_t ret_ref = (uint64_t)ret_var.inner;
23506         if (ret_var.is_owned) {
23507                 ret_ref |= 1;
23508         }
23509         return ret_ref;
23510 }
23511
23512 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) {
23513         LDKCommitmentTransaction this_arg_conv;
23514         this_arg_conv.inner = (void*)(this_arg & (~1));
23515         this_arg_conv.is_owned = false;
23516         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23517         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23518         channel_parameters_conv.is_owned = false;
23519         LDKChannelPublicKeys broadcaster_keys_conv;
23520         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23521         broadcaster_keys_conv.is_owned = false;
23522         LDKChannelPublicKeys countersignatory_keys_conv;
23523         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23524         countersignatory_keys_conv.is_owned = false;
23525         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
23526         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
23527         return (uint64_t)ret_conv;
23528 }
23529
23530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23531         LDKTrustedCommitmentTransaction this_obj_conv;
23532         this_obj_conv.inner = (void*)(this_obj & (~1));
23533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23534         TrustedCommitmentTransaction_free(this_obj_conv);
23535 }
23536
23537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
23538         LDKTrustedCommitmentTransaction this_arg_conv;
23539         this_arg_conv.inner = (void*)(this_arg & (~1));
23540         this_arg_conv.is_owned = false;
23541         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23542         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
23543         return ret_arr;
23544 }
23545
23546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
23547         LDKTrustedCommitmentTransaction this_arg_conv;
23548         this_arg_conv.inner = (void*)(this_arg & (~1));
23549         this_arg_conv.is_owned = false;
23550         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
23551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23553         uint64_t ret_ref = (uint64_t)ret_var.inner;
23554         if (ret_var.is_owned) {
23555                 ret_ref |= 1;
23556         }
23557         return ret_ref;
23558 }
23559
23560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
23561         LDKTrustedCommitmentTransaction this_arg_conv;
23562         this_arg_conv.inner = (void*)(this_arg & (~1));
23563         this_arg_conv.is_owned = false;
23564         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
23565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23567         uint64_t ret_ref = (uint64_t)ret_var.inner;
23568         if (ret_var.is_owned) {
23569                 ret_ref |= 1;
23570         }
23571         return ret_ref;
23572 }
23573
23574 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) {
23575         LDKTrustedCommitmentTransaction this_arg_conv;
23576         this_arg_conv.inner = (void*)(this_arg & (~1));
23577         this_arg_conv.is_owned = false;
23578         unsigned char htlc_base_key_arr[32];
23579         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
23580         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
23581         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
23582         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23583         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23584         channel_parameters_conv.is_owned = false;
23585         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
23586         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
23587         return (uint64_t)ret_conv;
23588 }
23589
23590 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) {
23591         LDKPublicKey broadcaster_payment_basepoint_ref;
23592         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
23593         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
23594         LDKPublicKey countersignatory_payment_basepoint_ref;
23595         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
23596         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
23597         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
23598         return ret_val;
23599 }
23600
23601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23602         LDKInitFeatures a_conv;
23603         a_conv.inner = (void*)(a & (~1));
23604         a_conv.is_owned = false;
23605         LDKInitFeatures b_conv;
23606         b_conv.inner = (void*)(b & (~1));
23607         b_conv.is_owned = false;
23608         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
23609         return ret_val;
23610 }
23611
23612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23613         LDKNodeFeatures a_conv;
23614         a_conv.inner = (void*)(a & (~1));
23615         a_conv.is_owned = false;
23616         LDKNodeFeatures b_conv;
23617         b_conv.inner = (void*)(b & (~1));
23618         b_conv.is_owned = false;
23619         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
23620         return ret_val;
23621 }
23622
23623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23624         LDKChannelFeatures a_conv;
23625         a_conv.inner = (void*)(a & (~1));
23626         a_conv.is_owned = false;
23627         LDKChannelFeatures b_conv;
23628         b_conv.inner = (void*)(b & (~1));
23629         b_conv.is_owned = false;
23630         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
23631         return ret_val;
23632 }
23633
23634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23635         LDKInvoiceFeatures a_conv;
23636         a_conv.inner = (void*)(a & (~1));
23637         a_conv.is_owned = false;
23638         LDKInvoiceFeatures b_conv;
23639         b_conv.inner = (void*)(b & (~1));
23640         b_conv.is_owned = false;
23641         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
23642         return ret_val;
23643 }
23644
23645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23646         LDKInitFeatures orig_conv;
23647         orig_conv.inner = (void*)(orig & (~1));
23648         orig_conv.is_owned = false;
23649         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
23650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23652         uint64_t ret_ref = (uint64_t)ret_var.inner;
23653         if (ret_var.is_owned) {
23654                 ret_ref |= 1;
23655         }
23656         return ret_ref;
23657 }
23658
23659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23660         LDKNodeFeatures orig_conv;
23661         orig_conv.inner = (void*)(orig & (~1));
23662         orig_conv.is_owned = false;
23663         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
23664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23666         uint64_t ret_ref = (uint64_t)ret_var.inner;
23667         if (ret_var.is_owned) {
23668                 ret_ref |= 1;
23669         }
23670         return ret_ref;
23671 }
23672
23673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23674         LDKChannelFeatures orig_conv;
23675         orig_conv.inner = (void*)(orig & (~1));
23676         orig_conv.is_owned = false;
23677         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
23678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23680         uint64_t ret_ref = (uint64_t)ret_var.inner;
23681         if (ret_var.is_owned) {
23682                 ret_ref |= 1;
23683         }
23684         return ret_ref;
23685 }
23686
23687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23688         LDKInvoiceFeatures orig_conv;
23689         orig_conv.inner = (void*)(orig & (~1));
23690         orig_conv.is_owned = false;
23691         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
23692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23694         uint64_t ret_ref = (uint64_t)ret_var.inner;
23695         if (ret_var.is_owned) {
23696                 ret_ref |= 1;
23697         }
23698         return ret_ref;
23699 }
23700
23701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23702         LDKInitFeatures this_obj_conv;
23703         this_obj_conv.inner = (void*)(this_obj & (~1));
23704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23705         InitFeatures_free(this_obj_conv);
23706 }
23707
23708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23709         LDKNodeFeatures this_obj_conv;
23710         this_obj_conv.inner = (void*)(this_obj & (~1));
23711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23712         NodeFeatures_free(this_obj_conv);
23713 }
23714
23715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23716         LDKChannelFeatures this_obj_conv;
23717         this_obj_conv.inner = (void*)(this_obj & (~1));
23718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23719         ChannelFeatures_free(this_obj_conv);
23720 }
23721
23722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23723         LDKInvoiceFeatures this_obj_conv;
23724         this_obj_conv.inner = (void*)(this_obj & (~1));
23725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23726         InvoiceFeatures_free(this_obj_conv);
23727 }
23728
23729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
23730         LDKInitFeatures ret_var = InitFeatures_empty();
23731         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23732         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23733         uint64_t ret_ref = (uint64_t)ret_var.inner;
23734         if (ret_var.is_owned) {
23735                 ret_ref |= 1;
23736         }
23737         return ret_ref;
23738 }
23739
23740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
23741         LDKInitFeatures ret_var = InitFeatures_known();
23742         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23743         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23744         uint64_t ret_ref = (uint64_t)ret_var.inner;
23745         if (ret_var.is_owned) {
23746                 ret_ref |= 1;
23747         }
23748         return ret_ref;
23749 }
23750
23751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
23752         LDKNodeFeatures ret_var = NodeFeatures_empty();
23753         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23754         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23755         uint64_t ret_ref = (uint64_t)ret_var.inner;
23756         if (ret_var.is_owned) {
23757                 ret_ref |= 1;
23758         }
23759         return ret_ref;
23760 }
23761
23762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
23763         LDKNodeFeatures ret_var = NodeFeatures_known();
23764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23766         uint64_t ret_ref = (uint64_t)ret_var.inner;
23767         if (ret_var.is_owned) {
23768                 ret_ref |= 1;
23769         }
23770         return ret_ref;
23771 }
23772
23773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
23774         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23775         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23776         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23777         uint64_t ret_ref = (uint64_t)ret_var.inner;
23778         if (ret_var.is_owned) {
23779                 ret_ref |= 1;
23780         }
23781         return ret_ref;
23782 }
23783
23784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
23785         LDKChannelFeatures ret_var = ChannelFeatures_known();
23786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23788         uint64_t ret_ref = (uint64_t)ret_var.inner;
23789         if (ret_var.is_owned) {
23790                 ret_ref |= 1;
23791         }
23792         return ret_ref;
23793 }
23794
23795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
23796         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23799         uint64_t ret_ref = (uint64_t)ret_var.inner;
23800         if (ret_var.is_owned) {
23801                 ret_ref |= 1;
23802         }
23803         return ret_ref;
23804 }
23805
23806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
23807         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23810         uint64_t ret_ref = (uint64_t)ret_var.inner;
23811         if (ret_var.is_owned) {
23812                 ret_ref |= 1;
23813         }
23814         return ret_ref;
23815 }
23816
23817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23818         LDKInitFeatures this_arg_conv;
23819         this_arg_conv.inner = (void*)(this_arg & (~1));
23820         this_arg_conv.is_owned = false;
23821         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23822         return ret_val;
23823 }
23824
23825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23826         LDKNodeFeatures this_arg_conv;
23827         this_arg_conv.inner = (void*)(this_arg & (~1));
23828         this_arg_conv.is_owned = false;
23829         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23830         return ret_val;
23831 }
23832
23833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23834         LDKInvoiceFeatures this_arg_conv;
23835         this_arg_conv.inner = (void*)(this_arg & (~1));
23836         this_arg_conv.is_owned = false;
23837         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23838         return ret_val;
23839 }
23840
23841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23842         LDKInitFeatures obj_conv;
23843         obj_conv.inner = (void*)(obj & (~1));
23844         obj_conv.is_owned = false;
23845         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23848         CVec_u8Z_free(ret_var);
23849         return ret_arr;
23850 }
23851
23852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23853         LDKNodeFeatures obj_conv;
23854         obj_conv.inner = (void*)(obj & (~1));
23855         obj_conv.is_owned = false;
23856         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23857         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23858         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23859         CVec_u8Z_free(ret_var);
23860         return ret_arr;
23861 }
23862
23863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23864         LDKChannelFeatures obj_conv;
23865         obj_conv.inner = (void*)(obj & (~1));
23866         obj_conv.is_owned = false;
23867         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23868         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23869         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23870         CVec_u8Z_free(ret_var);
23871         return ret_arr;
23872 }
23873
23874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23875         LDKInvoiceFeatures obj_conv;
23876         obj_conv.inner = (void*)(obj & (~1));
23877         obj_conv.is_owned = false;
23878         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23881         CVec_u8Z_free(ret_var);
23882         return ret_arr;
23883 }
23884
23885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23886         LDKu8slice ser_ref;
23887         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23888         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23889         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23890         *ret_conv = InitFeatures_read(ser_ref);
23891         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23892         return (uint64_t)ret_conv;
23893 }
23894
23895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23896         LDKu8slice ser_ref;
23897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23899         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23900         *ret_conv = NodeFeatures_read(ser_ref);
23901         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23902         return (uint64_t)ret_conv;
23903 }
23904
23905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23906         LDKu8slice ser_ref;
23907         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23908         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23909         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23910         *ret_conv = ChannelFeatures_read(ser_ref);
23911         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23912         return (uint64_t)ret_conv;
23913 }
23914
23915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23916         LDKu8slice ser_ref;
23917         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23918         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23919         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23920         *ret_conv = InvoiceFeatures_read(ser_ref);
23921         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23922         return (uint64_t)ret_conv;
23923 }
23924
23925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23926         LDKRouteHop this_obj_conv;
23927         this_obj_conv.inner = (void*)(this_obj & (~1));
23928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23929         RouteHop_free(this_obj_conv);
23930 }
23931
23932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23933         LDKRouteHop this_ptr_conv;
23934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23935         this_ptr_conv.is_owned = false;
23936         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
23938         return ret_arr;
23939 }
23940
23941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23942         LDKRouteHop this_ptr_conv;
23943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23944         this_ptr_conv.is_owned = false;
23945         LDKPublicKey val_ref;
23946         CHECK((*env)->GetArrayLength(env, val) == 33);
23947         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23948         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23949 }
23950
23951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23952         LDKRouteHop this_ptr_conv;
23953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23954         this_ptr_conv.is_owned = false;
23955         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23958         uint64_t ret_ref = (uint64_t)ret_var.inner;
23959         if (ret_var.is_owned) {
23960                 ret_ref |= 1;
23961         }
23962         return ret_ref;
23963 }
23964
23965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23966         LDKRouteHop this_ptr_conv;
23967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23968         this_ptr_conv.is_owned = false;
23969         LDKNodeFeatures val_conv;
23970         val_conv.inner = (void*)(val & (~1));
23971         val_conv.is_owned = (val & 1) || (val == 0);
23972         val_conv = NodeFeatures_clone(&val_conv);
23973         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23974 }
23975
23976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23977         LDKRouteHop this_ptr_conv;
23978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23979         this_ptr_conv.is_owned = false;
23980         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23981         return ret_val;
23982 }
23983
23984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23985         LDKRouteHop this_ptr_conv;
23986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23987         this_ptr_conv.is_owned = false;
23988         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23989 }
23990
23991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23992         LDKRouteHop this_ptr_conv;
23993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23994         this_ptr_conv.is_owned = false;
23995         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23998         uint64_t ret_ref = (uint64_t)ret_var.inner;
23999         if (ret_var.is_owned) {
24000                 ret_ref |= 1;
24001         }
24002         return ret_ref;
24003 }
24004
24005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24006         LDKRouteHop this_ptr_conv;
24007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24008         this_ptr_conv.is_owned = false;
24009         LDKChannelFeatures val_conv;
24010         val_conv.inner = (void*)(val & (~1));
24011         val_conv.is_owned = (val & 1) || (val == 0);
24012         val_conv = ChannelFeatures_clone(&val_conv);
24013         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
24014 }
24015
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24017         LDKRouteHop this_ptr_conv;
24018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24019         this_ptr_conv.is_owned = false;
24020         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
24021         return ret_val;
24022 }
24023
24024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24025         LDKRouteHop this_ptr_conv;
24026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24027         this_ptr_conv.is_owned = false;
24028         RouteHop_set_fee_msat(&this_ptr_conv, val);
24029 }
24030
24031 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24032         LDKRouteHop this_ptr_conv;
24033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24034         this_ptr_conv.is_owned = false;
24035         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
24036         return ret_val;
24037 }
24038
24039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24040         LDKRouteHop this_ptr_conv;
24041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24042         this_ptr_conv.is_owned = false;
24043         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
24044 }
24045
24046 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) {
24047         LDKPublicKey pubkey_arg_ref;
24048         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
24049         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
24050         LDKNodeFeatures node_features_arg_conv;
24051         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
24052         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
24053         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
24054         LDKChannelFeatures channel_features_arg_conv;
24055         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
24056         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
24057         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
24058         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);
24059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24061         uint64_t ret_ref = (uint64_t)ret_var.inner;
24062         if (ret_var.is_owned) {
24063                 ret_ref |= 1;
24064         }
24065         return ret_ref;
24066 }
24067
24068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24069         LDKRouteHop orig_conv;
24070         orig_conv.inner = (void*)(orig & (~1));
24071         orig_conv.is_owned = false;
24072         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
24073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24075         uint64_t ret_ref = (uint64_t)ret_var.inner;
24076         if (ret_var.is_owned) {
24077                 ret_ref |= 1;
24078         }
24079         return ret_ref;
24080 }
24081
24082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
24083         LDKRouteHop obj_conv;
24084         obj_conv.inner = (void*)(obj & (~1));
24085         obj_conv.is_owned = false;
24086         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
24087         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24088         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24089         CVec_u8Z_free(ret_var);
24090         return ret_arr;
24091 }
24092
24093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24094         LDKu8slice ser_ref;
24095         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24096         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24097         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
24098         *ret_conv = RouteHop_read(ser_ref);
24099         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24100         return (uint64_t)ret_conv;
24101 }
24102
24103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24104         LDKRoute this_obj_conv;
24105         this_obj_conv.inner = (void*)(this_obj & (~1));
24106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24107         Route_free(this_obj_conv);
24108 }
24109
24110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
24111         LDKRoute this_ptr_conv;
24112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24113         this_ptr_conv.is_owned = false;
24114         LDKCVec_CVec_RouteHopZZ val_constr;
24115         val_constr.datalen = (*env)->GetArrayLength(env, val);
24116         if (val_constr.datalen > 0)
24117                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24118         else
24119                 val_constr.data = NULL;
24120         for (size_t m = 0; m < val_constr.datalen; m++) {
24121                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
24122                 LDKCVec_RouteHopZ val_conv_12_constr;
24123                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
24124                 if (val_conv_12_constr.datalen > 0)
24125                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24126                 else
24127                         val_conv_12_constr.data = NULL;
24128                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
24129                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
24130                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
24131                         LDKRouteHop val_conv_12_conv_10_conv;
24132                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
24133                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
24134                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
24135                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
24136                 }
24137                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
24138                 val_constr.data[m] = val_conv_12_constr;
24139         }
24140         Route_set_paths(&this_ptr_conv, val_constr);
24141 }
24142
24143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
24144         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
24145         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
24146         if (paths_arg_constr.datalen > 0)
24147                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24148         else
24149                 paths_arg_constr.data = NULL;
24150         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
24151                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
24152                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
24153                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
24154                 if (paths_arg_conv_12_constr.datalen > 0)
24155                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24156                 else
24157                         paths_arg_conv_12_constr.data = NULL;
24158                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
24159                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
24160                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
24161                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
24162                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
24163                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
24164                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
24165                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
24166                 }
24167                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
24168                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
24169         }
24170         LDKRoute ret_var = Route_new(paths_arg_constr);
24171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24173         uint64_t ret_ref = (uint64_t)ret_var.inner;
24174         if (ret_var.is_owned) {
24175                 ret_ref |= 1;
24176         }
24177         return ret_ref;
24178 }
24179
24180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24181         LDKRoute orig_conv;
24182         orig_conv.inner = (void*)(orig & (~1));
24183         orig_conv.is_owned = false;
24184         LDKRoute ret_var = Route_clone(&orig_conv);
24185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24187         uint64_t ret_ref = (uint64_t)ret_var.inner;
24188         if (ret_var.is_owned) {
24189                 ret_ref |= 1;
24190         }
24191         return ret_ref;
24192 }
24193
24194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
24195         LDKRoute obj_conv;
24196         obj_conv.inner = (void*)(obj & (~1));
24197         obj_conv.is_owned = false;
24198         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
24199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24201         CVec_u8Z_free(ret_var);
24202         return ret_arr;
24203 }
24204
24205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24206         LDKu8slice ser_ref;
24207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24209         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
24210         *ret_conv = Route_read(ser_ref);
24211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24212         return (uint64_t)ret_conv;
24213 }
24214
24215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24216         LDKRouteHint this_obj_conv;
24217         this_obj_conv.inner = (void*)(this_obj & (~1));
24218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24219         RouteHint_free(this_obj_conv);
24220 }
24221
24222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24223         LDKRouteHint a_conv;
24224         a_conv.inner = (void*)(a & (~1));
24225         a_conv.is_owned = false;
24226         LDKRouteHint b_conv;
24227         b_conv.inner = (void*)(b & (~1));
24228         b_conv.is_owned = false;
24229         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
24230         return ret_val;
24231 }
24232
24233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24234         LDKRouteHint orig_conv;
24235         orig_conv.inner = (void*)(orig & (~1));
24236         orig_conv.is_owned = false;
24237         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
24238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24240         uint64_t ret_ref = (uint64_t)ret_var.inner;
24241         if (ret_var.is_owned) {
24242                 ret_ref |= 1;
24243         }
24244         return ret_ref;
24245 }
24246
24247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24248         LDKRouteHintHop this_obj_conv;
24249         this_obj_conv.inner = (void*)(this_obj & (~1));
24250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24251         RouteHintHop_free(this_obj_conv);
24252 }
24253
24254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24255         LDKRouteHintHop this_ptr_conv;
24256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24257         this_ptr_conv.is_owned = false;
24258         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24259         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
24260         return ret_arr;
24261 }
24262
24263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24264         LDKRouteHintHop this_ptr_conv;
24265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24266         this_ptr_conv.is_owned = false;
24267         LDKPublicKey val_ref;
24268         CHECK((*env)->GetArrayLength(env, val) == 33);
24269         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24270         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
24271 }
24272
24273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24274         LDKRouteHintHop this_ptr_conv;
24275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24276         this_ptr_conv.is_owned = false;
24277         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
24278         return ret_val;
24279 }
24280
24281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24282         LDKRouteHintHop this_ptr_conv;
24283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24284         this_ptr_conv.is_owned = false;
24285         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
24286 }
24287
24288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24289         LDKRouteHintHop this_ptr_conv;
24290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24291         this_ptr_conv.is_owned = false;
24292         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
24293         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24294         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24295         uint64_t ret_ref = (uint64_t)ret_var.inner;
24296         if (ret_var.is_owned) {
24297                 ret_ref |= 1;
24298         }
24299         return ret_ref;
24300 }
24301
24302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24303         LDKRouteHintHop this_ptr_conv;
24304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24305         this_ptr_conv.is_owned = false;
24306         LDKRoutingFees val_conv;
24307         val_conv.inner = (void*)(val & (~1));
24308         val_conv.is_owned = (val & 1) || (val == 0);
24309         val_conv = RoutingFees_clone(&val_conv);
24310         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
24311 }
24312
24313 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24314         LDKRouteHintHop this_ptr_conv;
24315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24316         this_ptr_conv.is_owned = false;
24317         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
24318         return ret_val;
24319 }
24320
24321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24322         LDKRouteHintHop this_ptr_conv;
24323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24324         this_ptr_conv.is_owned = false;
24325         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
24326 }
24327
24328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24329         LDKRouteHintHop this_ptr_conv;
24330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24331         this_ptr_conv.is_owned = false;
24332         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24333         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
24334         uint64_t ret_ref = (uint64_t)ret_copy;
24335         return ret_ref;
24336 }
24337
24338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24339         LDKRouteHintHop this_ptr_conv;
24340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24341         this_ptr_conv.is_owned = false;
24342         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24343         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
24344 }
24345
24346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24347         LDKRouteHintHop this_ptr_conv;
24348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24349         this_ptr_conv.is_owned = false;
24350         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24351         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
24352         uint64_t ret_ref = (uint64_t)ret_copy;
24353         return ret_ref;
24354 }
24355
24356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24357         LDKRouteHintHop this_ptr_conv;
24358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24359         this_ptr_conv.is_owned = false;
24360         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24361         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24362 }
24363
24364 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) {
24365         LDKPublicKey src_node_id_arg_ref;
24366         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
24367         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
24368         LDKRoutingFees fees_arg_conv;
24369         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24370         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24371         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24372         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
24373         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24374         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);
24375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24377         uint64_t ret_ref = (uint64_t)ret_var.inner;
24378         if (ret_var.is_owned) {
24379                 ret_ref |= 1;
24380         }
24381         return ret_ref;
24382 }
24383
24384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24385         LDKRouteHintHop a_conv;
24386         a_conv.inner = (void*)(a & (~1));
24387         a_conv.is_owned = false;
24388         LDKRouteHintHop b_conv;
24389         b_conv.inner = (void*)(b & (~1));
24390         b_conv.is_owned = false;
24391         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
24392         return ret_val;
24393 }
24394
24395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24396         LDKRouteHintHop orig_conv;
24397         orig_conv.inner = (void*)(orig & (~1));
24398         orig_conv.is_owned = false;
24399         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
24400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24402         uint64_t ret_ref = (uint64_t)ret_var.inner;
24403         if (ret_var.is_owned) {
24404                 ret_ref |= 1;
24405         }
24406         return ret_ref;
24407 }
24408
24409 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) {
24410         LDKPublicKey our_node_id_ref;
24411         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
24412         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
24413         LDKNetworkGraph network_conv;
24414         network_conv.inner = (void*)(network & (~1));
24415         network_conv.is_owned = false;
24416         LDKPublicKey payee_ref;
24417         CHECK((*env)->GetArrayLength(env, payee) == 33);
24418         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
24419         LDKInvoiceFeatures payee_features_conv;
24420         payee_features_conv.inner = (void*)(payee_features & (~1));
24421         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
24422         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
24423         LDKCVec_ChannelDetailsZ first_hops_constr;
24424         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
24425         if (first_hops != NULL) {
24426                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
24427                 if (first_hops_constr.datalen > 0)
24428                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24429                 else
24430                         first_hops_constr.data = NULL;
24431                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
24432                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
24433                         int64_t first_hops_conv_16 = first_hops_vals[q];
24434                         LDKChannelDetails first_hops_conv_16_conv;
24435                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
24436                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
24437                         first_hops_constr.data[q] = first_hops_conv_16_conv;
24438                 }
24439                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
24440                 first_hops_ptr = &first_hops_constr;
24441         }
24442         LDKCVec_RouteHintZ last_hops_constr;
24443         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
24444         if (last_hops_constr.datalen > 0)
24445                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
24446         else
24447                 last_hops_constr.data = NULL;
24448         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
24449         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
24450                 int64_t last_hops_conv_11 = last_hops_vals[l];
24451                 LDKRouteHint last_hops_conv_11_conv;
24452                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
24453                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
24454                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
24455                 last_hops_constr.data[l] = last_hops_conv_11_conv;
24456         }
24457         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
24458         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24459         if (logger_conv.free == LDKLogger_JCalls_free) {
24460                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24461                 LDKLogger_JCalls_cloned(&logger_conv);
24462         }
24463         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
24464         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
24465         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
24466         return (uint64_t)ret_conv;
24467 }
24468
24469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24470         LDKNetworkGraph this_obj_conv;
24471         this_obj_conv.inner = (void*)(this_obj & (~1));
24472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24473         NetworkGraph_free(this_obj_conv);
24474 }
24475
24476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24477         LDKNetworkGraph orig_conv;
24478         orig_conv.inner = (void*)(orig & (~1));
24479         orig_conv.is_owned = false;
24480         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
24481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24483         uint64_t ret_ref = (uint64_t)ret_var.inner;
24484         if (ret_var.is_owned) {
24485                 ret_ref |= 1;
24486         }
24487         return ret_ref;
24488 }
24489
24490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24491         LDKLockedNetworkGraph this_obj_conv;
24492         this_obj_conv.inner = (void*)(this_obj & (~1));
24493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24494         LockedNetworkGraph_free(this_obj_conv);
24495 }
24496
24497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24498         LDKNetGraphMsgHandler this_obj_conv;
24499         this_obj_conv.inner = (void*)(this_obj & (~1));
24500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24501         NetGraphMsgHandler_free(this_obj_conv);
24502 }
24503
24504 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) {
24505         LDKThirtyTwoBytes genesis_hash_ref;
24506         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24507         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24508         LDKAccess *chain_access_conv_ptr = NULL;
24509         if (chain_access != 0) {
24510                 LDKAccess chain_access_conv;
24511                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24512                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24513                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24514                         LDKAccess_JCalls_cloned(&chain_access_conv);
24515                 }
24516                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24517                 *chain_access_conv_ptr = chain_access_conv;
24518         }
24519         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24520         if (logger_conv.free == LDKLogger_JCalls_free) {
24521                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24522                 LDKLogger_JCalls_cloned(&logger_conv);
24523         }
24524         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
24525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24527         uint64_t ret_ref = (uint64_t)ret_var.inner;
24528         if (ret_var.is_owned) {
24529                 ret_ref |= 1;
24530         }
24531         return ret_ref;
24532 }
24533
24534 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) {
24535         LDKAccess *chain_access_conv_ptr = NULL;
24536         if (chain_access != 0) {
24537                 LDKAccess chain_access_conv;
24538                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24539                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24540                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24541                         LDKAccess_JCalls_cloned(&chain_access_conv);
24542                 }
24543                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24544                 *chain_access_conv_ptr = chain_access_conv;
24545         }
24546         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24547         if (logger_conv.free == LDKLogger_JCalls_free) {
24548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24549                 LDKLogger_JCalls_cloned(&logger_conv);
24550         }
24551         LDKNetworkGraph network_graph_conv;
24552         network_graph_conv.inner = (void*)(network_graph & (~1));
24553         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
24554         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
24555         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
24556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24558         uint64_t ret_ref = (uint64_t)ret_var.inner;
24559         if (ret_var.is_owned) {
24560                 ret_ref |= 1;
24561         }
24562         return ret_ref;
24563 }
24564
24565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
24566         LDKNetGraphMsgHandler this_arg_conv;
24567         this_arg_conv.inner = (void*)(this_arg & (~1));
24568         this_arg_conv.is_owned = false;
24569         LDKAccess *chain_access_conv_ptr = NULL;
24570         if (chain_access != 0) {
24571                 LDKAccess chain_access_conv;
24572                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24573                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24574                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24575                         LDKAccess_JCalls_cloned(&chain_access_conv);
24576                 }
24577                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24578                 *chain_access_conv_ptr = chain_access_conv;
24579         }
24580         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
24581 }
24582
24583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24584         LDKNetGraphMsgHandler this_arg_conv;
24585         this_arg_conv.inner = (void*)(this_arg & (~1));
24586         this_arg_conv.is_owned = false;
24587         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
24588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24590         uint64_t ret_ref = (uint64_t)ret_var.inner;
24591         if (ret_var.is_owned) {
24592                 ret_ref |= 1;
24593         }
24594         return ret_ref;
24595 }
24596
24597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24598         LDKLockedNetworkGraph this_arg_conv;
24599         this_arg_conv.inner = (void*)(this_arg & (~1));
24600         this_arg_conv.is_owned = false;
24601         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_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_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24612         LDKNetGraphMsgHandler this_arg_conv;
24613         this_arg_conv.inner = (void*)(this_arg & (~1));
24614         this_arg_conv.is_owned = false;
24615         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24616         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
24617         return (uint64_t)ret;
24618 }
24619
24620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24621         LDKNetGraphMsgHandler this_arg_conv;
24622         this_arg_conv.inner = (void*)(this_arg & (~1));
24623         this_arg_conv.is_owned = false;
24624         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24625         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
24626         return (uint64_t)ret;
24627 }
24628
24629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24630         LDKDirectionalChannelInfo this_obj_conv;
24631         this_obj_conv.inner = (void*)(this_obj & (~1));
24632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24633         DirectionalChannelInfo_free(this_obj_conv);
24634 }
24635
24636 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24637         LDKDirectionalChannelInfo this_ptr_conv;
24638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24639         this_ptr_conv.is_owned = false;
24640         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
24641         return ret_val;
24642 }
24643
24644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24645         LDKDirectionalChannelInfo this_ptr_conv;
24646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24647         this_ptr_conv.is_owned = false;
24648         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24649 }
24650
24651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
24652         LDKDirectionalChannelInfo this_ptr_conv;
24653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24654         this_ptr_conv.is_owned = false;
24655         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24656         return ret_val;
24657 }
24658
24659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24660         LDKDirectionalChannelInfo this_ptr_conv;
24661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24662         this_ptr_conv.is_owned = false;
24663         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24664 }
24665
24666 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24667         LDKDirectionalChannelInfo this_ptr_conv;
24668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24669         this_ptr_conv.is_owned = false;
24670         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24671         return ret_val;
24672 }
24673
24674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24675         LDKDirectionalChannelInfo this_ptr_conv;
24676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24677         this_ptr_conv.is_owned = false;
24678         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24679 }
24680
24681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24682         LDKDirectionalChannelInfo this_ptr_conv;
24683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24684         this_ptr_conv.is_owned = false;
24685         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24686         return ret_val;
24687 }
24688
24689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24690         LDKDirectionalChannelInfo this_ptr_conv;
24691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24692         this_ptr_conv.is_owned = false;
24693         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24694 }
24695
24696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24697         LDKDirectionalChannelInfo this_ptr_conv;
24698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24699         this_ptr_conv.is_owned = false;
24700         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24701         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24702         uint64_t ret_ref = (uint64_t)ret_copy;
24703         return ret_ref;
24704 }
24705
24706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24707         LDKDirectionalChannelInfo this_ptr_conv;
24708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24709         this_ptr_conv.is_owned = false;
24710         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24711         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24712 }
24713
24714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24715         LDKDirectionalChannelInfo this_ptr_conv;
24716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24717         this_ptr_conv.is_owned = false;
24718         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24721         uint64_t ret_ref = (uint64_t)ret_var.inner;
24722         if (ret_var.is_owned) {
24723                 ret_ref |= 1;
24724         }
24725         return ret_ref;
24726 }
24727
24728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24729         LDKDirectionalChannelInfo this_ptr_conv;
24730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24731         this_ptr_conv.is_owned = false;
24732         LDKRoutingFees val_conv;
24733         val_conv.inner = (void*)(val & (~1));
24734         val_conv.is_owned = (val & 1) || (val == 0);
24735         val_conv = RoutingFees_clone(&val_conv);
24736         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24737 }
24738
24739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24740         LDKDirectionalChannelInfo this_ptr_conv;
24741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24742         this_ptr_conv.is_owned = false;
24743         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24754         LDKDirectionalChannelInfo this_ptr_conv;
24755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24756         this_ptr_conv.is_owned = false;
24757         LDKChannelUpdate val_conv;
24758         val_conv.inner = (void*)(val & (~1));
24759         val_conv.is_owned = (val & 1) || (val == 0);
24760         val_conv = ChannelUpdate_clone(&val_conv);
24761         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24762 }
24763
24764 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) {
24765         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24766         LDKRoutingFees fees_arg_conv;
24767         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24768         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24769         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24770         LDKChannelUpdate last_update_message_arg_conv;
24771         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24772         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24773         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24774         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);
24775         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24776         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24777         uint64_t ret_ref = (uint64_t)ret_var.inner;
24778         if (ret_var.is_owned) {
24779                 ret_ref |= 1;
24780         }
24781         return ret_ref;
24782 }
24783
24784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24785         LDKDirectionalChannelInfo orig_conv;
24786         orig_conv.inner = (void*)(orig & (~1));
24787         orig_conv.is_owned = false;
24788         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24791         uint64_t ret_ref = (uint64_t)ret_var.inner;
24792         if (ret_var.is_owned) {
24793                 ret_ref |= 1;
24794         }
24795         return ret_ref;
24796 }
24797
24798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24799         LDKDirectionalChannelInfo obj_conv;
24800         obj_conv.inner = (void*)(obj & (~1));
24801         obj_conv.is_owned = false;
24802         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24805         CVec_u8Z_free(ret_var);
24806         return ret_arr;
24807 }
24808
24809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24810         LDKu8slice ser_ref;
24811         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24812         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24813         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24814         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24815         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24816         return (uint64_t)ret_conv;
24817 }
24818
24819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24820         LDKChannelInfo this_obj_conv;
24821         this_obj_conv.inner = (void*)(this_obj & (~1));
24822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24823         ChannelInfo_free(this_obj_conv);
24824 }
24825
24826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24827         LDKChannelInfo this_ptr_conv;
24828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24829         this_ptr_conv.is_owned = false;
24830         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24833         uint64_t ret_ref = (uint64_t)ret_var.inner;
24834         if (ret_var.is_owned) {
24835                 ret_ref |= 1;
24836         }
24837         return ret_ref;
24838 }
24839
24840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24841         LDKChannelInfo this_ptr_conv;
24842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24843         this_ptr_conv.is_owned = false;
24844         LDKChannelFeatures val_conv;
24845         val_conv.inner = (void*)(val & (~1));
24846         val_conv.is_owned = (val & 1) || (val == 0);
24847         val_conv = ChannelFeatures_clone(&val_conv);
24848         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24849 }
24850
24851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24852         LDKChannelInfo this_ptr_conv;
24853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24854         this_ptr_conv.is_owned = false;
24855         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
24857         return ret_arr;
24858 }
24859
24860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24861         LDKChannelInfo this_ptr_conv;
24862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24863         this_ptr_conv.is_owned = false;
24864         LDKPublicKey val_ref;
24865         CHECK((*env)->GetArrayLength(env, val) == 33);
24866         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24867         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24868 }
24869
24870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24871         LDKChannelInfo this_ptr_conv;
24872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24873         this_ptr_conv.is_owned = false;
24874         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24875         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24876         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24877         uint64_t ret_ref = (uint64_t)ret_var.inner;
24878         if (ret_var.is_owned) {
24879                 ret_ref |= 1;
24880         }
24881         return ret_ref;
24882 }
24883
24884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24885         LDKChannelInfo this_ptr_conv;
24886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24887         this_ptr_conv.is_owned = false;
24888         LDKDirectionalChannelInfo val_conv;
24889         val_conv.inner = (void*)(val & (~1));
24890         val_conv.is_owned = (val & 1) || (val == 0);
24891         val_conv = DirectionalChannelInfo_clone(&val_conv);
24892         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24893 }
24894
24895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24896         LDKChannelInfo this_ptr_conv;
24897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24898         this_ptr_conv.is_owned = false;
24899         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24900         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
24901         return ret_arr;
24902 }
24903
24904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24905         LDKChannelInfo this_ptr_conv;
24906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24907         this_ptr_conv.is_owned = false;
24908         LDKPublicKey val_ref;
24909         CHECK((*env)->GetArrayLength(env, val) == 33);
24910         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24911         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24912 }
24913
24914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24915         LDKChannelInfo this_ptr_conv;
24916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24917         this_ptr_conv.is_owned = false;
24918         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24921         uint64_t ret_ref = (uint64_t)ret_var.inner;
24922         if (ret_var.is_owned) {
24923                 ret_ref |= 1;
24924         }
24925         return ret_ref;
24926 }
24927
24928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24929         LDKChannelInfo this_ptr_conv;
24930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24931         this_ptr_conv.is_owned = false;
24932         LDKDirectionalChannelInfo val_conv;
24933         val_conv.inner = (void*)(val & (~1));
24934         val_conv.is_owned = (val & 1) || (val == 0);
24935         val_conv = DirectionalChannelInfo_clone(&val_conv);
24936         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24937 }
24938
24939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
24940         LDKChannelInfo this_ptr_conv;
24941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24942         this_ptr_conv.is_owned = false;
24943         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24944         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24945         uint64_t ret_ref = (uint64_t)ret_copy;
24946         return ret_ref;
24947 }
24948
24949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24950         LDKChannelInfo this_ptr_conv;
24951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24952         this_ptr_conv.is_owned = false;
24953         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24954         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24955 }
24956
24957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24958         LDKChannelInfo this_ptr_conv;
24959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24960         this_ptr_conv.is_owned = false;
24961         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24964         uint64_t ret_ref = (uint64_t)ret_var.inner;
24965         if (ret_var.is_owned) {
24966                 ret_ref |= 1;
24967         }
24968         return ret_ref;
24969 }
24970
24971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24972         LDKChannelInfo this_ptr_conv;
24973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24974         this_ptr_conv.is_owned = false;
24975         LDKChannelAnnouncement val_conv;
24976         val_conv.inner = (void*)(val & (~1));
24977         val_conv.is_owned = (val & 1) || (val == 0);
24978         val_conv = ChannelAnnouncement_clone(&val_conv);
24979         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24980 }
24981
24982 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) {
24983         LDKChannelFeatures features_arg_conv;
24984         features_arg_conv.inner = (void*)(features_arg & (~1));
24985         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24986         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24987         LDKPublicKey node_one_arg_ref;
24988         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
24989         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
24990         LDKDirectionalChannelInfo one_to_two_arg_conv;
24991         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24992         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24993         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24994         LDKPublicKey node_two_arg_ref;
24995         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
24996         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
24997         LDKDirectionalChannelInfo two_to_one_arg_conv;
24998         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24999         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
25000         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
25001         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
25002         LDKChannelAnnouncement announcement_message_arg_conv;
25003         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
25004         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
25005         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
25006         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);
25007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25009         uint64_t ret_ref = (uint64_t)ret_var.inner;
25010         if (ret_var.is_owned) {
25011                 ret_ref |= 1;
25012         }
25013         return ret_ref;
25014 }
25015
25016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25017         LDKChannelInfo orig_conv;
25018         orig_conv.inner = (void*)(orig & (~1));
25019         orig_conv.is_owned = false;
25020         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
25021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25023         uint64_t ret_ref = (uint64_t)ret_var.inner;
25024         if (ret_var.is_owned) {
25025                 ret_ref |= 1;
25026         }
25027         return ret_ref;
25028 }
25029
25030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25031         LDKChannelInfo obj_conv;
25032         obj_conv.inner = (void*)(obj & (~1));
25033         obj_conv.is_owned = false;
25034         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
25035         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25036         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25037         CVec_u8Z_free(ret_var);
25038         return ret_arr;
25039 }
25040
25041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25042         LDKu8slice ser_ref;
25043         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25044         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25045         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
25046         *ret_conv = ChannelInfo_read(ser_ref);
25047         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25048         return (uint64_t)ret_conv;
25049 }
25050
25051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25052         LDKRoutingFees this_obj_conv;
25053         this_obj_conv.inner = (void*)(this_obj & (~1));
25054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25055         RoutingFees_free(this_obj_conv);
25056 }
25057
25058 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25059         LDKRoutingFees this_ptr_conv;
25060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25061         this_ptr_conv.is_owned = false;
25062         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
25063         return ret_val;
25064 }
25065
25066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25067         LDKRoutingFees this_ptr_conv;
25068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25069         this_ptr_conv.is_owned = false;
25070         RoutingFees_set_base_msat(&this_ptr_conv, val);
25071 }
25072
25073 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25074         LDKRoutingFees this_ptr_conv;
25075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25076         this_ptr_conv.is_owned = false;
25077         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
25078         return ret_val;
25079 }
25080
25081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25082         LDKRoutingFees this_ptr_conv;
25083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25084         this_ptr_conv.is_owned = false;
25085         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
25086 }
25087
25088 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) {
25089         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
25090         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25091         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25092         uint64_t ret_ref = (uint64_t)ret_var.inner;
25093         if (ret_var.is_owned) {
25094                 ret_ref |= 1;
25095         }
25096         return ret_ref;
25097 }
25098
25099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25100         LDKRoutingFees a_conv;
25101         a_conv.inner = (void*)(a & (~1));
25102         a_conv.is_owned = false;
25103         LDKRoutingFees b_conv;
25104         b_conv.inner = (void*)(b & (~1));
25105         b_conv.is_owned = false;
25106         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
25107         return ret_val;
25108 }
25109
25110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25111         LDKRoutingFees orig_conv;
25112         orig_conv.inner = (void*)(orig & (~1));
25113         orig_conv.is_owned = false;
25114         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
25115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25117         uint64_t ret_ref = (uint64_t)ret_var.inner;
25118         if (ret_var.is_owned) {
25119                 ret_ref |= 1;
25120         }
25121         return ret_ref;
25122 }
25123
25124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
25125         LDKRoutingFees obj_conv;
25126         obj_conv.inner = (void*)(obj & (~1));
25127         obj_conv.is_owned = false;
25128         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
25129         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25130         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25131         CVec_u8Z_free(ret_var);
25132         return ret_arr;
25133 }
25134
25135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25136         LDKu8slice ser_ref;
25137         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25138         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25139         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
25140         *ret_conv = RoutingFees_read(ser_ref);
25141         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25142         return (uint64_t)ret_conv;
25143 }
25144
25145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25146         LDKNodeAnnouncementInfo this_obj_conv;
25147         this_obj_conv.inner = (void*)(this_obj & (~1));
25148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25149         NodeAnnouncementInfo_free(this_obj_conv);
25150 }
25151
25152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25153         LDKNodeAnnouncementInfo this_ptr_conv;
25154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25155         this_ptr_conv.is_owned = false;
25156         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
25157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25159         uint64_t ret_ref = (uint64_t)ret_var.inner;
25160         if (ret_var.is_owned) {
25161                 ret_ref |= 1;
25162         }
25163         return ret_ref;
25164 }
25165
25166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25167         LDKNodeAnnouncementInfo this_ptr_conv;
25168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25169         this_ptr_conv.is_owned = false;
25170         LDKNodeFeatures val_conv;
25171         val_conv.inner = (void*)(val & (~1));
25172         val_conv.is_owned = (val & 1) || (val == 0);
25173         val_conv = NodeFeatures_clone(&val_conv);
25174         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
25175 }
25176
25177 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
25178         LDKNodeAnnouncementInfo this_ptr_conv;
25179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25180         this_ptr_conv.is_owned = false;
25181         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
25182         return ret_val;
25183 }
25184
25185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25186         LDKNodeAnnouncementInfo this_ptr_conv;
25187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25188         this_ptr_conv.is_owned = false;
25189         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
25190 }
25191
25192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
25193         LDKNodeAnnouncementInfo this_ptr_conv;
25194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25195         this_ptr_conv.is_owned = false;
25196         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
25197         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
25198         return ret_arr;
25199 }
25200
25201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25202         LDKNodeAnnouncementInfo this_ptr_conv;
25203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25204         this_ptr_conv.is_owned = false;
25205         LDKThreeBytes val_ref;
25206         CHECK((*env)->GetArrayLength(env, val) == 3);
25207         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
25208         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
25209 }
25210
25211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
25212         LDKNodeAnnouncementInfo this_ptr_conv;
25213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25214         this_ptr_conv.is_owned = false;
25215         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
25217         return ret_arr;
25218 }
25219
25220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25221         LDKNodeAnnouncementInfo this_ptr_conv;
25222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25223         this_ptr_conv.is_owned = false;
25224         LDKThirtyTwoBytes val_ref;
25225         CHECK((*env)->GetArrayLength(env, val) == 32);
25226         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25227         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
25228 }
25229
25230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25231         LDKNodeAnnouncementInfo this_ptr_conv;
25232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25233         this_ptr_conv.is_owned = false;
25234         LDKCVec_NetAddressZ val_constr;
25235         val_constr.datalen = (*env)->GetArrayLength(env, val);
25236         if (val_constr.datalen > 0)
25237                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25238         else
25239                 val_constr.data = NULL;
25240         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25241         for (size_t m = 0; m < val_constr.datalen; m++) {
25242                 int64_t val_conv_12 = val_vals[m];
25243                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
25244                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25245                 val_constr.data[m] = val_conv_12_conv;
25246         }
25247         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25248         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
25249 }
25250
25251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25252         LDKNodeAnnouncementInfo this_ptr_conv;
25253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25254         this_ptr_conv.is_owned = false;
25255         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
25256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25258         uint64_t ret_ref = (uint64_t)ret_var.inner;
25259         if (ret_var.is_owned) {
25260                 ret_ref |= 1;
25261         }
25262         return ret_ref;
25263 }
25264
25265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25266         LDKNodeAnnouncementInfo this_ptr_conv;
25267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25268         this_ptr_conv.is_owned = false;
25269         LDKNodeAnnouncement val_conv;
25270         val_conv.inner = (void*)(val & (~1));
25271         val_conv.is_owned = (val & 1) || (val == 0);
25272         val_conv = NodeAnnouncement_clone(&val_conv);
25273         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
25274 }
25275
25276 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) {
25277         LDKNodeFeatures features_arg_conv;
25278         features_arg_conv.inner = (void*)(features_arg & (~1));
25279         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25280         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
25281         LDKThreeBytes rgb_arg_ref;
25282         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
25283         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
25284         LDKThirtyTwoBytes alias_arg_ref;
25285         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
25286         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
25287         LDKCVec_NetAddressZ addresses_arg_constr;
25288         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
25289         if (addresses_arg_constr.datalen > 0)
25290                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25291         else
25292                 addresses_arg_constr.data = NULL;
25293         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
25294         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
25295                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
25296                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
25297                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
25298         }
25299         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
25300         LDKNodeAnnouncement announcement_message_arg_conv;
25301         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
25302         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
25303         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
25304         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
25305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25307         uint64_t ret_ref = (uint64_t)ret_var.inner;
25308         if (ret_var.is_owned) {
25309                 ret_ref |= 1;
25310         }
25311         return ret_ref;
25312 }
25313
25314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25315         LDKNodeAnnouncementInfo orig_conv;
25316         orig_conv.inner = (void*)(orig & (~1));
25317         orig_conv.is_owned = false;
25318         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
25319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25321         uint64_t ret_ref = (uint64_t)ret_var.inner;
25322         if (ret_var.is_owned) {
25323                 ret_ref |= 1;
25324         }
25325         return ret_ref;
25326 }
25327
25328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25329         LDKNodeAnnouncementInfo obj_conv;
25330         obj_conv.inner = (void*)(obj & (~1));
25331         obj_conv.is_owned = false;
25332         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
25333         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25334         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25335         CVec_u8Z_free(ret_var);
25336         return ret_arr;
25337 }
25338
25339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25340         LDKu8slice ser_ref;
25341         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25342         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25343         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
25344         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
25345         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25346         return (uint64_t)ret_conv;
25347 }
25348
25349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25350         LDKNodeInfo this_obj_conv;
25351         this_obj_conv.inner = (void*)(this_obj & (~1));
25352         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25353         NodeInfo_free(this_obj_conv);
25354 }
25355
25356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25357         LDKNodeInfo this_ptr_conv;
25358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25359         this_ptr_conv.is_owned = false;
25360         LDKCVec_u64Z val_constr;
25361         val_constr.datalen = (*env)->GetArrayLength(env, val);
25362         if (val_constr.datalen > 0)
25363                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25364         else
25365                 val_constr.data = NULL;
25366         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25367         for (size_t g = 0; g < val_constr.datalen; g++) {
25368                 int64_t val_conv_6 = val_vals[g];
25369                 val_constr.data[g] = val_conv_6;
25370         }
25371         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25372         NodeInfo_set_channels(&this_ptr_conv, val_constr);
25373 }
25374
25375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
25376         LDKNodeInfo this_ptr_conv;
25377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25378         this_ptr_conv.is_owned = false;
25379         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
25380         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25381         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25382         uint64_t ret_ref = (uint64_t)ret_var.inner;
25383         if (ret_var.is_owned) {
25384                 ret_ref |= 1;
25385         }
25386         return ret_ref;
25387 }
25388
25389 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) {
25390         LDKNodeInfo this_ptr_conv;
25391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25392         this_ptr_conv.is_owned = false;
25393         LDKRoutingFees val_conv;
25394         val_conv.inner = (void*)(val & (~1));
25395         val_conv.is_owned = (val & 1) || (val == 0);
25396         val_conv = RoutingFees_clone(&val_conv);
25397         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
25398 }
25399
25400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
25401         LDKNodeInfo this_ptr_conv;
25402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25403         this_ptr_conv.is_owned = false;
25404         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
25405         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25406         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25407         uint64_t ret_ref = (uint64_t)ret_var.inner;
25408         if (ret_var.is_owned) {
25409                 ret_ref |= 1;
25410         }
25411         return ret_ref;
25412 }
25413
25414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25415         LDKNodeInfo this_ptr_conv;
25416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25417         this_ptr_conv.is_owned = false;
25418         LDKNodeAnnouncementInfo val_conv;
25419         val_conv.inner = (void*)(val & (~1));
25420         val_conv.is_owned = (val & 1) || (val == 0);
25421         val_conv = NodeAnnouncementInfo_clone(&val_conv);
25422         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
25423 }
25424
25425 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) {
25426         LDKCVec_u64Z channels_arg_constr;
25427         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
25428         if (channels_arg_constr.datalen > 0)
25429                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25430         else
25431                 channels_arg_constr.data = NULL;
25432         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
25433         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
25434                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
25435                 channels_arg_constr.data[g] = channels_arg_conv_6;
25436         }
25437         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
25438         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
25439         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
25440         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
25441         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
25442         LDKNodeAnnouncementInfo announcement_info_arg_conv;
25443         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
25444         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
25445         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
25446         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
25447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25449         uint64_t ret_ref = (uint64_t)ret_var.inner;
25450         if (ret_var.is_owned) {
25451                 ret_ref |= 1;
25452         }
25453         return ret_ref;
25454 }
25455
25456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25457         LDKNodeInfo orig_conv;
25458         orig_conv.inner = (void*)(orig & (~1));
25459         orig_conv.is_owned = false;
25460         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
25461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25463         uint64_t ret_ref = (uint64_t)ret_var.inner;
25464         if (ret_var.is_owned) {
25465                 ret_ref |= 1;
25466         }
25467         return ret_ref;
25468 }
25469
25470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25471         LDKNodeInfo obj_conv;
25472         obj_conv.inner = (void*)(obj & (~1));
25473         obj_conv.is_owned = false;
25474         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
25475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25477         CVec_u8Z_free(ret_var);
25478         return ret_arr;
25479 }
25480
25481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25482         LDKu8slice ser_ref;
25483         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25484         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25485         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
25486         *ret_conv = NodeInfo_read(ser_ref);
25487         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25488         return (uint64_t)ret_conv;
25489 }
25490
25491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
25492         LDKNetworkGraph obj_conv;
25493         obj_conv.inner = (void*)(obj & (~1));
25494         obj_conv.is_owned = false;
25495         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
25496         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25497         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25498         CVec_u8Z_free(ret_var);
25499         return ret_arr;
25500 }
25501
25502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25503         LDKu8slice ser_ref;
25504         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25505         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25506         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
25507         *ret_conv = NetworkGraph_read(ser_ref);
25508         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25509         return (uint64_t)ret_conv;
25510 }
25511
25512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
25513         LDKThirtyTwoBytes genesis_hash_ref;
25514         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
25515         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
25516         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
25517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25519         uint64_t ret_ref = (uint64_t)ret_var.inner;
25520         if (ret_var.is_owned) {
25521                 ret_ref |= 1;
25522         }
25523         return ret_ref;
25524 }
25525
25526 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) {
25527         LDKNetworkGraph this_arg_conv;
25528         this_arg_conv.inner = (void*)(this_arg & (~1));
25529         this_arg_conv.is_owned = false;
25530         LDKNodeAnnouncement msg_conv;
25531         msg_conv.inner = (void*)(msg & (~1));
25532         msg_conv.is_owned = false;
25533         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25534         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
25535         return (uint64_t)ret_conv;
25536 }
25537
25538 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) {
25539         LDKNetworkGraph this_arg_conv;
25540         this_arg_conv.inner = (void*)(this_arg & (~1));
25541         this_arg_conv.is_owned = false;
25542         LDKUnsignedNodeAnnouncement msg_conv;
25543         msg_conv.inner = (void*)(msg & (~1));
25544         msg_conv.is_owned = false;
25545         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25546         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
25547         return (uint64_t)ret_conv;
25548 }
25549
25550 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) {
25551         LDKNetworkGraph this_arg_conv;
25552         this_arg_conv.inner = (void*)(this_arg & (~1));
25553         this_arg_conv.is_owned = false;
25554         LDKChannelAnnouncement msg_conv;
25555         msg_conv.inner = (void*)(msg & (~1));
25556         msg_conv.is_owned = false;
25557         LDKAccess *chain_access_conv_ptr = NULL;
25558         if (chain_access != 0) {
25559                 LDKAccess chain_access_conv;
25560                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25561                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25562                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25563                         LDKAccess_JCalls_cloned(&chain_access_conv);
25564                 }
25565                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25566                 *chain_access_conv_ptr = chain_access_conv;
25567         }
25568         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25569         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25570         return (uint64_t)ret_conv;
25571 }
25572
25573 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) {
25574         LDKNetworkGraph this_arg_conv;
25575         this_arg_conv.inner = (void*)(this_arg & (~1));
25576         this_arg_conv.is_owned = false;
25577         LDKUnsignedChannelAnnouncement msg_conv;
25578         msg_conv.inner = (void*)(msg & (~1));
25579         msg_conv.is_owned = false;
25580         LDKAccess *chain_access_conv_ptr = NULL;
25581         if (chain_access != 0) {
25582                 LDKAccess chain_access_conv;
25583                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25584                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25585                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25586                         LDKAccess_JCalls_cloned(&chain_access_conv);
25587                 }
25588                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25589                 *chain_access_conv_ptr = chain_access_conv;
25590         }
25591         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25592         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25593         return (uint64_t)ret_conv;
25594 }
25595
25596 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) {
25597         LDKNetworkGraph this_arg_conv;
25598         this_arg_conv.inner = (void*)(this_arg & (~1));
25599         this_arg_conv.is_owned = false;
25600         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
25601 }
25602
25603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25604         LDKNetworkGraph this_arg_conv;
25605         this_arg_conv.inner = (void*)(this_arg & (~1));
25606         this_arg_conv.is_owned = false;
25607         LDKChannelUpdate msg_conv;
25608         msg_conv.inner = (void*)(msg & (~1));
25609         msg_conv.is_owned = false;
25610         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25611         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
25612         return (uint64_t)ret_conv;
25613 }
25614
25615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25616         LDKNetworkGraph this_arg_conv;
25617         this_arg_conv.inner = (void*)(this_arg & (~1));
25618         this_arg_conv.is_owned = false;
25619         LDKUnsignedChannelUpdate msg_conv;
25620         msg_conv.inner = (void*)(msg & (~1));
25621         msg_conv.is_owned = false;
25622         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25623         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
25624         return (uint64_t)ret_conv;
25625 }
25626
25627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25628         LDKFilesystemPersister this_obj_conv;
25629         this_obj_conv.inner = (void*)(this_obj & (~1));
25630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25631         FilesystemPersister_free(this_obj_conv);
25632 }
25633
25634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
25635         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
25636         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25639         uint64_t ret_ref = (uint64_t)ret_var.inner;
25640         if (ret_var.is_owned) {
25641                 ret_ref |= 1;
25642         }
25643         return ret_ref;
25644 }
25645
25646 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
25647         LDKFilesystemPersister this_arg_conv;
25648         this_arg_conv.inner = (void*)(this_arg & (~1));
25649         this_arg_conv.is_owned = false;
25650         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25651         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25652         Str_free(ret_str);
25653         return ret_conv;
25654 }
25655
25656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
25657         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
25658         LDKChannelManager manager_conv;
25659         manager_conv.inner = (void*)(manager & (~1));
25660         manager_conv.is_owned = false;
25661         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25662         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25663         return (uint64_t)ret_conv;
25664 }
25665
25666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
25667         LDKFilesystemPersister this_arg_conv;
25668         this_arg_conv.inner = (void*)(this_arg & (~1));
25669         this_arg_conv.is_owned = false;
25670         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25671         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25672                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25673                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25674         }
25675         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25676         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25677         return (uint64_t)ret_conv;
25678 }
25679
25680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
25681         LDKFilesystemPersister this_arg_conv;
25682         this_arg_conv.inner = (void*)(this_arg & (~1));
25683         this_arg_conv.is_owned = false;
25684         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
25685         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
25686         return (uint64_t)ret;
25687 }
25688
25689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25690         LDKBackgroundProcessor this_obj_conv;
25691         this_obj_conv.inner = (void*)(this_obj & (~1));
25692         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25693         BackgroundProcessor_free(this_obj_conv);
25694 }
25695
25696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25697         if ((this_ptr & 1) != 0) return;
25698         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25699         FREE((void*)this_ptr);
25700         ChannelManagerPersister_free(this_ptr_conv);
25701 }
25702
25703 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) {
25704         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25705         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
25706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25707                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
25708         }
25709         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25710         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
25711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25712                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
25713         }
25714         LDKChainMonitor chain_monitor_conv;
25715         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25716         chain_monitor_conv.is_owned = false;
25717         LDKChannelManager channel_manager_conv;
25718         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25719         channel_manager_conv.is_owned = false;
25720         LDKPeerManager peer_manager_conv;
25721         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25722         peer_manager_conv.is_owned = false;
25723         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25724         if (logger_conv.free == LDKLogger_JCalls_free) {
25725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25726                 LDKLogger_JCalls_cloned(&logger_conv);
25727         }
25728         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
25729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25731         uint64_t ret_ref = (uint64_t)ret_var.inner;
25732         if (ret_var.is_owned) {
25733                 ret_ref |= 1;
25734         }
25735         return ret_ref;
25736 }
25737
25738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
25739         LDKBackgroundProcessor this_arg_conv;
25740         this_arg_conv.inner = (void*)(this_arg & (~1));
25741         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25742         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25743         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25744         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25745         return (uint64_t)ret_conv;
25746 }
25747
25748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
25749         check_platform();
25750 }
25751
25752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25753         LDKInvoice this_obj_conv;
25754         this_obj_conv.inner = (void*)(this_obj & (~1));
25755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25756         Invoice_free(this_obj_conv);
25757 }
25758
25759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25760         LDKInvoice a_conv;
25761         a_conv.inner = (void*)(a & (~1));
25762         a_conv.is_owned = false;
25763         LDKInvoice b_conv;
25764         b_conv.inner = (void*)(b & (~1));
25765         b_conv.is_owned = false;
25766         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25767         return ret_val;
25768 }
25769
25770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25771         LDKInvoice orig_conv;
25772         orig_conv.inner = (void*)(orig & (~1));
25773         orig_conv.is_owned = false;
25774         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25775         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25776         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25777         uint64_t ret_ref = (uint64_t)ret_var.inner;
25778         if (ret_var.is_owned) {
25779                 ret_ref |= 1;
25780         }
25781         return ret_ref;
25782 }
25783
25784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25785         LDKSignedRawInvoice this_obj_conv;
25786         this_obj_conv.inner = (void*)(this_obj & (~1));
25787         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25788         SignedRawInvoice_free(this_obj_conv);
25789 }
25790
25791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25792         LDKSignedRawInvoice a_conv;
25793         a_conv.inner = (void*)(a & (~1));
25794         a_conv.is_owned = false;
25795         LDKSignedRawInvoice b_conv;
25796         b_conv.inner = (void*)(b & (~1));
25797         b_conv.is_owned = false;
25798         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25799         return ret_val;
25800 }
25801
25802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25803         LDKSignedRawInvoice orig_conv;
25804         orig_conv.inner = (void*)(orig & (~1));
25805         orig_conv.is_owned = false;
25806         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25807         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25808         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25809         uint64_t ret_ref = (uint64_t)ret_var.inner;
25810         if (ret_var.is_owned) {
25811                 ret_ref |= 1;
25812         }
25813         return ret_ref;
25814 }
25815
25816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25817         LDKRawInvoice this_obj_conv;
25818         this_obj_conv.inner = (void*)(this_obj & (~1));
25819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25820         RawInvoice_free(this_obj_conv);
25821 }
25822
25823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25824         LDKRawInvoice this_ptr_conv;
25825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25826         this_ptr_conv.is_owned = false;
25827         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25828         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25829         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25830         uint64_t ret_ref = (uint64_t)ret_var.inner;
25831         if (ret_var.is_owned) {
25832                 ret_ref |= 1;
25833         }
25834         return ret_ref;
25835 }
25836
25837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25838         LDKRawInvoice this_ptr_conv;
25839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25840         this_ptr_conv.is_owned = false;
25841         LDKRawDataPart val_conv;
25842         val_conv.inner = (void*)(val & (~1));
25843         val_conv.is_owned = (val & 1) || (val == 0);
25844         val_conv = RawDataPart_clone(&val_conv);
25845         RawInvoice_set_data(&this_ptr_conv, val_conv);
25846 }
25847
25848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25849         LDKRawInvoice a_conv;
25850         a_conv.inner = (void*)(a & (~1));
25851         a_conv.is_owned = false;
25852         LDKRawInvoice b_conv;
25853         b_conv.inner = (void*)(b & (~1));
25854         b_conv.is_owned = false;
25855         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25856         return ret_val;
25857 }
25858
25859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25860         LDKRawInvoice orig_conv;
25861         orig_conv.inner = (void*)(orig & (~1));
25862         orig_conv.is_owned = false;
25863         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25866         uint64_t ret_ref = (uint64_t)ret_var.inner;
25867         if (ret_var.is_owned) {
25868                 ret_ref |= 1;
25869         }
25870         return ret_ref;
25871 }
25872
25873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25874         LDKRawDataPart this_obj_conv;
25875         this_obj_conv.inner = (void*)(this_obj & (~1));
25876         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25877         RawDataPart_free(this_obj_conv);
25878 }
25879
25880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25881         LDKRawDataPart this_ptr_conv;
25882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25883         this_ptr_conv.is_owned = false;
25884         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25887         uint64_t ret_ref = (uint64_t)ret_var.inner;
25888         if (ret_var.is_owned) {
25889                 ret_ref |= 1;
25890         }
25891         return ret_ref;
25892 }
25893
25894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25895         LDKRawDataPart this_ptr_conv;
25896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25897         this_ptr_conv.is_owned = false;
25898         LDKPositiveTimestamp val_conv;
25899         val_conv.inner = (void*)(val & (~1));
25900         val_conv.is_owned = (val & 1) || (val == 0);
25901         val_conv = PositiveTimestamp_clone(&val_conv);
25902         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25903 }
25904
25905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25906         LDKRawDataPart a_conv;
25907         a_conv.inner = (void*)(a & (~1));
25908         a_conv.is_owned = false;
25909         LDKRawDataPart b_conv;
25910         b_conv.inner = (void*)(b & (~1));
25911         b_conv.is_owned = false;
25912         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25913         return ret_val;
25914 }
25915
25916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25917         LDKRawDataPart orig_conv;
25918         orig_conv.inner = (void*)(orig & (~1));
25919         orig_conv.is_owned = false;
25920         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25921         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25922         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25923         uint64_t ret_ref = (uint64_t)ret_var.inner;
25924         if (ret_var.is_owned) {
25925                 ret_ref |= 1;
25926         }
25927         return ret_ref;
25928 }
25929
25930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25931         LDKPositiveTimestamp this_obj_conv;
25932         this_obj_conv.inner = (void*)(this_obj & (~1));
25933         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25934         PositiveTimestamp_free(this_obj_conv);
25935 }
25936
25937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25938         LDKPositiveTimestamp a_conv;
25939         a_conv.inner = (void*)(a & (~1));
25940         a_conv.is_owned = false;
25941         LDKPositiveTimestamp b_conv;
25942         b_conv.inner = (void*)(b & (~1));
25943         b_conv.is_owned = false;
25944         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25945         return ret_val;
25946 }
25947
25948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25949         LDKPositiveTimestamp orig_conv;
25950         orig_conv.inner = (void*)(orig & (~1));
25951         orig_conv.is_owned = false;
25952         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25955         uint64_t ret_ref = (uint64_t)ret_var.inner;
25956         if (ret_var.is_owned) {
25957                 ret_ref |= 1;
25958         }
25959         return ret_ref;
25960 }
25961
25962 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25963         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25964         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
25965         return ret_conv;
25966 }
25967
25968 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
25969         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
25970         return ret_conv;
25971 }
25972
25973 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
25974         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
25975         return ret_conv;
25976 }
25977
25978 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
25979         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
25980         return ret_conv;
25981 }
25982
25983 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
25984         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
25985         return ret_conv;
25986 }
25987
25988 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25989         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25990         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25991         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25992         return ret_val;
25993 }
25994
25995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
25996         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25997         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25998         return ret_val;
25999 }
26000
26001 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26002         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
26003         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
26004         return ret_conv;
26005 }
26006
26007 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
26008         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
26009         return ret_conv;
26010 }
26011
26012 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
26013         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
26014         return ret_conv;
26015 }
26016
26017 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
26018         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
26019         return ret_conv;
26020 }
26021
26022 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
26023         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
26024         return ret_conv;
26025 }
26026
26027 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
26028         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
26029         return ret_conv;
26030 }
26031
26032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26033         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
26034         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
26035         jboolean ret_val = Currency_eq(a_conv, b_conv);
26036         return ret_val;
26037 }
26038
26039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26040         LDKSha256 this_obj_conv;
26041         this_obj_conv.inner = (void*)(this_obj & (~1));
26042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26043         Sha256_free(this_obj_conv);
26044 }
26045
26046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26047         LDKSha256 a_conv;
26048         a_conv.inner = (void*)(a & (~1));
26049         a_conv.is_owned = false;
26050         LDKSha256 b_conv;
26051         b_conv.inner = (void*)(b & (~1));
26052         b_conv.is_owned = false;
26053         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
26054         return ret_val;
26055 }
26056
26057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26058         LDKSha256 orig_conv;
26059         orig_conv.inner = (void*)(orig & (~1));
26060         orig_conv.is_owned = false;
26061         LDKSha256 ret_var = Sha256_clone(&orig_conv);
26062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26064         uint64_t ret_ref = (uint64_t)ret_var.inner;
26065         if (ret_var.is_owned) {
26066                 ret_ref |= 1;
26067         }
26068         return ret_ref;
26069 }
26070
26071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26072         LDKDescription this_obj_conv;
26073         this_obj_conv.inner = (void*)(this_obj & (~1));
26074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26075         Description_free(this_obj_conv);
26076 }
26077
26078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26079         LDKDescription a_conv;
26080         a_conv.inner = (void*)(a & (~1));
26081         a_conv.is_owned = false;
26082         LDKDescription b_conv;
26083         b_conv.inner = (void*)(b & (~1));
26084         b_conv.is_owned = false;
26085         jboolean ret_val = Description_eq(&a_conv, &b_conv);
26086         return ret_val;
26087 }
26088
26089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26090         LDKDescription orig_conv;
26091         orig_conv.inner = (void*)(orig & (~1));
26092         orig_conv.is_owned = false;
26093         LDKDescription ret_var = Description_clone(&orig_conv);
26094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26096         uint64_t ret_ref = (uint64_t)ret_var.inner;
26097         if (ret_var.is_owned) {
26098                 ret_ref |= 1;
26099         }
26100         return ret_ref;
26101 }
26102
26103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26104         LDKPayeePubKey this_obj_conv;
26105         this_obj_conv.inner = (void*)(this_obj & (~1));
26106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26107         PayeePubKey_free(this_obj_conv);
26108 }
26109
26110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26111         LDKPayeePubKey a_conv;
26112         a_conv.inner = (void*)(a & (~1));
26113         a_conv.is_owned = false;
26114         LDKPayeePubKey b_conv;
26115         b_conv.inner = (void*)(b & (~1));
26116         b_conv.is_owned = false;
26117         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
26118         return ret_val;
26119 }
26120
26121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26122         LDKPayeePubKey orig_conv;
26123         orig_conv.inner = (void*)(orig & (~1));
26124         orig_conv.is_owned = false;
26125         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
26126         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26127         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26128         uint64_t ret_ref = (uint64_t)ret_var.inner;
26129         if (ret_var.is_owned) {
26130                 ret_ref |= 1;
26131         }
26132         return ret_ref;
26133 }
26134
26135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26136         LDKExpiryTime this_obj_conv;
26137         this_obj_conv.inner = (void*)(this_obj & (~1));
26138         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26139         ExpiryTime_free(this_obj_conv);
26140 }
26141
26142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26143         LDKExpiryTime a_conv;
26144         a_conv.inner = (void*)(a & (~1));
26145         a_conv.is_owned = false;
26146         LDKExpiryTime b_conv;
26147         b_conv.inner = (void*)(b & (~1));
26148         b_conv.is_owned = false;
26149         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
26150         return ret_val;
26151 }
26152
26153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26154         LDKExpiryTime orig_conv;
26155         orig_conv.inner = (void*)(orig & (~1));
26156         orig_conv.is_owned = false;
26157         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
26158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26160         uint64_t ret_ref = (uint64_t)ret_var.inner;
26161         if (ret_var.is_owned) {
26162                 ret_ref |= 1;
26163         }
26164         return ret_ref;
26165 }
26166
26167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26168         LDKMinFinalCltvExpiry this_obj_conv;
26169         this_obj_conv.inner = (void*)(this_obj & (~1));
26170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26171         MinFinalCltvExpiry_free(this_obj_conv);
26172 }
26173
26174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26175         LDKMinFinalCltvExpiry a_conv;
26176         a_conv.inner = (void*)(a & (~1));
26177         a_conv.is_owned = false;
26178         LDKMinFinalCltvExpiry b_conv;
26179         b_conv.inner = (void*)(b & (~1));
26180         b_conv.is_owned = false;
26181         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
26182         return ret_val;
26183 }
26184
26185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26186         LDKMinFinalCltvExpiry orig_conv;
26187         orig_conv.inner = (void*)(orig & (~1));
26188         orig_conv.is_owned = false;
26189         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
26190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26192         uint64_t ret_ref = (uint64_t)ret_var.inner;
26193         if (ret_var.is_owned) {
26194                 ret_ref |= 1;
26195         }
26196         return ret_ref;
26197 }
26198
26199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26200         if ((this_ptr & 1) != 0) return;
26201         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
26202         FREE((void*)this_ptr);
26203         Fallback_free(this_ptr_conv);
26204 }
26205
26206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26207         LDKFallback* orig_conv = (LDKFallback*)orig;
26208         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26209         *ret_copy = Fallback_clone(orig_conv);
26210         uint64_t ret_ref = (uint64_t)ret_copy;
26211         return ret_ref;
26212 }
26213
26214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
26215         
26216         LDKCVec_u8Z program_ref;
26217         program_ref.datalen = (*env)->GetArrayLength(env, program);
26218         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
26219         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
26220         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26221         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
26222         uint64_t ret_ref = (uint64_t)ret_copy;
26223         return ret_ref;
26224 }
26225
26226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26227         LDKTwentyBytes a_ref;
26228         CHECK((*env)->GetArrayLength(env, a) == 20);
26229         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26230         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26231         *ret_copy = Fallback_pub_key_hash(a_ref);
26232         uint64_t ret_ref = (uint64_t)ret_copy;
26233         return ret_ref;
26234 }
26235
26236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26237         LDKTwentyBytes a_ref;
26238         CHECK((*env)->GetArrayLength(env, a) == 20);
26239         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26240         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26241         *ret_copy = Fallback_script_hash(a_ref);
26242         uint64_t ret_ref = (uint64_t)ret_copy;
26243         return ret_ref;
26244 }
26245
26246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26247         LDKFallback* a_conv = (LDKFallback*)a;
26248         LDKFallback* b_conv = (LDKFallback*)b;
26249         jboolean ret_val = Fallback_eq(a_conv, b_conv);
26250         return ret_val;
26251 }
26252
26253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26254         LDKInvoiceSignature this_obj_conv;
26255         this_obj_conv.inner = (void*)(this_obj & (~1));
26256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26257         InvoiceSignature_free(this_obj_conv);
26258 }
26259
26260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26261         LDKInvoiceSignature a_conv;
26262         a_conv.inner = (void*)(a & (~1));
26263         a_conv.is_owned = false;
26264         LDKInvoiceSignature b_conv;
26265         b_conv.inner = (void*)(b & (~1));
26266         b_conv.is_owned = false;
26267         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
26268         return ret_val;
26269 }
26270
26271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26272         LDKInvoiceSignature orig_conv;
26273         orig_conv.inner = (void*)(orig & (~1));
26274         orig_conv.is_owned = false;
26275         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
26276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26278         uint64_t ret_ref = (uint64_t)ret_var.inner;
26279         if (ret_var.is_owned) {
26280                 ret_ref |= 1;
26281         }
26282         return ret_ref;
26283 }
26284
26285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26286         LDKPrivateRoute this_obj_conv;
26287         this_obj_conv.inner = (void*)(this_obj & (~1));
26288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26289         PrivateRoute_free(this_obj_conv);
26290 }
26291
26292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26293         LDKPrivateRoute a_conv;
26294         a_conv.inner = (void*)(a & (~1));
26295         a_conv.is_owned = false;
26296         LDKPrivateRoute b_conv;
26297         b_conv.inner = (void*)(b & (~1));
26298         b_conv.is_owned = false;
26299         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
26300         return ret_val;
26301 }
26302
26303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26304         LDKPrivateRoute orig_conv;
26305         orig_conv.inner = (void*)(orig & (~1));
26306         orig_conv.is_owned = false;
26307         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
26308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26310         uint64_t ret_ref = (uint64_t)ret_var.inner;
26311         if (ret_var.is_owned) {
26312                 ret_ref |= 1;
26313         }
26314         return ret_ref;
26315 }
26316
26317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
26318         LDKSignedRawInvoice this_arg_conv;
26319         this_arg_conv.inner = (void*)(this_arg & (~1));
26320         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26321         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
26322         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
26323         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
26324         return (uint64_t)ret_ref;
26325 }
26326
26327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
26328         LDKSignedRawInvoice this_arg_conv;
26329         this_arg_conv.inner = (void*)(this_arg & (~1));
26330         this_arg_conv.is_owned = false;
26331         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
26332         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26333         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26334         uint64_t ret_ref = (uint64_t)ret_var.inner;
26335         if (ret_var.is_owned) {
26336                 ret_ref |= 1;
26337         }
26338         return ret_ref;
26339 }
26340
26341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26342         LDKSignedRawInvoice this_arg_conv;
26343         this_arg_conv.inner = (void*)(this_arg & (~1));
26344         this_arg_conv.is_owned = false;
26345         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26346         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
26347         return ret_arr;
26348 }
26349
26350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26351         LDKSignedRawInvoice this_arg_conv;
26352         this_arg_conv.inner = (void*)(this_arg & (~1));
26353         this_arg_conv.is_owned = false;
26354         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
26355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26357         uint64_t ret_ref = (uint64_t)ret_var.inner;
26358         if (ret_var.is_owned) {
26359                 ret_ref |= 1;
26360         }
26361         return ret_ref;
26362 }
26363
26364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26365         LDKSignedRawInvoice this_arg_conv;
26366         this_arg_conv.inner = (void*)(this_arg & (~1));
26367         this_arg_conv.is_owned = false;
26368         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
26369         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
26370         return (uint64_t)ret_conv;
26371 }
26372
26373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26374         LDKSignedRawInvoice this_arg_conv;
26375         this_arg_conv.inner = (void*)(this_arg & (~1));
26376         this_arg_conv.is_owned = false;
26377         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
26378         return ret_val;
26379 }
26380
26381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26382         LDKRawInvoice this_arg_conv;
26383         this_arg_conv.inner = (void*)(this_arg & (~1));
26384         this_arg_conv.is_owned = false;
26385         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26386         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
26387         return ret_arr;
26388 }
26389
26390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26391         LDKRawInvoice this_arg_conv;
26392         this_arg_conv.inner = (void*)(this_arg & (~1));
26393         this_arg_conv.is_owned = false;
26394         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
26395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26397         uint64_t ret_ref = (uint64_t)ret_var.inner;
26398         if (ret_var.is_owned) {
26399                 ret_ref |= 1;
26400         }
26401         return ret_ref;
26402 }
26403
26404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
26405         LDKRawInvoice this_arg_conv;
26406         this_arg_conv.inner = (void*)(this_arg & (~1));
26407         this_arg_conv.is_owned = false;
26408         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
26409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26411         uint64_t ret_ref = (uint64_t)ret_var.inner;
26412         if (ret_var.is_owned) {
26413                 ret_ref |= 1;
26414         }
26415         return ret_ref;
26416 }
26417
26418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26419         LDKRawInvoice this_arg_conv;
26420         this_arg_conv.inner = (void*)(this_arg & (~1));
26421         this_arg_conv.is_owned = false;
26422         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
26423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26425         uint64_t ret_ref = (uint64_t)ret_var.inner;
26426         if (ret_var.is_owned) {
26427                 ret_ref |= 1;
26428         }
26429         return ret_ref;
26430 }
26431
26432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26433         LDKRawInvoice this_arg_conv;
26434         this_arg_conv.inner = (void*)(this_arg & (~1));
26435         this_arg_conv.is_owned = false;
26436         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
26437         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26438         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26439         uint64_t ret_ref = (uint64_t)ret_var.inner;
26440         if (ret_var.is_owned) {
26441                 ret_ref |= 1;
26442         }
26443         return ret_ref;
26444 }
26445
26446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26447         LDKRawInvoice this_arg_conv;
26448         this_arg_conv.inner = (void*)(this_arg & (~1));
26449         this_arg_conv.is_owned = false;
26450         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
26451         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26452         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26453         uint64_t ret_ref = (uint64_t)ret_var.inner;
26454         if (ret_var.is_owned) {
26455                 ret_ref |= 1;
26456         }
26457         return ret_ref;
26458 }
26459
26460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
26461         LDKRawInvoice this_arg_conv;
26462         this_arg_conv.inner = (void*)(this_arg & (~1));
26463         this_arg_conv.is_owned = false;
26464         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
26465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26467         uint64_t ret_ref = (uint64_t)ret_var.inner;
26468         if (ret_var.is_owned) {
26469                 ret_ref |= 1;
26470         }
26471         return ret_ref;
26472 }
26473
26474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26475         LDKRawInvoice this_arg_conv;
26476         this_arg_conv.inner = (void*)(this_arg & (~1));
26477         this_arg_conv.is_owned = false;
26478         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26479         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
26480         return ret_arr;
26481 }
26482
26483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
26484         LDKRawInvoice this_arg_conv;
26485         this_arg_conv.inner = (void*)(this_arg & (~1));
26486         this_arg_conv.is_owned = false;
26487         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
26488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26490         uint64_t ret_ref = (uint64_t)ret_var.inner;
26491         if (ret_var.is_owned) {
26492                 ret_ref |= 1;
26493         }
26494         return ret_ref;
26495 }
26496
26497 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26498         LDKRawInvoice this_arg_conv;
26499         this_arg_conv.inner = (void*)(this_arg & (~1));
26500         this_arg_conv.is_owned = false;
26501         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
26502         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26503         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26504         for (size_t o = 0; o < ret_var.datalen; o++) {
26505                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26506                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26507                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26508                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26509                 if (ret_conv_14_var.is_owned) {
26510                         ret_conv_14_ref |= 1;
26511                 }
26512                 ret_arr_ptr[o] = ret_conv_14_ref;
26513         }
26514         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26515         FREE(ret_var.data);
26516         return ret_arr;
26517 }
26518
26519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26520         LDKRawInvoice this_arg_conv;
26521         this_arg_conv.inner = (void*)(this_arg & (~1));
26522         this_arg_conv.is_owned = false;
26523         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26524         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
26525         uint64_t ret_ref = (uint64_t)ret_copy;
26526         return ret_ref;
26527 }
26528
26529 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26530         LDKRawInvoice this_arg_conv;
26531         this_arg_conv.inner = (void*)(this_arg & (~1));
26532         this_arg_conv.is_owned = false;
26533         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
26534         return ret_conv;
26535 }
26536
26537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
26538         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26539         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
26540         return (uint64_t)ret_conv;
26541 }
26542
26543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
26544         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26545         *ret_conv = PositiveTimestamp_from_system_time(time);
26546         return (uint64_t)ret_conv;
26547 }
26548
26549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26550         LDKPositiveTimestamp this_arg_conv;
26551         this_arg_conv.inner = (void*)(this_arg & (~1));
26552         this_arg_conv.is_owned = false;
26553         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
26554         return ret_val;
26555 }
26556
26557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26558         LDKPositiveTimestamp this_arg_conv;
26559         this_arg_conv.inner = (void*)(this_arg & (~1));
26560         this_arg_conv.is_owned = false;
26561         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
26562         return ret_val;
26563 }
26564
26565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
26566         LDKInvoice this_arg_conv;
26567         this_arg_conv.inner = (void*)(this_arg & (~1));
26568         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26569         this_arg_conv = Invoice_clone(&this_arg_conv);
26570         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
26571         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26572         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26573         uint64_t ret_ref = (uint64_t)ret_var.inner;
26574         if (ret_var.is_owned) {
26575                 ret_ref |= 1;
26576         }
26577         return ret_ref;
26578 }
26579
26580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26581         LDKInvoice this_arg_conv;
26582         this_arg_conv.inner = (void*)(this_arg & (~1));
26583         this_arg_conv.is_owned = false;
26584         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26585         *ret_conv = Invoice_check_signature(&this_arg_conv);
26586         return (uint64_t)ret_conv;
26587 }
26588
26589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
26590         LDKSignedRawInvoice signed_invoice_conv;
26591         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26592         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26593         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26594         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26595         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26596         return (uint64_t)ret_conv;
26597 }
26598
26599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26600         LDKInvoice this_arg_conv;
26601         this_arg_conv.inner = (void*)(this_arg & (~1));
26602         this_arg_conv.is_owned = false;
26603         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26604         return ret_val;
26605 }
26606
26607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26608         LDKInvoice this_arg_conv;
26609         this_arg_conv.inner = (void*)(this_arg & (~1));
26610         this_arg_conv.is_owned = false;
26611         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
26613         return ret_arr;
26614 }
26615
26616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26617         LDKInvoice this_arg_conv;
26618         this_arg_conv.inner = (void*)(this_arg & (~1));
26619         this_arg_conv.is_owned = false;
26620         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
26622         return ret_arr;
26623 }
26624
26625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26626         LDKInvoice this_arg_conv;
26627         this_arg_conv.inner = (void*)(this_arg & (~1));
26628         this_arg_conv.is_owned = false;
26629         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
26631         return ret_arr;
26632 }
26633
26634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
26635         LDKInvoice this_arg_conv;
26636         this_arg_conv.inner = (void*)(this_arg & (~1));
26637         this_arg_conv.is_owned = false;
26638         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26641         uint64_t ret_ref = (uint64_t)ret_var.inner;
26642         if (ret_var.is_owned) {
26643                 ret_ref |= 1;
26644         }
26645         return ret_ref;
26646 }
26647
26648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26649         LDKInvoice this_arg_conv;
26650         this_arg_conv.inner = (void*)(this_arg & (~1));
26651         this_arg_conv.is_owned = false;
26652         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
26654         return ret_arr;
26655 }
26656
26657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26658         LDKInvoice this_arg_conv;
26659         this_arg_conv.inner = (void*)(this_arg & (~1));
26660         this_arg_conv.is_owned = false;
26661         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
26662         return ret_val;
26663 }
26664
26665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
26666         LDKInvoice this_arg_conv;
26667         this_arg_conv.inner = (void*)(this_arg & (~1));
26668         this_arg_conv.is_owned = false;
26669         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
26670         return ret_val;
26671 }
26672
26673 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26674         LDKInvoice this_arg_conv;
26675         this_arg_conv.inner = (void*)(this_arg & (~1));
26676         this_arg_conv.is_owned = false;
26677         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
26678         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26679         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26680         for (size_t o = 0; o < ret_var.datalen; o++) {
26681                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26682                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26683                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26684                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26685                 if (ret_conv_14_var.is_owned) {
26686                         ret_conv_14_ref |= 1;
26687                 }
26688                 ret_arr_ptr[o] = ret_conv_14_ref;
26689         }
26690         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26691         FREE(ret_var.data);
26692         return ret_arr;
26693 }
26694
26695 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
26696         LDKInvoice this_arg_conv;
26697         this_arg_conv.inner = (void*)(this_arg & (~1));
26698         this_arg_conv.is_owned = false;
26699         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
26700         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26701         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26702         for (size_t l = 0; l < ret_var.datalen; l++) {
26703                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
26704                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26705                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26706                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
26707                 if (ret_conv_11_var.is_owned) {
26708                         ret_conv_11_ref |= 1;
26709                 }
26710                 ret_arr_ptr[l] = ret_conv_11_ref;
26711         }
26712         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26713         FREE(ret_var.data);
26714         return ret_arr;
26715 }
26716
26717 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26718         LDKInvoice this_arg_conv;
26719         this_arg_conv.inner = (void*)(this_arg & (~1));
26720         this_arg_conv.is_owned = false;
26721         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
26722         return ret_conv;
26723 }
26724
26725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26726         LDKInvoice this_arg_conv;
26727         this_arg_conv.inner = (void*)(this_arg & (~1));
26728         this_arg_conv.is_owned = false;
26729         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26730         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
26731         uint64_t ret_ref = (uint64_t)ret_copy;
26732         return ret_ref;
26733 }
26734
26735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
26736         LDKStr description_conv = java_to_owned_str(env, description);
26737         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
26738         *ret_conv = Description_new(description_conv);
26739         return (uint64_t)ret_conv;
26740 }
26741
26742 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26743         LDKDescription this_arg_conv;
26744         this_arg_conv.inner = (void*)(this_arg & (~1));
26745         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26746         this_arg_conv = Description_clone(&this_arg_conv);
26747         LDKStr ret_str = Description_into_inner(this_arg_conv);
26748         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26749         Str_free(ret_str);
26750         return ret_conv;
26751 }
26752
26753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
26754         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26755         *ret_conv = ExpiryTime_from_seconds(seconds);
26756         return (uint64_t)ret_conv;
26757 }
26758
26759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
26760         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26761         *ret_conv = ExpiryTime_from_duration(duration);
26762         return (uint64_t)ret_conv;
26763 }
26764
26765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
26766         LDKExpiryTime this_arg_conv;
26767         this_arg_conv.inner = (void*)(this_arg & (~1));
26768         this_arg_conv.is_owned = false;
26769         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
26770         return ret_val;
26771 }
26772
26773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
26774         LDKExpiryTime this_arg_conv;
26775         this_arg_conv.inner = (void*)(this_arg & (~1));
26776         this_arg_conv.is_owned = false;
26777         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
26778         return ret_val;
26779 }
26780
26781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
26782         LDKRouteHint hops_conv;
26783         hops_conv.inner = (void*)(hops & (~1));
26784         hops_conv.is_owned = (hops & 1) || (hops == 0);
26785         hops_conv = RouteHint_clone(&hops_conv);
26786         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26787         *ret_conv = PrivateRoute_new(hops_conv);
26788         return (uint64_t)ret_conv;
26789 }
26790
26791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26792         LDKPrivateRoute this_arg_conv;
26793         this_arg_conv.inner = (void*)(this_arg & (~1));
26794         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26795         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26796         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26799         uint64_t ret_ref = (uint64_t)ret_var.inner;
26800         if (ret_var.is_owned) {
26801                 ret_ref |= 1;
26802         }
26803         return ret_ref;
26804 }
26805
26806 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26807         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26808         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
26809         return ret_conv;
26810 }
26811
26812 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
26813         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
26814         return ret_conv;
26815 }
26816
26817 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
26818         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
26819         return ret_conv;
26820 }
26821
26822 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
26823         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
26824         return ret_conv;
26825 }
26826
26827 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
26828         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
26829         return ret_conv;
26830 }
26831
26832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26833         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26834         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26835         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26836         return ret_val;
26837 }
26838
26839 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26840         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26841         LDKStr ret_str = CreationError_to_str(o_conv);
26842         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26843         Str_free(ret_str);
26844         return ret_conv;
26845 }
26846
26847 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26848         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26849         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
26850         return ret_conv;
26851 }
26852
26853 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
26854         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
26855         return ret_conv;
26856 }
26857
26858 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
26859         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
26860         return ret_conv;
26861 }
26862
26863 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
26864         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
26865         return ret_conv;
26866 }
26867
26868 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
26869         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
26870         return ret_conv;
26871 }
26872
26873 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
26874         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
26875         return ret_conv;
26876 }
26877
26878 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
26879         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
26880         return ret_conv;
26881 }
26882
26883 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
26884         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
26885         return ret_conv;
26886 }
26887
26888 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
26889         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
26890         return ret_conv;
26891 }
26892
26893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26894         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26895         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26896         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26897         return ret_val;
26898 }
26899
26900 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26901         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26902         LDKStr ret_str = SemanticError_to_str(o_conv);
26903         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26904         Str_free(ret_str);
26905         return ret_conv;
26906 }
26907
26908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26909         if ((this_ptr & 1) != 0) return;
26910         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26911         FREE((void*)this_ptr);
26912         SignOrCreationError_free(this_ptr_conv);
26913 }
26914
26915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26916         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26917         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26918         *ret_copy = SignOrCreationError_clone(orig_conv);
26919         uint64_t ret_ref = (uint64_t)ret_copy;
26920         return ret_ref;
26921 }
26922
26923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
26924         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26925         *ret_copy = SignOrCreationError_sign_error();
26926         uint64_t ret_ref = (uint64_t)ret_copy;
26927         return ret_ref;
26928 }
26929
26930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
26931         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
26932         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26933         *ret_copy = SignOrCreationError_creation_error(a_conv);
26934         uint64_t ret_ref = (uint64_t)ret_copy;
26935         return ret_ref;
26936 }
26937
26938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26939         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26940         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26941         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26942         return ret_val;
26943 }
26944
26945 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26946         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26947         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26948         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26949         Str_free(ret_str);
26950         return ret_conv;
26951 }
26952
26953 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) {
26954         LDKChannelManager channelmanager_conv;
26955         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26956         channelmanager_conv.is_owned = false;
26957         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26958         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26959                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26960                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26961         }
26962         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
26963         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26964         LDKStr description_conv = java_to_owned_str(env, description);
26965         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26966         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26967         return (uint64_t)ret_conv;
26968 }
26969
26970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26971         LDKStr s_conv = java_to_owned_str(env, s);
26972         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26973         *ret_conv = SiPrefix_from_str(s_conv);
26974         return (uint64_t)ret_conv;
26975 }
26976
26977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26978         LDKStr s_conv = java_to_owned_str(env, s);
26979         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26980         *ret_conv = Invoice_from_str(s_conv);
26981         return (uint64_t)ret_conv;
26982 }
26983
26984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26985         LDKStr s_conv = java_to_owned_str(env, s);
26986         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26987         *ret_conv = SignedRawInvoice_from_str(s_conv);
26988         return (uint64_t)ret_conv;
26989 }
26990
26991 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26992         LDKInvoice o_conv;
26993         o_conv.inner = (void*)(o & (~1));
26994         o_conv.is_owned = false;
26995         LDKStr ret_str = Invoice_to_str(&o_conv);
26996         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26997         Str_free(ret_str);
26998         return ret_conv;
26999 }
27000
27001 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27002         LDKSignedRawInvoice o_conv;
27003         o_conv.inner = (void*)(o & (~1));
27004         o_conv.is_owned = false;
27005         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
27006         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27007         Str_free(ret_str);
27008         return ret_conv;
27009 }
27010
27011 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27012         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
27013         LDKStr ret_str = Currency_to_str(o_conv);
27014         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27015         Str_free(ret_str);
27016         return ret_conv;
27017 }
27018
27019 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27020         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
27021         LDKStr ret_str = SiPrefix_to_str(o_conv);
27022         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27023         Str_free(ret_str);
27024         return ret_conv;
27025 }
27026