Bump version to 0.0.100.2
[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.100.2", strlen("v0.0.100.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_1ShutdownScriptDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1035         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
1036 }
1037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1038         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1039         CHECK(val->result_ok);
1040         LDKShutdownScript res_var = (*val->contents.result);
1041         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1042         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1043         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1044         return res_ref;
1045 }
1046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1047         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1048         CHECK(!val->result_ok);
1049         LDKDecodeError err_var = (*val->contents.err);
1050         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1051         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1052         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1053         return err_ref;
1054 }
1055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1056         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
1057 }
1058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1059         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1060         CHECK(val->result_ok);
1061         LDKShutdownScript res_var = (*val->contents.result);
1062         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1063         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1064         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1065         return res_ref;
1066 }
1067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1068         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1069         CHECK(!val->result_ok);
1070         LDKInvalidShutdownScript err_var = (*val->contents.err);
1071         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1072         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1073         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1074         return err_ref;
1075 }
1076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1077         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1078 }
1079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1080         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1081         CHECK(val->result_ok);
1082         return *val->contents.result;
1083 }
1084 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1085         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1086         CHECK(!val->result_ok);
1087         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1088         return err_conv;
1089 }
1090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1091         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1092 }
1093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1094         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1095         CHECK(val->result_ok);
1096         LDKRouteHop res_var = (*val->contents.result);
1097         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1098         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1099         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1100         return res_ref;
1101 }
1102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1103         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1104         CHECK(!val->result_ok);
1105         LDKDecodeError err_var = (*val->contents.err);
1106         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1109         return err_ref;
1110 }
1111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1112         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1113         ret->datalen = (*env)->GetArrayLength(env, elems);
1114         if (ret->datalen == 0) {
1115                 ret->data = NULL;
1116         } else {
1117                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1118                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1119                 for (size_t i = 0; i < ret->datalen; i++) {
1120                         int64_t arr_elem = java_elems[i];
1121                         LDKRouteHop arr_elem_conv;
1122                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1123                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1124                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1125                         ret->data[i] = arr_elem_conv;
1126                 }
1127                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1128         }
1129         return (uint64_t)ret;
1130 }
1131 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1132         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1133         for (size_t i = 0; i < ret.datalen; i++) {
1134                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1135         }
1136         return ret;
1137 }
1138 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1139         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1140         for (size_t i = 0; i < ret.datalen; i++) {
1141                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1142         }
1143         return ret;
1144 }
1145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1146         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1147 }
1148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1149         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1150         CHECK(val->result_ok);
1151         LDKRoute res_var = (*val->contents.result);
1152         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1153         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1154         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1155         return res_ref;
1156 }
1157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1158         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1159         CHECK(!val->result_ok);
1160         LDKDecodeError err_var = (*val->contents.err);
1161         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1162         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1163         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1164         return err_ref;
1165 }
1166 static jclass LDKCOption_u64Z_Some_class = NULL;
1167 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1168 static jclass LDKCOption_u64Z_None_class = NULL;
1169 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1171         LDKCOption_u64Z_Some_class =
1172                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1173         CHECK(LDKCOption_u64Z_Some_class != NULL);
1174         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1175         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1176         LDKCOption_u64Z_None_class =
1177                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1178         CHECK(LDKCOption_u64Z_None_class != NULL);
1179         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1180         CHECK(LDKCOption_u64Z_None_meth != NULL);
1181 }
1182 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1183         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1184         switch(obj->tag) {
1185                 case LDKCOption_u64Z_Some: {
1186                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1187                 }
1188                 case LDKCOption_u64Z_None: {
1189                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1190                 }
1191                 default: abort();
1192         }
1193 }
1194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1195         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1196         ret->datalen = (*env)->GetArrayLength(env, elems);
1197         if (ret->datalen == 0) {
1198                 ret->data = NULL;
1199         } else {
1200                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1201                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1202                 for (size_t i = 0; i < ret->datalen; i++) {
1203                         int64_t arr_elem = java_elems[i];
1204                         LDKChannelDetails arr_elem_conv;
1205                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1206                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1207                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1208                         ret->data[i] = arr_elem_conv;
1209                 }
1210                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1211         }
1212         return (uint64_t)ret;
1213 }
1214 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1215         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1216         for (size_t i = 0; i < ret.datalen; i++) {
1217                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1218         }
1219         return ret;
1220 }
1221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1222         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1223         ret->datalen = (*env)->GetArrayLength(env, elems);
1224         if (ret->datalen == 0) {
1225                 ret->data = NULL;
1226         } else {
1227                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1228                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1229                 for (size_t i = 0; i < ret->datalen; i++) {
1230                         int64_t arr_elem = java_elems[i];
1231                         LDKRouteHint arr_elem_conv;
1232                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1233                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1234                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1235                         ret->data[i] = arr_elem_conv;
1236                 }
1237                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1238         }
1239         return (uint64_t)ret;
1240 }
1241 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1242         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1243         for (size_t i = 0; i < ret.datalen; i++) {
1244                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1245         }
1246         return ret;
1247 }
1248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1249         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1250 }
1251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1252         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1253         CHECK(val->result_ok);
1254         LDKRoute res_var = (*val->contents.result);
1255         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1256         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1257         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1258         return res_ref;
1259 }
1260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1261         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1262         CHECK(!val->result_ok);
1263         LDKLightningError err_var = (*val->contents.err);
1264         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1265         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1266         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1267         return err_ref;
1268 }
1269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1270         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1271 }
1272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1273         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1274         CHECK(val->result_ok);
1275         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1276         return (uint64_t)res_ref;
1277 }
1278 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1279         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1280         CHECK(!val->result_ok);
1281         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1282         return err_conv;
1283 }
1284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1285         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1286         ret->a = a;
1287         LDKTransaction b_ref;
1288         b_ref.datalen = (*env)->GetArrayLength(env, b);
1289         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1290         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1291         b_ref.data_is_owned = false;
1292         ret->b = b_ref;
1293         return (uint64_t)ret;
1294 }
1295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1296         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1297         return tuple->a;
1298 }
1299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1300         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1301         LDKTransaction b_var = tuple->b;
1302         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1303         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1304         return b_arr;
1305 }
1306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1307         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1308         ret->datalen = (*env)->GetArrayLength(env, elems);
1309         if (ret->datalen == 0) {
1310                 ret->data = NULL;
1311         } else {
1312                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1313                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1314                 for (size_t i = 0; i < ret->datalen; i++) {
1315                         int64_t arr_elem = java_elems[i];
1316                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1317                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1318                         ret->data[i] = arr_elem_conv;
1319                 }
1320                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1321         }
1322         return (uint64_t)ret;
1323 }
1324 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1325         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1326         for (size_t i = 0; i < ret.datalen; i++) {
1327                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1328         }
1329         return ret;
1330 }
1331 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1332         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1333         for (size_t i = 0; i < ret.datalen; i++) {
1334                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1335         }
1336         return ret;
1337 }
1338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1339         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1340 }
1341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1342         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1343         CHECK(val->result_ok);
1344         return *val->contents.result;
1345 }
1346 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1347         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1348         CHECK(!val->result_ok);
1349         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1350         return err_conv;
1351 }
1352 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1353 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1354 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1355 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1357         LDKMonitorEvent_HTLCEvent_class =
1358                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1359         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1360         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1361         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1362         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1363                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1364         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1365         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1366         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1367 }
1368 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1369         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1370         switch(obj->tag) {
1371                 case LDKMonitorEvent_HTLCEvent: {
1372                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1373                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1374                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1375                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1376                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1377                 }
1378                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1379                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1380                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1381                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1382                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1383                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1384                 }
1385                 default: abort();
1386         }
1387 }
1388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1389         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1390         ret->datalen = (*env)->GetArrayLength(env, elems);
1391         if (ret->datalen == 0) {
1392                 ret->data = NULL;
1393         } else {
1394                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1395                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1396                 for (size_t i = 0; i < ret->datalen; i++) {
1397                         int64_t arr_elem = java_elems[i];
1398                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1399                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1400                         ret->data[i] = arr_elem_conv;
1401                 }
1402                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1403         }
1404         return (uint64_t)ret;
1405 }
1406 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1407         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1408         for (size_t i = 0; i < ret.datalen; i++) {
1409                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1410         }
1411         return ret;
1412 }
1413 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1414 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1415 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1416 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1418         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1419                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1420         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1421         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1422         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1423         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1424                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1425         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1426         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1427         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1428 }
1429 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1430         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1431         switch(obj->tag) {
1432                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1433                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1434                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1435                 }
1436                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1437                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1438                 }
1439                 default: abort();
1440         }
1441 }
1442 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1443 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1444 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1445 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1446 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1447 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1449         LDKSpendableOutputDescriptor_StaticOutput_class =
1450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1451         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1452         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1453         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1454         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1455                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1456         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1457         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1458         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1459         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1460                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1461         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1462         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1463         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1464 }
1465 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1466         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1467         switch(obj->tag) {
1468                 case LDKSpendableOutputDescriptor_StaticOutput: {
1469                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1470                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1471                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1472                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1473                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1474                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1475                 }
1476                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1477                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1478                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1479                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1480                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1481                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1482                 }
1483                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1484                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1485                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1486                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1487                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1488                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1489                 }
1490                 default: abort();
1491         }
1492 }
1493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1494         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1495         ret->datalen = (*env)->GetArrayLength(env, elems);
1496         if (ret->datalen == 0) {
1497                 ret->data = NULL;
1498         } else {
1499                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1500                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1501                 for (size_t i = 0; i < ret->datalen; i++) {
1502                         int64_t arr_elem = java_elems[i];
1503                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1504                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1505                         ret->data[i] = arr_elem_conv;
1506                 }
1507                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1508         }
1509         return (uint64_t)ret;
1510 }
1511 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1512         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1513         for (size_t i = 0; i < ret.datalen; i++) {
1514                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1515         }
1516         return ret;
1517 }
1518 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1519 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1520 static jclass LDKErrorAction_IgnoreError_class = NULL;
1521 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1522 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1523 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1524 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1525 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1527         LDKErrorAction_DisconnectPeer_class =
1528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1529         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1530         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1531         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1532         LDKErrorAction_IgnoreError_class =
1533                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1534         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1535         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1536         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1537         LDKErrorAction_IgnoreAndLog_class =
1538                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1539         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1540         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1541         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1542         LDKErrorAction_SendErrorMessage_class =
1543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1544         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1545         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1546         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1547 }
1548 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1549         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1550         switch(obj->tag) {
1551                 case LDKErrorAction_DisconnectPeer: {
1552                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1553                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1554                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1555                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1556                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1557                 }
1558                 case LDKErrorAction_IgnoreError: {
1559                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1560                 }
1561                 case LDKErrorAction_IgnoreAndLog: {
1562                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1563                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1564                 }
1565                 case LDKErrorAction_SendErrorMessage: {
1566                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1567                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1568                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1569                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1570                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1571                 }
1572                 default: abort();
1573         }
1574 }
1575 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1576 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1577 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1578 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1579 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1580 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1582         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1584         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1585         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1586         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1587         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1588                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1589         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1590         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1591         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1592         LDKHTLCFailChannelUpdate_NodeFailure_class =
1593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1594         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1595         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1596         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1597 }
1598 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1599         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1600         switch(obj->tag) {
1601                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1602                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1603                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1604                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1605                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1606                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1607                 }
1608                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1609                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1610                 }
1611                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1612                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1613                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1614                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1615                 }
1616                 default: abort();
1617         }
1618 }
1619 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1620 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1621 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1622 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1623 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1624 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1625 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1626 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1627 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1628 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1629 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1630 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1631 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1632 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1633 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1634 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1635 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1636 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1637 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1638 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1639 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1640 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1641 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1642 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1643 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1644 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1645 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1646 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1647 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1648 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1649 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1650 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1651 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1652 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1653 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1654 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1655 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1656 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1657 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1658 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1660         LDKMessageSendEvent_SendAcceptChannel_class =
1661                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1662         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1663         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1664         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1665         LDKMessageSendEvent_SendOpenChannel_class =
1666                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1667         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1668         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1669         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1670         LDKMessageSendEvent_SendFundingCreated_class =
1671                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1672         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1673         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1674         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1675         LDKMessageSendEvent_SendFundingSigned_class =
1676                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1677         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1678         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1679         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1680         LDKMessageSendEvent_SendFundingLocked_class =
1681                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1682         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1683         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1684         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1685         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1686                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1687         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1688         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1689         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1690         LDKMessageSendEvent_UpdateHTLCs_class =
1691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1692         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1693         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1694         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1695         LDKMessageSendEvent_SendRevokeAndACK_class =
1696                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1697         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1698         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1699         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1700         LDKMessageSendEvent_SendClosingSigned_class =
1701                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1702         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1703         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1704         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1705         LDKMessageSendEvent_SendShutdown_class =
1706                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1707         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1708         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1709         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1710         LDKMessageSendEvent_SendChannelReestablish_class =
1711                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1712         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1713         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1714         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1715         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1717         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1718         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1719         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1720         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1722         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1723         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1724         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1725         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1726                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1727         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1728         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1729         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1730         LDKMessageSendEvent_SendChannelUpdate_class =
1731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1732         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1733         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1734         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1735         LDKMessageSendEvent_HandleError_class =
1736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1737         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1738         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1739         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1740         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1742         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1743         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1744         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1745         LDKMessageSendEvent_SendChannelRangeQuery_class =
1746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1747         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1748         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1749         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1750         LDKMessageSendEvent_SendShortIdsQuery_class =
1751                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1752         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1753         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1754         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1755         LDKMessageSendEvent_SendReplyChannelRange_class =
1756                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1757         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1758         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1759         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1760 }
1761 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1762         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1763         switch(obj->tag) {
1764                 case LDKMessageSendEvent_SendAcceptChannel: {
1765                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1766                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1767                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1768                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1769                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1770                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1771                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1772                 }
1773                 case LDKMessageSendEvent_SendOpenChannel: {
1774                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1775                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1776                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1777                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1778                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1779                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1780                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1781                 }
1782                 case LDKMessageSendEvent_SendFundingCreated: {
1783                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1784                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1785                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1786                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1787                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1788                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1789                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1790                 }
1791                 case LDKMessageSendEvent_SendFundingSigned: {
1792                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1793                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1794                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1795                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1796                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1797                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1798                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1799                 }
1800                 case LDKMessageSendEvent_SendFundingLocked: {
1801                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1802                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1803                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1804                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1805                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1806                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1807                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1808                 }
1809                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1810                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1811                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1812                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1813                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1814                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1815                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1816                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1817                 }
1818                 case LDKMessageSendEvent_UpdateHTLCs: {
1819                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1820                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1821                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1822                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1823                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1824                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1825                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1826                 }
1827                 case LDKMessageSendEvent_SendRevokeAndACK: {
1828                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1829                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1830                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1831                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1832                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1833                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1834                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1835                 }
1836                 case LDKMessageSendEvent_SendClosingSigned: {
1837                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1838                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1839                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1840                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1841                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1842                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1843                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1844                 }
1845                 case LDKMessageSendEvent_SendShutdown: {
1846                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1847                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1848                         LDKShutdown msg_var = obj->send_shutdown.msg;
1849                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1850                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1851                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1852                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1853                 }
1854                 case LDKMessageSendEvent_SendChannelReestablish: {
1855                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1856                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1857                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1858                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1859                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1860                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1861                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1862                 }
1863                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1864                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1865                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1866                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1867                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1868                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1869                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1870                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1871                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1872                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1873                 }
1874                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1875                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1876                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1877                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1878                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1879                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1880                 }
1881                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1882                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1883                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1884                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1885                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1886                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1887                 }
1888                 case LDKMessageSendEvent_SendChannelUpdate: {
1889                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1890                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1891                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1892                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1893                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1894                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1895                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1896                 }
1897                 case LDKMessageSendEvent_HandleError: {
1898                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1899                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1900                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1901                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1902                 }
1903                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1904                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1905                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1906                 }
1907                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1908                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1909                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1910                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1911                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1912                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1913                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1914                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1915                 }
1916                 case LDKMessageSendEvent_SendShortIdsQuery: {
1917                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1918                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1919                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1920                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1921                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1922                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1923                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1924                 }
1925                 case LDKMessageSendEvent_SendReplyChannelRange: {
1926                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1927                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1928                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1929                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1930                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1931                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1932                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1933                 }
1934                 default: abort();
1935         }
1936 }
1937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1938         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1939         ret->datalen = (*env)->GetArrayLength(env, elems);
1940         if (ret->datalen == 0) {
1941                 ret->data = NULL;
1942         } else {
1943                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1944                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1945                 for (size_t i = 0; i < ret->datalen; i++) {
1946                         int64_t arr_elem = java_elems[i];
1947                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1948                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1949                         ret->data[i] = arr_elem_conv;
1950                 }
1951                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1952         }
1953         return (uint64_t)ret;
1954 }
1955 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1956         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1957         for (size_t i = 0; i < ret.datalen; i++) {
1958                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1959         }
1960         return ret;
1961 }
1962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1963         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1964 }
1965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1966         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1967         CHECK(val->result_ok);
1968         LDKInitFeatures 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_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1975         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(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_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1984         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1985 }
1986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1987         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1988         CHECK(val->result_ok);
1989         LDKNodeFeatures 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_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1996         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(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_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2005         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2006 }
2007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2008         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2009         CHECK(val->result_ok);
2010         LDKChannelFeatures 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_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2017         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(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_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2026         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2027 }
2028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2029         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2030         CHECK(val->result_ok);
2031         LDKInvoiceFeatures 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_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2038         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(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_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2047         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2048 }
2049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2050         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2051         CHECK(val->result_ok);
2052         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2053         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2054         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2055         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2056         return res_ref;
2057 }
2058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2059         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2060         CHECK(!val->result_ok);
2061         LDKDecodeError err_var = (*val->contents.err);
2062         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2063         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2064         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2065         return err_ref;
2066 }
2067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2068         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2069 }
2070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2071         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2072         CHECK(val->result_ok);
2073         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2074         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2075         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2076         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2077         return res_ref;
2078 }
2079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2080         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2081         CHECK(!val->result_ok);
2082         LDKDecodeError err_var = (*val->contents.err);
2083         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2084         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2085         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2086         return err_ref;
2087 }
2088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2089         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2090 }
2091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2092         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2093         CHECK(val->result_ok);
2094         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2095         return res_ref;
2096 }
2097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2098         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2099         CHECK(!val->result_ok);
2100         LDKDecodeError err_var = (*val->contents.err);
2101         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2102         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2103         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2104         return err_ref;
2105 }
2106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2107         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2108         LDKSignature a_ref;
2109         CHECK((*env)->GetArrayLength(env, a) == 64);
2110         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2111         ret->a = a_ref;
2112         LDKCVec_SignatureZ b_constr;
2113         b_constr.datalen = (*env)->GetArrayLength(env, b);
2114         if (b_constr.datalen > 0)
2115                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2116         else
2117                 b_constr.data = NULL;
2118         for (size_t i = 0; i < b_constr.datalen; i++) {
2119                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2120                 LDKSignature b_conv_8_ref;
2121                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2122                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2123                 b_constr.data[i] = b_conv_8_ref;
2124         }
2125         ret->b = b_constr;
2126         return (uint64_t)ret;
2127 }
2128 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2129         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2130         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2131         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2132         return a_arr;
2133 }
2134 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2135         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2136         LDKCVec_SignatureZ b_var = tuple->b;
2137         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2138         ;
2139         for (size_t i = 0; i < b_var.datalen; i++) {
2140                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2141                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2142                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2143         }
2144         return b_arr;
2145 }
2146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2147         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2148 }
2149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2150         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2151         CHECK(val->result_ok);
2152         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2153         return res_ref;
2154 }
2155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2156         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2157         CHECK(!val->result_ok);
2158         return *val->contents.err;
2159 }
2160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2161         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2162 }
2163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2164         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2165         CHECK(val->result_ok);
2166         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2167         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2168         return res_arr;
2169 }
2170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2171         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2172         CHECK(!val->result_ok);
2173         return *val->contents.err;
2174 }
2175 typedef struct LDKBaseSign_JCalls {
2176         atomic_size_t refcnt;
2177         JavaVM *vm;
2178         jweak o;
2179         jmethodID get_per_commitment_point_meth;
2180         jmethodID release_commitment_secret_meth;
2181         jmethodID channel_keys_id_meth;
2182         jmethodID sign_counterparty_commitment_meth;
2183         jmethodID sign_holder_commitment_and_htlcs_meth;
2184         jmethodID sign_justice_revoked_output_meth;
2185         jmethodID sign_justice_revoked_htlc_meth;
2186         jmethodID sign_counterparty_htlc_transaction_meth;
2187         jmethodID sign_closing_transaction_meth;
2188         jmethodID sign_channel_announcement_meth;
2189         jmethodID ready_channel_meth;
2190 } LDKBaseSign_JCalls;
2191 static void LDKBaseSign_JCalls_free(void* this_arg) {
2192         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2193         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2194                 JNIEnv *env;
2195                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2196                 if (get_jenv_res == JNI_EDETACHED) {
2197                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2198                 } else {
2199                         DO_ASSERT(get_jenv_res == JNI_OK);
2200                 }
2201                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2202                 if (get_jenv_res == JNI_EDETACHED) {
2203                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2204                 }
2205                 FREE(j_calls);
2206         }
2207 }
2208 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2209         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2210         JNIEnv *env;
2211         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2212         if (get_jenv_res == JNI_EDETACHED) {
2213                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2214         } else {
2215                 DO_ASSERT(get_jenv_res == JNI_OK);
2216         }
2217         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2218         CHECK(obj != NULL);
2219         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2220         if ((*env)->ExceptionCheck(env)) {
2221                 (*env)->ExceptionDescribe(env);
2222                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2223         }
2224         LDKPublicKey ret_ref;
2225         CHECK((*env)->GetArrayLength(env, ret) == 33);
2226         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2227         if (get_jenv_res == JNI_EDETACHED) {
2228                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2229         }
2230         return ret_ref;
2231 }
2232 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2233         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2234         JNIEnv *env;
2235         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2236         if (get_jenv_res == JNI_EDETACHED) {
2237                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2238         } else {
2239                 DO_ASSERT(get_jenv_res == JNI_OK);
2240         }
2241         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2242         CHECK(obj != NULL);
2243         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2244         if ((*env)->ExceptionCheck(env)) {
2245                 (*env)->ExceptionDescribe(env);
2246                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2247         }
2248         LDKThirtyTwoBytes ret_ref;
2249         CHECK((*env)->GetArrayLength(env, ret) == 32);
2250         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2251         if (get_jenv_res == JNI_EDETACHED) {
2252                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2253         }
2254         return ret_ref;
2255 }
2256 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2257         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2258         JNIEnv *env;
2259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2260         if (get_jenv_res == JNI_EDETACHED) {
2261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2262         } else {
2263                 DO_ASSERT(get_jenv_res == JNI_OK);
2264         }
2265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2266         CHECK(obj != NULL);
2267         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2268         if ((*env)->ExceptionCheck(env)) {
2269                 (*env)->ExceptionDescribe(env);
2270                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2271         }
2272         LDKThirtyTwoBytes ret_ref;
2273         CHECK((*env)->GetArrayLength(env, ret) == 32);
2274         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2275         if (get_jenv_res == JNI_EDETACHED) {
2276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2277         }
2278         return ret_ref;
2279 }
2280 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2281         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2282         JNIEnv *env;
2283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2284         if (get_jenv_res == JNI_EDETACHED) {
2285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2286         } else {
2287                 DO_ASSERT(get_jenv_res == JNI_OK);
2288         }
2289         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2290         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2291         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2292         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2293         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2294         if (commitment_tx_var.is_owned) {
2295                 commitment_tx_ref |= 1;
2296         }
2297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2298         CHECK(obj != NULL);
2299         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2300         if ((*env)->ExceptionCheck(env)) {
2301                 (*env)->ExceptionDescribe(env);
2302                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2303         }
2304         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2305         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2306         if (get_jenv_res == JNI_EDETACHED) {
2307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2308         }
2309         return ret_conv;
2310 }
2311 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2312         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2313         JNIEnv *env;
2314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2315         if (get_jenv_res == JNI_EDETACHED) {
2316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2317         } else {
2318                 DO_ASSERT(get_jenv_res == JNI_OK);
2319         }
2320         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2321         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2322         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2323         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2324         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2325         if (commitment_tx_var.is_owned) {
2326                 commitment_tx_ref |= 1;
2327         }
2328         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2329         CHECK(obj != NULL);
2330         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2331         if ((*env)->ExceptionCheck(env)) {
2332                 (*env)->ExceptionDescribe(env);
2333                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2334         }
2335         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2336         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2337         if (get_jenv_res == JNI_EDETACHED) {
2338                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2339         }
2340         return ret_conv;
2341 }
2342 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]) {
2343         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2344         JNIEnv *env;
2345         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2346         if (get_jenv_res == JNI_EDETACHED) {
2347                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2348         } else {
2349                 DO_ASSERT(get_jenv_res == JNI_OK);
2350         }
2351         LDKTransaction justice_tx_var = justice_tx;
2352         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2353         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2354         Transaction_free(justice_tx_var);
2355         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2356         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2358         CHECK(obj != NULL);
2359         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2360         if ((*env)->ExceptionCheck(env)) {
2361                 (*env)->ExceptionDescribe(env);
2362                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2363         }
2364         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2365         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2366         if (get_jenv_res == JNI_EDETACHED) {
2367                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2368         }
2369         return ret_conv;
2370 }
2371 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) {
2372         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2373         JNIEnv *env;
2374         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2375         if (get_jenv_res == JNI_EDETACHED) {
2376                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2377         } else {
2378                 DO_ASSERT(get_jenv_res == JNI_OK);
2379         }
2380         LDKTransaction justice_tx_var = justice_tx;
2381         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2382         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2383         Transaction_free(justice_tx_var);
2384         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2385         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2386         LDKHTLCOutputInCommitment htlc_var = *htlc;
2387         htlc_var = HTLCOutputInCommitment_clone(htlc);
2388         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2389         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2390         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2391         if (htlc_var.is_owned) {
2392                 htlc_ref |= 1;
2393         }
2394         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2395         CHECK(obj != NULL);
2396         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2397         if ((*env)->ExceptionCheck(env)) {
2398                 (*env)->ExceptionDescribe(env);
2399                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2400         }
2401         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2402         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2403         if (get_jenv_res == JNI_EDETACHED) {
2404                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2405         }
2406         return ret_conv;
2407 }
2408 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) {
2409         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2410         JNIEnv *env;
2411         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2412         if (get_jenv_res == JNI_EDETACHED) {
2413                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2414         } else {
2415                 DO_ASSERT(get_jenv_res == JNI_OK);
2416         }
2417         LDKTransaction htlc_tx_var = htlc_tx;
2418         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2419         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2420         Transaction_free(htlc_tx_var);
2421         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2422         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2423         LDKHTLCOutputInCommitment htlc_var = *htlc;
2424         htlc_var = HTLCOutputInCommitment_clone(htlc);
2425         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2426         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2427         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2428         if (htlc_var.is_owned) {
2429                 htlc_ref |= 1;
2430         }
2431         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2432         CHECK(obj != NULL);
2433         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2434         if ((*env)->ExceptionCheck(env)) {
2435                 (*env)->ExceptionDescribe(env);
2436                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2437         }
2438         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2439         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2440         if (get_jenv_res == JNI_EDETACHED) {
2441                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2442         }
2443         return ret_conv;
2444 }
2445 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2446         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2447         JNIEnv *env;
2448         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2449         if (get_jenv_res == JNI_EDETACHED) {
2450                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2451         } else {
2452                 DO_ASSERT(get_jenv_res == JNI_OK);
2453         }
2454         LDKTransaction closing_tx_var = closing_tx;
2455         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2456         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2457         Transaction_free(closing_tx_var);
2458         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2459         CHECK(obj != NULL);
2460         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2461         if ((*env)->ExceptionCheck(env)) {
2462                 (*env)->ExceptionDescribe(env);
2463                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2464         }
2465         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2466         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2467         if (get_jenv_res == JNI_EDETACHED) {
2468                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2469         }
2470         return ret_conv;
2471 }
2472 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2473         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2474         JNIEnv *env;
2475         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2476         if (get_jenv_res == JNI_EDETACHED) {
2477                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2478         } else {
2479                 DO_ASSERT(get_jenv_res == JNI_OK);
2480         }
2481         LDKUnsignedChannelAnnouncement msg_var = *msg;
2482         msg_var = UnsignedChannelAnnouncement_clone(msg);
2483         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2484         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2485         uint64_t msg_ref = (uint64_t)msg_var.inner;
2486         if (msg_var.is_owned) {
2487                 msg_ref |= 1;
2488         }
2489         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2490         CHECK(obj != NULL);
2491         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2492         if ((*env)->ExceptionCheck(env)) {
2493                 (*env)->ExceptionDescribe(env);
2494                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2495         }
2496         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2497         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2498         if (get_jenv_res == JNI_EDETACHED) {
2499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2500         }
2501         return ret_conv;
2502 }
2503 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2504         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2505         JNIEnv *env;
2506         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2507         if (get_jenv_res == JNI_EDETACHED) {
2508                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2509         } else {
2510                 DO_ASSERT(get_jenv_res == JNI_OK);
2511         }
2512         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2513         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2514         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2515         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2516         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2517         if (channel_parameters_var.is_owned) {
2518                 channel_parameters_ref |= 1;
2519         }
2520         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2521         CHECK(obj != NULL);
2522         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2523         if ((*env)->ExceptionCheck(env)) {
2524                 (*env)->ExceptionDescribe(env);
2525                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2526         }
2527         if (get_jenv_res == JNI_EDETACHED) {
2528                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2529         }
2530 }
2531 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2532         jclass c = (*env)->GetObjectClass(env, o);
2533         CHECK(c != NULL);
2534         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2535         atomic_init(&calls->refcnt, 1);
2536         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2537         calls->o = (*env)->NewWeakGlobalRef(env, o);
2538         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2539         CHECK(calls->get_per_commitment_point_meth != NULL);
2540         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2541         CHECK(calls->release_commitment_secret_meth != NULL);
2542         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2543         CHECK(calls->channel_keys_id_meth != NULL);
2544         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2545         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2546         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2547         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2548         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2549         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2550         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2551         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2552         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2553         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2554         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2555         CHECK(calls->sign_closing_transaction_meth != NULL);
2556         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2557         CHECK(calls->sign_channel_announcement_meth != NULL);
2558         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2559         CHECK(calls->ready_channel_meth != NULL);
2560
2561         LDKChannelPublicKeys pubkeys_conv;
2562         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2563         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2564         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2565
2566         LDKBaseSign ret = {
2567                 .this_arg = (void*) calls,
2568                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2569                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2570                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2571                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2572                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2573                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2574                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2575                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2576                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2577                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2578                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2579                 .free = LDKBaseSign_JCalls_free,
2580                 .pubkeys = pubkeys_conv,
2581                 .set_pubkeys = NULL,
2582         };
2583         return ret;
2584 }
2585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2586         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2587         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2588         return (uint64_t)res_ptr;
2589 }
2590 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) {
2591         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2592         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2594         return ret_arr;
2595 }
2596
2597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2598         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2599         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2600         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2601         return ret_arr;
2602 }
2603
2604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2605         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2606         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2607         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2608         return ret_arr;
2609 }
2610
2611 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) {
2612         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2613         LDKCommitmentTransaction commitment_tx_conv;
2614         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2615         commitment_tx_conv.is_owned = false;
2616         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2617         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2618         return (uint64_t)ret_conv;
2619 }
2620
2621 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) {
2622         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2623         LDKHolderCommitmentTransaction commitment_tx_conv;
2624         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2625         commitment_tx_conv.is_owned = false;
2626         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2627         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2628         return (uint64_t)ret_conv;
2629 }
2630
2631 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) {
2632         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2633         LDKTransaction justice_tx_ref;
2634         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2635         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2636         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2637         justice_tx_ref.data_is_owned = true;
2638         unsigned char per_commitment_key_arr[32];
2639         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2640         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2641         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2642         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2643         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2644         return (uint64_t)ret_conv;
2645 }
2646
2647 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) {
2648         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2649         LDKTransaction justice_tx_ref;
2650         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2651         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2652         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2653         justice_tx_ref.data_is_owned = true;
2654         unsigned char per_commitment_key_arr[32];
2655         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2656         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2657         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2658         LDKHTLCOutputInCommitment htlc_conv;
2659         htlc_conv.inner = (void*)(htlc & (~1));
2660         htlc_conv.is_owned = false;
2661         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2662         *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);
2663         return (uint64_t)ret_conv;
2664 }
2665
2666 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) {
2667         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2668         LDKTransaction htlc_tx_ref;
2669         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2670         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2671         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2672         htlc_tx_ref.data_is_owned = true;
2673         LDKPublicKey per_commitment_point_ref;
2674         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2675         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2676         LDKHTLCOutputInCommitment htlc_conv;
2677         htlc_conv.inner = (void*)(htlc & (~1));
2678         htlc_conv.is_owned = false;
2679         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2680         *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);
2681         return (uint64_t)ret_conv;
2682 }
2683
2684 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) {
2685         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2686         LDKTransaction closing_tx_ref;
2687         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2688         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2689         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2690         closing_tx_ref.data_is_owned = true;
2691         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2692         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2693         return (uint64_t)ret_conv;
2694 }
2695
2696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2697         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2698         LDKUnsignedChannelAnnouncement msg_conv;
2699         msg_conv.inner = (void*)(msg & (~1));
2700         msg_conv.is_owned = false;
2701         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2702         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2703         return (uint64_t)ret_conv;
2704 }
2705
2706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2707         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2708         LDKChannelTransactionParameters channel_parameters_conv;
2709         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2710         channel_parameters_conv.is_owned = false;
2711         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2712 }
2713
2714 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2715         if (this_arg->set_pubkeys != NULL)
2716                 this_arg->set_pubkeys(this_arg);
2717         return this_arg->pubkeys;
2718 }
2719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2720         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2721         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2722         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2723         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2724         uint64_t ret_ref = (uint64_t)ret_var.inner;
2725         if (ret_var.is_owned) {
2726                 ret_ref |= 1;
2727         }
2728         return ret_ref;
2729 }
2730
2731 typedef struct LDKSign_JCalls {
2732         atomic_size_t refcnt;
2733         JavaVM *vm;
2734         jweak o;
2735         LDKBaseSign_JCalls* BaseSign;
2736         jmethodID write_meth;
2737 } LDKSign_JCalls;
2738 static void LDKSign_JCalls_free(void* this_arg) {
2739         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2740         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2741                 JNIEnv *env;
2742                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2743                 if (get_jenv_res == JNI_EDETACHED) {
2744                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2745                 } else {
2746                         DO_ASSERT(get_jenv_res == JNI_OK);
2747                 }
2748                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2749                 if (get_jenv_res == JNI_EDETACHED) {
2750                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2751                 }
2752                 FREE(j_calls);
2753         }
2754 }
2755 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2756         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2757         JNIEnv *env;
2758         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2759         if (get_jenv_res == JNI_EDETACHED) {
2760                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2761         } else {
2762                 DO_ASSERT(get_jenv_res == JNI_OK);
2763         }
2764         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2765         CHECK(obj != NULL);
2766         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2767         if ((*env)->ExceptionCheck(env)) {
2768                 (*env)->ExceptionDescribe(env);
2769                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2770         }
2771         LDKCVec_u8Z ret_ref;
2772         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2773         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2774         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2775         if (get_jenv_res == JNI_EDETACHED) {
2776                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2777         }
2778         return ret_ref;
2779 }
2780 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2781         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2782         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2783         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2784 }
2785 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2786         jclass c = (*env)->GetObjectClass(env, o);
2787         CHECK(c != NULL);
2788         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2789         atomic_init(&calls->refcnt, 1);
2790         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2791         calls->o = (*env)->NewWeakGlobalRef(env, o);
2792         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2793         CHECK(calls->write_meth != NULL);
2794
2795         LDKChannelPublicKeys pubkeys_conv;
2796         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2797         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2798         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2799
2800         LDKSign ret = {
2801                 .this_arg = (void*) calls,
2802                 .write = write_LDKSign_jcall,
2803                 .cloned = LDKSign_JCalls_cloned,
2804                 .free = LDKSign_JCalls_free,
2805                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2806         };
2807         calls->BaseSign = ret.BaseSign.this_arg;
2808         return ret;
2809 }
2810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2811         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2812         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2813         return (uint64_t)res_ptr;
2814 }
2815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2816         LDKSign *inp = (LDKSign *)(arg & ~1);
2817         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2818         DO_ASSERT((res_ptr & 1) == 0);
2819         return (int64_t)(res_ptr | 1);
2820 }
2821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2822         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2823         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2824         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2825         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2826         CVec_u8Z_free(ret_var);
2827         return ret_arr;
2828 }
2829
2830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2831         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2832 }
2833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2834         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2835         CHECK(val->result_ok);
2836         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2837         *ret = Sign_clone(&(*val->contents.result));
2838         return (uint64_t)ret;
2839 }
2840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2841         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2842         CHECK(!val->result_ok);
2843         LDKDecodeError err_var = (*val->contents.err);
2844         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2845         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2846         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2847         return err_ref;
2848 }
2849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2850         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2851 }
2852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2853         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2854         CHECK(val->result_ok);
2855         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2856         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2857         return es_arr;
2858 }
2859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2860         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2861         CHECK(!val->result_ok);
2862         return *val->contents.err;
2863 }
2864 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2865         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2866         for (size_t i = 0; i < ret.datalen; i++) {
2867                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2868         }
2869         return ret;
2870 }
2871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2872         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2873 }
2874 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2875         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2876         CHECK(val->result_ok);
2877         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2878         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2879         ;
2880         for (size_t i = 0; i < res_var.datalen; i++) {
2881                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2882                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2883                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2884                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2885         }
2886         return res_arr;
2887 }
2888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2889         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2890         CHECK(!val->result_ok);
2891         return *val->contents.err;
2892 }
2893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2894         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2895 }
2896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2897         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2898         CHECK(val->result_ok);
2899         LDKInMemorySigner res_var = (*val->contents.result);
2900         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2901         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2902         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2903         return res_ref;
2904 }
2905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2906         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2907         CHECK(!val->result_ok);
2908         LDKDecodeError err_var = (*val->contents.err);
2909         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2910         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2911         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2912         return err_ref;
2913 }
2914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2915         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2916         ret->datalen = (*env)->GetArrayLength(env, elems);
2917         if (ret->datalen == 0) {
2918                 ret->data = NULL;
2919         } else {
2920                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2921                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2922                 for (size_t i = 0; i < ret->datalen; i++) {
2923                         int64_t arr_elem = java_elems[i];
2924                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2925                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2926                         ret->data[i] = arr_elem_conv;
2927                 }
2928                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2929         }
2930         return (uint64_t)ret;
2931 }
2932 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2933         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2934         for (size_t i = 0; i < ret.datalen; i++) {
2935                 ret.data[i] = TxOut_clone(&orig->data[i]);
2936         }
2937         return ret;
2938 }
2939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2940         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2941 }
2942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2943         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2944         CHECK(val->result_ok);
2945         LDKTransaction res_var = (*val->contents.result);
2946         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2947         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2948         return res_arr;
2949 }
2950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2951         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2952         CHECK(!val->result_ok);
2953         return *val->contents.err;
2954 }
2955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2956         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2957         LDKThirtyTwoBytes a_ref;
2958         CHECK((*env)->GetArrayLength(env, a) == 32);
2959         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2960         ret->a = a_ref;
2961         LDKChannelMonitor b_conv;
2962         b_conv.inner = (void*)(b & (~1));
2963         b_conv.is_owned = (b & 1) || (b == 0);
2964         b_conv = ChannelMonitor_clone(&b_conv);
2965         ret->b = b_conv;
2966         return (uint64_t)ret;
2967 }
2968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2969         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2970         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2971         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2972         return a_arr;
2973 }
2974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2975         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2976         LDKChannelMonitor b_var = tuple->b;
2977         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2978         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2979         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2980         return b_ref;
2981 }
2982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2983         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2984         ret->datalen = (*env)->GetArrayLength(env, elems);
2985         if (ret->datalen == 0) {
2986                 ret->data = NULL;
2987         } else {
2988                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2989                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2990                 for (size_t i = 0; i < ret->datalen; i++) {
2991                         int64_t arr_elem = java_elems[i];
2992                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2993                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2994                         ret->data[i] = arr_elem_conv;
2995                 }
2996                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2997         }
2998         return (uint64_t)ret;
2999 }
3000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3001         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3002 }
3003 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3004         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3005         CHECK(val->result_ok);
3006         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3007         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
3008         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3009         for (size_t i = 0; i < res_var.datalen; i++) {
3010                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
3011                 res_arr_ptr[i] = res_conv_34_ref;
3012         }
3013         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3014         return res_arr;
3015 }
3016 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3017         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3018         CHECK(!val->result_ok);
3019         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3020         return err_conv;
3021 }
3022 static jclass LDKCOption_u16Z_Some_class = NULL;
3023 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3024 static jclass LDKCOption_u16Z_None_class = NULL;
3025 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3027         LDKCOption_u16Z_Some_class =
3028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3029         CHECK(LDKCOption_u16Z_Some_class != NULL);
3030         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3031         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3032         LDKCOption_u16Z_None_class =
3033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3034         CHECK(LDKCOption_u16Z_None_class != NULL);
3035         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3036         CHECK(LDKCOption_u16Z_None_meth != NULL);
3037 }
3038 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3039         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3040         switch(obj->tag) {
3041                 case LDKCOption_u16Z_Some: {
3042                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3043                 }
3044                 case LDKCOption_u16Z_None: {
3045                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3046                 }
3047                 default: abort();
3048         }
3049 }
3050 static jclass LDKAPIError_APIMisuseError_class = NULL;
3051 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3052 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3053 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3054 static jclass LDKAPIError_RouteError_class = NULL;
3055 static jmethodID LDKAPIError_RouteError_meth = NULL;
3056 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3057 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3058 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3059 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3060 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3061 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3063         LDKAPIError_APIMisuseError_class =
3064                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3065         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3066         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3067         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3068         LDKAPIError_FeeRateTooHigh_class =
3069                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3070         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3071         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3072         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3073         LDKAPIError_RouteError_class =
3074                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3075         CHECK(LDKAPIError_RouteError_class != NULL);
3076         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3077         CHECK(LDKAPIError_RouteError_meth != NULL);
3078         LDKAPIError_ChannelUnavailable_class =
3079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3080         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3081         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3082         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3083         LDKAPIError_MonitorUpdateFailed_class =
3084                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3085         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3086         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3087         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3088         LDKAPIError_IncompatibleShutdownScript_class =
3089                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3090         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3091         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3092         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3093 }
3094 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3095         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3096         switch(obj->tag) {
3097                 case LDKAPIError_APIMisuseError: {
3098                         LDKStr err_str = obj->api_misuse_error.err;
3099                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3100                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3101                 }
3102                 case LDKAPIError_FeeRateTooHigh: {
3103                         LDKStr err_str = obj->fee_rate_too_high.err;
3104                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3105                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3106                 }
3107                 case LDKAPIError_RouteError: {
3108                         LDKStr err_str = obj->route_error.err;
3109                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3110                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3111                 }
3112                 case LDKAPIError_ChannelUnavailable: {
3113                         LDKStr err_str = obj->channel_unavailable.err;
3114                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3115                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3116                 }
3117                 case LDKAPIError_MonitorUpdateFailed: {
3118                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3119                 }
3120                 case LDKAPIError_IncompatibleShutdownScript: {
3121                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3122                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3123                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3124                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
3125                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3126                 }
3127                 default: abort();
3128         }
3129 }
3130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3131         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3132 }
3133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3134         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3135         CHECK(val->result_ok);
3136         return *val->contents.result;
3137 }
3138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3139         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3140         CHECK(!val->result_ok);
3141         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3142         return err_ref;
3143 }
3144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3145         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3146         ret->datalen = (*env)->GetArrayLength(env, elems);
3147         if (ret->datalen == 0) {
3148                 ret->data = NULL;
3149         } else {
3150                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3151                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3152                 for (size_t i = 0; i < ret->datalen; i++) {
3153                         int64_t arr_elem = java_elems[i];
3154                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3155                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3156                         ret->data[i] = arr_elem_conv;
3157                 }
3158                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3159         }
3160         return (uint64_t)ret;
3161 }
3162 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3163         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3164         for (size_t i = 0; i < ret.datalen; i++) {
3165                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3166         }
3167         return ret;
3168 }
3169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3170         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3171         ret->datalen = (*env)->GetArrayLength(env, elems);
3172         if (ret->datalen == 0) {
3173                 ret->data = NULL;
3174         } else {
3175                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3176                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3177                 for (size_t i = 0; i < ret->datalen; i++) {
3178                         int64_t arr_elem = java_elems[i];
3179                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3180                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3181                         ret->data[i] = arr_elem_conv;
3182                 }
3183                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3184         }
3185         return (uint64_t)ret;
3186 }
3187 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3188         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3189         for (size_t i = 0; i < ret.datalen; i++) {
3190                 ret.data[i] = APIError_clone(&orig->data[i]);
3191         }
3192         return ret;
3193 }
3194 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3195 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3196 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3197 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3198 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3199 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3200 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3201 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3203         LDKPaymentSendFailure_ParameterError_class =
3204                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3205         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3206         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3207         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3208         LDKPaymentSendFailure_PathParameterError_class =
3209                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3210         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3211         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3212         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3213         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3214                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3215         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3216         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3217         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3218         LDKPaymentSendFailure_PartialFailure_class =
3219                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3220         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3221         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3222         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3223 }
3224 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3225         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3226         switch(obj->tag) {
3227                 case LDKPaymentSendFailure_ParameterError: {
3228                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3229                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3230                 }
3231                 case LDKPaymentSendFailure_PathParameterError: {
3232                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3233                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3234                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3235                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3236                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3237                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3238                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3239                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3240                         }
3241                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3242                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3243                 }
3244                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3245                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3246                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3247                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3248                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3249                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3250                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3251                         }
3252                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3253                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3254                 }
3255                 case LDKPaymentSendFailure_PartialFailure: {
3256                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3257                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3258                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3259                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3260                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3261                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3262                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3263                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3264                         }
3265                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3266                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3267                 }
3268                 default: abort();
3269         }
3270 }
3271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3272         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3273 }
3274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3275         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3276         CHECK(val->result_ok);
3277         return *val->contents.result;
3278 }
3279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3280         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3281         CHECK(!val->result_ok);
3282         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3283         return err_ref;
3284 }
3285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3286         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
3287 }
3288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3289         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3290         CHECK(val->result_ok);
3291         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3292         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3293         return res_arr;
3294 }
3295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3296         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3297         CHECK(!val->result_ok);
3298         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3299         return err_ref;
3300 }
3301 static jclass LDKNetAddress_IPv4_class = NULL;
3302 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3303 static jclass LDKNetAddress_IPv6_class = NULL;
3304 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3305 static jclass LDKNetAddress_OnionV2_class = NULL;
3306 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3307 static jclass LDKNetAddress_OnionV3_class = NULL;
3308 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3310         LDKNetAddress_IPv4_class =
3311                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3312         CHECK(LDKNetAddress_IPv4_class != NULL);
3313         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3314         CHECK(LDKNetAddress_IPv4_meth != NULL);
3315         LDKNetAddress_IPv6_class =
3316                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3317         CHECK(LDKNetAddress_IPv6_class != NULL);
3318         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3319         CHECK(LDKNetAddress_IPv6_meth != NULL);
3320         LDKNetAddress_OnionV2_class =
3321                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3322         CHECK(LDKNetAddress_OnionV2_class != NULL);
3323         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3324         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3325         LDKNetAddress_OnionV3_class =
3326                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3327         CHECK(LDKNetAddress_OnionV3_class != NULL);
3328         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3329         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3330 }
3331 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3332         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3333         switch(obj->tag) {
3334                 case LDKNetAddress_IPv4: {
3335                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3336                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3337                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3338                 }
3339                 case LDKNetAddress_IPv6: {
3340                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3341                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3342                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3343                 }
3344                 case LDKNetAddress_OnionV2: {
3345                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3346                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3347                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3348                 }
3349                 case LDKNetAddress_OnionV3: {
3350                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3351                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3352                         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);
3353                 }
3354                 default: abort();
3355         }
3356 }
3357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3358         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3359         ret->datalen = (*env)->GetArrayLength(env, elems);
3360         if (ret->datalen == 0) {
3361                 ret->data = NULL;
3362         } else {
3363                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3364                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3365                 for (size_t i = 0; i < ret->datalen; i++) {
3366                         int64_t arr_elem = java_elems[i];
3367                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3368                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3369                         ret->data[i] = arr_elem_conv;
3370                 }
3371                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3372         }
3373         return (uint64_t)ret;
3374 }
3375 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3376         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3377         for (size_t i = 0; i < ret.datalen; i++) {
3378                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3379         }
3380         return ret;
3381 }
3382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3383         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3384         LDKThirtyTwoBytes a_ref;
3385         CHECK((*env)->GetArrayLength(env, a) == 32);
3386         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3387         ret->a = a_ref;
3388         LDKThirtyTwoBytes b_ref;
3389         CHECK((*env)->GetArrayLength(env, b) == 32);
3390         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3391         ret->b = b_ref;
3392         return (uint64_t)ret;
3393 }
3394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3395         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3396         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3397         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3398         return a_arr;
3399 }
3400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3401         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3402         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3403         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3404         return b_arr;
3405 }
3406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3407         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3408 }
3409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3410         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3411         CHECK(val->result_ok);
3412         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3413         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3414         return res_arr;
3415 }
3416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3417         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3418         CHECK(!val->result_ok);
3419         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3420         return err_ref;
3421 }
3422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3423         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3424         ret->datalen = (*env)->GetArrayLength(env, elems);
3425         if (ret->datalen == 0) {
3426                 ret->data = NULL;
3427         } else {
3428                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3429                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3430                 for (size_t i = 0; i < ret->datalen; i++) {
3431                         int64_t arr_elem = java_elems[i];
3432                         LDKChannelMonitor arr_elem_conv;
3433                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3434                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3435                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3436                         ret->data[i] = arr_elem_conv;
3437                 }
3438                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3439         }
3440         return (uint64_t)ret;
3441 }
3442 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3443         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3444         for (size_t i = 0; i < ret.datalen; i++) {
3445                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3446         }
3447         return ret;
3448 }
3449 typedef struct LDKWatch_JCalls {
3450         atomic_size_t refcnt;
3451         JavaVM *vm;
3452         jweak o;
3453         jmethodID watch_channel_meth;
3454         jmethodID update_channel_meth;
3455         jmethodID release_pending_monitor_events_meth;
3456 } LDKWatch_JCalls;
3457 static void LDKWatch_JCalls_free(void* this_arg) {
3458         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3459         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3460                 JNIEnv *env;
3461                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3462                 if (get_jenv_res == JNI_EDETACHED) {
3463                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3464                 } else {
3465                         DO_ASSERT(get_jenv_res == JNI_OK);
3466                 }
3467                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3468                 if (get_jenv_res == JNI_EDETACHED) {
3469                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3470                 }
3471                 FREE(j_calls);
3472         }
3473 }
3474 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3475         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3476         JNIEnv *env;
3477         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3478         if (get_jenv_res == JNI_EDETACHED) {
3479                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3480         } else {
3481                 DO_ASSERT(get_jenv_res == JNI_OK);
3482         }
3483         LDKOutPoint funding_txo_var = funding_txo;
3484         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3485         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3486         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3487         if (funding_txo_var.is_owned) {
3488                 funding_txo_ref |= 1;
3489         }
3490         LDKChannelMonitor monitor_var = monitor;
3491         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3492         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3493         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3494         if (monitor_var.is_owned) {
3495                 monitor_ref |= 1;
3496         }
3497         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3498         CHECK(obj != NULL);
3499         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3500         if ((*env)->ExceptionCheck(env)) {
3501                 (*env)->ExceptionDescribe(env);
3502                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3503         }
3504         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3505         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3506         if (get_jenv_res == JNI_EDETACHED) {
3507                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3508         }
3509         return ret_conv;
3510 }
3511 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3512         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3513         JNIEnv *env;
3514         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3515         if (get_jenv_res == JNI_EDETACHED) {
3516                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3517         } else {
3518                 DO_ASSERT(get_jenv_res == JNI_OK);
3519         }
3520         LDKOutPoint funding_txo_var = funding_txo;
3521         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3522         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3523         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3524         if (funding_txo_var.is_owned) {
3525                 funding_txo_ref |= 1;
3526         }
3527         LDKChannelMonitorUpdate update_var = update;
3528         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3529         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3530         uint64_t update_ref = (uint64_t)update_var.inner;
3531         if (update_var.is_owned) {
3532                 update_ref |= 1;
3533         }
3534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3535         CHECK(obj != NULL);
3536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3537         if ((*env)->ExceptionCheck(env)) {
3538                 (*env)->ExceptionDescribe(env);
3539                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3540         }
3541         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3542         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3543         if (get_jenv_res == JNI_EDETACHED) {
3544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3545         }
3546         return ret_conv;
3547 }
3548 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3549         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3550         JNIEnv *env;
3551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3552         if (get_jenv_res == JNI_EDETACHED) {
3553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3554         } else {
3555                 DO_ASSERT(get_jenv_res == JNI_OK);
3556         }
3557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3558         CHECK(obj != NULL);
3559         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3560         if ((*env)->ExceptionCheck(env)) {
3561                 (*env)->ExceptionDescribe(env);
3562                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3563         }
3564         LDKCVec_MonitorEventZ ret_constr;
3565         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3566         if (ret_constr.datalen > 0)
3567                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3568         else
3569                 ret_constr.data = NULL;
3570         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3571         for (size_t o = 0; o < ret_constr.datalen; o++) {
3572                 int64_t ret_conv_14 = ret_vals[o];
3573                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3574                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3575                 ret_constr.data[o] = ret_conv_14_conv;
3576         }
3577         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3578         if (get_jenv_res == JNI_EDETACHED) {
3579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3580         }
3581         return ret_constr;
3582 }
3583 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3584         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3586 }
3587 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3588         jclass c = (*env)->GetObjectClass(env, o);
3589         CHECK(c != NULL);
3590         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3591         atomic_init(&calls->refcnt, 1);
3592         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3593         calls->o = (*env)->NewWeakGlobalRef(env, o);
3594         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3595         CHECK(calls->watch_channel_meth != NULL);
3596         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3597         CHECK(calls->update_channel_meth != NULL);
3598         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3599         CHECK(calls->release_pending_monitor_events_meth != NULL);
3600
3601         LDKWatch ret = {
3602                 .this_arg = (void*) calls,
3603                 .watch_channel = watch_channel_LDKWatch_jcall,
3604                 .update_channel = update_channel_LDKWatch_jcall,
3605                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3606                 .free = LDKWatch_JCalls_free,
3607         };
3608         return ret;
3609 }
3610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3611         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3612         *res_ptr = LDKWatch_init(env, clz, o);
3613         return (uint64_t)res_ptr;
3614 }
3615 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) {
3616         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3617         LDKOutPoint funding_txo_conv;
3618         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3619         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3620         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3621         LDKChannelMonitor monitor_conv;
3622         monitor_conv.inner = (void*)(monitor & (~1));
3623         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3624         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3625         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3626         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3627         return (uint64_t)ret_conv;
3628 }
3629
3630 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) {
3631         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3632         LDKOutPoint funding_txo_conv;
3633         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3634         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3635         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3636         LDKChannelMonitorUpdate update_conv;
3637         update_conv.inner = (void*)(update & (~1));
3638         update_conv.is_owned = (update & 1) || (update == 0);
3639         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3640         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3641         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3642         return (uint64_t)ret_conv;
3643 }
3644
3645 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3646         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3647         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3648         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3649         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3650         for (size_t o = 0; o < ret_var.datalen; o++) {
3651                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3652                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3653                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3654                 ret_arr_ptr[o] = ret_conv_14_ref;
3655         }
3656         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3657         FREE(ret_var.data);
3658         return ret_arr;
3659 }
3660
3661 typedef struct LDKBroadcasterInterface_JCalls {
3662         atomic_size_t refcnt;
3663         JavaVM *vm;
3664         jweak o;
3665         jmethodID broadcast_transaction_meth;
3666 } LDKBroadcasterInterface_JCalls;
3667 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3668         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3669         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3670                 JNIEnv *env;
3671                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3672                 if (get_jenv_res == JNI_EDETACHED) {
3673                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3674                 } else {
3675                         DO_ASSERT(get_jenv_res == JNI_OK);
3676                 }
3677                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3678                 if (get_jenv_res == JNI_EDETACHED) {
3679                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3680                 }
3681                 FREE(j_calls);
3682         }
3683 }
3684 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3685         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3686         JNIEnv *env;
3687         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3688         if (get_jenv_res == JNI_EDETACHED) {
3689                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3690         } else {
3691                 DO_ASSERT(get_jenv_res == JNI_OK);
3692         }
3693         LDKTransaction tx_var = tx;
3694         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3695         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3696         Transaction_free(tx_var);
3697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3698         CHECK(obj != NULL);
3699         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3700         if ((*env)->ExceptionCheck(env)) {
3701                 (*env)->ExceptionDescribe(env);
3702                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3703         }
3704         if (get_jenv_res == JNI_EDETACHED) {
3705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3706         }
3707 }
3708 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3709         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3710         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3711 }
3712 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3713         jclass c = (*env)->GetObjectClass(env, o);
3714         CHECK(c != NULL);
3715         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3716         atomic_init(&calls->refcnt, 1);
3717         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3718         calls->o = (*env)->NewWeakGlobalRef(env, o);
3719         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3720         CHECK(calls->broadcast_transaction_meth != NULL);
3721
3722         LDKBroadcasterInterface ret = {
3723                 .this_arg = (void*) calls,
3724                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3725                 .free = LDKBroadcasterInterface_JCalls_free,
3726         };
3727         return ret;
3728 }
3729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3730         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3731         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3732         return (uint64_t)res_ptr;
3733 }
3734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3735         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3736         LDKTransaction tx_ref;
3737         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3738         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3739         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3740         tx_ref.data_is_owned = true;
3741         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3742 }
3743
3744 typedef struct LDKKeysInterface_JCalls {
3745         atomic_size_t refcnt;
3746         JavaVM *vm;
3747         jweak o;
3748         jmethodID get_node_secret_meth;
3749         jmethodID get_destination_script_meth;
3750         jmethodID get_shutdown_scriptpubkey_meth;
3751         jmethodID get_channel_signer_meth;
3752         jmethodID get_secure_random_bytes_meth;
3753         jmethodID read_chan_signer_meth;
3754         jmethodID sign_invoice_meth;
3755 } LDKKeysInterface_JCalls;
3756 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3757         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3758         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3759                 JNIEnv *env;
3760                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3761                 if (get_jenv_res == JNI_EDETACHED) {
3762                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3763                 } else {
3764                         DO_ASSERT(get_jenv_res == JNI_OK);
3765                 }
3766                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3767                 if (get_jenv_res == JNI_EDETACHED) {
3768                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3769                 }
3770                 FREE(j_calls);
3771         }
3772 }
3773 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3774         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3775         JNIEnv *env;
3776         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3777         if (get_jenv_res == JNI_EDETACHED) {
3778                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3779         } else {
3780                 DO_ASSERT(get_jenv_res == JNI_OK);
3781         }
3782         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3783         CHECK(obj != NULL);
3784         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3785         if ((*env)->ExceptionCheck(env)) {
3786                 (*env)->ExceptionDescribe(env);
3787                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3788         }
3789         LDKSecretKey ret_ref;
3790         CHECK((*env)->GetArrayLength(env, ret) == 32);
3791         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3792         if (get_jenv_res == JNI_EDETACHED) {
3793                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3794         }
3795         return ret_ref;
3796 }
3797 LDKCVec_u8Z get_destination_script_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_destination_script_meth);
3809         if ((*env)->ExceptionCheck(env)) {
3810                 (*env)->ExceptionDescribe(env);
3811                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3812         }
3813         LDKCVec_u8Z ret_ref;
3814         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3815         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3816         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3817         if (get_jenv_res == JNI_EDETACHED) {
3818                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3819         }
3820         return ret_ref;
3821 }
3822 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
3823         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3824         JNIEnv *env;
3825         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3826         if (get_jenv_res == JNI_EDETACHED) {
3827                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3828         } else {
3829                 DO_ASSERT(get_jenv_res == JNI_OK);
3830         }
3831         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3832         CHECK(obj != NULL);
3833         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
3834         if ((*env)->ExceptionCheck(env)) {
3835                 (*env)->ExceptionDescribe(env);
3836                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
3837         }
3838         LDKShutdownScript ret_conv;
3839         ret_conv.inner = (void*)(ret & (~1));
3840         ret_conv.is_owned = (ret & 1) || (ret == 0);
3841         ret_conv = ShutdownScript_clone(&ret_conv);
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 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
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         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3857         CHECK(obj != NULL);
3858         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3859         if ((*env)->ExceptionCheck(env)) {
3860                 (*env)->ExceptionDescribe(env);
3861                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3862         }
3863         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3864         ret_conv = Sign_clone(&ret_conv);
3865         if (get_jenv_res == JNI_EDETACHED) {
3866                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3867         }
3868         return ret_conv;
3869 }
3870 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3871         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3872         JNIEnv *env;
3873         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3874         if (get_jenv_res == JNI_EDETACHED) {
3875                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3876         } else {
3877                 DO_ASSERT(get_jenv_res == JNI_OK);
3878         }
3879         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3880         CHECK(obj != NULL);
3881         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3882         if ((*env)->ExceptionCheck(env)) {
3883                 (*env)->ExceptionDescribe(env);
3884                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3885         }
3886         LDKThirtyTwoBytes ret_ref;
3887         CHECK((*env)->GetArrayLength(env, ret) == 32);
3888         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3889         if (get_jenv_res == JNI_EDETACHED) {
3890                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3891         }
3892         return ret_ref;
3893 }
3894 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3895         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3896         JNIEnv *env;
3897         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3898         if (get_jenv_res == JNI_EDETACHED) {
3899                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3900         } else {
3901                 DO_ASSERT(get_jenv_res == JNI_OK);
3902         }
3903         LDKu8slice reader_var = reader;
3904         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3905         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3906         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3907         CHECK(obj != NULL);
3908         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3909         if ((*env)->ExceptionCheck(env)) {
3910                 (*env)->ExceptionDescribe(env);
3911                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3912         }
3913         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3914         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3915         if (get_jenv_res == JNI_EDETACHED) {
3916                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3917         }
3918         return ret_conv;
3919 }
3920 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3921         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3922         JNIEnv *env;
3923         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3924         if (get_jenv_res == JNI_EDETACHED) {
3925                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3926         } else {
3927                 DO_ASSERT(get_jenv_res == JNI_OK);
3928         }
3929         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3930         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3931         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3932         CVec_u8Z_free(invoice_preimage_var);
3933         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3934         CHECK(obj != NULL);
3935         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3936         if ((*env)->ExceptionCheck(env)) {
3937                 (*env)->ExceptionDescribe(env);
3938                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3939         }
3940         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3941         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3942         if (get_jenv_res == JNI_EDETACHED) {
3943                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3944         }
3945         return ret_conv;
3946 }
3947 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3948         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3949         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3950 }
3951 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3952         jclass c = (*env)->GetObjectClass(env, o);
3953         CHECK(c != NULL);
3954         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3955         atomic_init(&calls->refcnt, 1);
3956         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3957         calls->o = (*env)->NewWeakGlobalRef(env, o);
3958         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3959         CHECK(calls->get_node_secret_meth != NULL);
3960         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3961         CHECK(calls->get_destination_script_meth != NULL);
3962         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
3963         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
3964         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3965         CHECK(calls->get_channel_signer_meth != NULL);
3966         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3967         CHECK(calls->get_secure_random_bytes_meth != NULL);
3968         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3969         CHECK(calls->read_chan_signer_meth != NULL);
3970         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3971         CHECK(calls->sign_invoice_meth != NULL);
3972
3973         LDKKeysInterface ret = {
3974                 .this_arg = (void*) calls,
3975                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3976                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3977                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
3978                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3979                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3980                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3981                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3982                 .free = LDKKeysInterface_JCalls_free,
3983         };
3984         return ret;
3985 }
3986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3987         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3988         *res_ptr = LDKKeysInterface_init(env, clz, o);
3989         return (uint64_t)res_ptr;
3990 }
3991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3992         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3993         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3994         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3995         return ret_arr;
3996 }
3997
3998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3999         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4000         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4001         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4002         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4003         CVec_u8Z_free(ret_var);
4004         return ret_arr;
4005 }
4006
4007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4008         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4009         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4010         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4011         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4012         uint64_t ret_ref = (uint64_t)ret_var.inner;
4013         if (ret_var.is_owned) {
4014                 ret_ref |= 1;
4015         }
4016         return ret_ref;
4017 }
4018
4019 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) {
4020         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4021         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
4022         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4023         return (uint64_t)ret;
4024 }
4025
4026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4027         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4028         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4030         return ret_arr;
4031 }
4032
4033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4034         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4035         LDKu8slice reader_ref;
4036         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4037         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4038         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4039         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4040         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4041         return (uint64_t)ret_conv;
4042 }
4043
4044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4045         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4046         LDKCVec_u8Z invoice_preimage_ref;
4047         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4048         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4049         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4050         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4051         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4052         return (uint64_t)ret_conv;
4053 }
4054
4055 typedef struct LDKFeeEstimator_JCalls {
4056         atomic_size_t refcnt;
4057         JavaVM *vm;
4058         jweak o;
4059         jmethodID get_est_sat_per_1000_weight_meth;
4060 } LDKFeeEstimator_JCalls;
4061 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4062         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_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 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4079         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_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         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4088         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4089         CHECK(obj != NULL);
4090         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4091         if ((*env)->ExceptionCheck(env)) {
4092                 (*env)->ExceptionDescribe(env);
4093                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4094         }
4095         if (get_jenv_res == JNI_EDETACHED) {
4096                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4097         }
4098         return ret;
4099 }
4100 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4101         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4102         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4103 }
4104 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4105         jclass c = (*env)->GetObjectClass(env, o);
4106         CHECK(c != NULL);
4107         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_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->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4112         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4113
4114         LDKFeeEstimator ret = {
4115                 .this_arg = (void*) calls,
4116                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4117                 .free = LDKFeeEstimator_JCalls_free,
4118         };
4119         return ret;
4120 }
4121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4122         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4123         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4124         return (uint64_t)res_ptr;
4125 }
4126 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) {
4127         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4128         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4129         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4130         return ret_val;
4131 }
4132
4133 typedef struct LDKLogger_JCalls {
4134         atomic_size_t refcnt;
4135         JavaVM *vm;
4136         jweak o;
4137         jmethodID log_meth;
4138 } LDKLogger_JCalls;
4139 static void LDKLogger_JCalls_free(void* this_arg) {
4140         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4141         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4142                 JNIEnv *env;
4143                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4144                 if (get_jenv_res == JNI_EDETACHED) {
4145                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4146                 } else {
4147                         DO_ASSERT(get_jenv_res == JNI_OK);
4148                 }
4149                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4150                 if (get_jenv_res == JNI_EDETACHED) {
4151                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4152                 }
4153                 FREE(j_calls);
4154         }
4155 }
4156 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4157         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4158         JNIEnv *env;
4159         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4160         if (get_jenv_res == JNI_EDETACHED) {
4161                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4162         } else {
4163                 DO_ASSERT(get_jenv_res == JNI_OK);
4164         }
4165         const char* record_str = record;
4166         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4167         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4168         CHECK(obj != NULL);
4169         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4170         if ((*env)->ExceptionCheck(env)) {
4171                 (*env)->ExceptionDescribe(env);
4172                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4173         }
4174         if (get_jenv_res == JNI_EDETACHED) {
4175                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4176         }
4177 }
4178 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4179         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4180         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4181 }
4182 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4183         jclass c = (*env)->GetObjectClass(env, o);
4184         CHECK(c != NULL);
4185         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4186         atomic_init(&calls->refcnt, 1);
4187         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4188         calls->o = (*env)->NewWeakGlobalRef(env, o);
4189         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4190         CHECK(calls->log_meth != NULL);
4191
4192         LDKLogger ret = {
4193                 .this_arg = (void*) calls,
4194                 .log = log_LDKLogger_jcall,
4195                 .free = LDKLogger_JCalls_free,
4196         };
4197         return ret;
4198 }
4199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4200         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4201         *res_ptr = LDKLogger_init(env, clz, o);
4202         return (uint64_t)res_ptr;
4203 }
4204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4205         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4206         LDKThirtyTwoBytes a_ref;
4207         CHECK((*env)->GetArrayLength(env, a) == 32);
4208         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4209         ret->a = a_ref;
4210         LDKChannelManager b_conv;
4211         b_conv.inner = (void*)(b & (~1));
4212         b_conv.is_owned = (b & 1) || (b == 0);
4213         // Warning: we need a move here but no clone is available for LDKChannelManager
4214         ret->b = b_conv;
4215         return (uint64_t)ret;
4216 }
4217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4218         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4219         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4220         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4221         return a_arr;
4222 }
4223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4224         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4225         LDKChannelManager b_var = tuple->b;
4226         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4227         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4228         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4229         return b_ref;
4230 }
4231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4232         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4233 }
4234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4235         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4236         CHECK(val->result_ok);
4237         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4238         return res_ref;
4239 }
4240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4241         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4242         CHECK(!val->result_ok);
4243         LDKDecodeError err_var = (*val->contents.err);
4244         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4245         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4246         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4247         return err_ref;
4248 }
4249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4250         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4251 }
4252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4253         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4254         CHECK(val->result_ok);
4255         LDKChannelConfig res_var = (*val->contents.result);
4256         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4257         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4258         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4259         return res_ref;
4260 }
4261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4262         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4263         CHECK(!val->result_ok);
4264         LDKDecodeError err_var = (*val->contents.err);
4265         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4266         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4267         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4268         return err_ref;
4269 }
4270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4271         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4272 }
4273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4274         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4275         CHECK(val->result_ok);
4276         LDKOutPoint res_var = (*val->contents.result);
4277         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4278         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4279         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4280         return res_ref;
4281 }
4282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4283         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4284         CHECK(!val->result_ok);
4285         LDKDecodeError err_var = (*val->contents.err);
4286         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4287         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4288         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4289         return err_ref;
4290 }
4291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4292         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4293 }
4294 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4295         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4296         CHECK(val->result_ok);
4297         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4298         return res_conv;
4299 }
4300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4301         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4302         CHECK(!val->result_ok);
4303         return *val->contents.err;
4304 }
4305 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4306         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4307 }
4308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4309         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4310         CHECK(val->result_ok);
4311         LDKInvoice res_var = (*val->contents.result);
4312         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4313         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4314         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4315         return res_ref;
4316 }
4317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4318         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4319         CHECK(!val->result_ok);
4320         return *val->contents.err;
4321 }
4322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4323         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4324 }
4325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4326         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4327         CHECK(val->result_ok);
4328         LDKSignedRawInvoice res_var = (*val->contents.result);
4329         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4330         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4331         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4332         return res_ref;
4333 }
4334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4335         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4336         CHECK(!val->result_ok);
4337         return *val->contents.err;
4338 }
4339 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) {
4340         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4341         LDKRawInvoice a_conv;
4342         a_conv.inner = (void*)(a & (~1));
4343         a_conv.is_owned = (a & 1) || (a == 0);
4344         a_conv = RawInvoice_clone(&a_conv);
4345         ret->a = a_conv;
4346         LDKThirtyTwoBytes b_ref;
4347         CHECK((*env)->GetArrayLength(env, b) == 32);
4348         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4349         ret->b = b_ref;
4350         LDKInvoiceSignature c_conv;
4351         c_conv.inner = (void*)(c & (~1));
4352         c_conv.is_owned = (c & 1) || (c == 0);
4353         c_conv = InvoiceSignature_clone(&c_conv);
4354         ret->c = c_conv;
4355         return (uint64_t)ret;
4356 }
4357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4358         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4359         LDKRawInvoice a_var = tuple->a;
4360         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4361         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4362         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4363         return a_ref;
4364 }
4365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4366         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4367         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4368         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4369         return b_arr;
4370 }
4371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4372         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4373         LDKInvoiceSignature c_var = tuple->c;
4374         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4375         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4376         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4377         return c_ref;
4378 }
4379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4380         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4381 }
4382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4383         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4384         CHECK(val->result_ok);
4385         LDKPayeePubKey res_var = (*val->contents.result);
4386         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4387         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4388         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4389         return res_ref;
4390 }
4391 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4392         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4393         CHECK(!val->result_ok);
4394         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4395         return err_conv;
4396 }
4397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4398         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4399         ret->datalen = (*env)->GetArrayLength(env, elems);
4400         if (ret->datalen == 0) {
4401                 ret->data = NULL;
4402         } else {
4403                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4404                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4405                 for (size_t i = 0; i < ret->datalen; i++) {
4406                         int64_t arr_elem = java_elems[i];
4407                         LDKPrivateRoute arr_elem_conv;
4408                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4409                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4410                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4411                         ret->data[i] = arr_elem_conv;
4412                 }
4413                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4414         }
4415         return (uint64_t)ret;
4416 }
4417 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4418         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4419         for (size_t i = 0; i < ret.datalen; i++) {
4420                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4421         }
4422         return ret;
4423 }
4424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4425         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4426 }
4427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4428         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4429         CHECK(val->result_ok);
4430         LDKPositiveTimestamp res_var = (*val->contents.result);
4431         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4432         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4433         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4434         return res_ref;
4435 }
4436 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4437         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4438         CHECK(!val->result_ok);
4439         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4440         return err_conv;
4441 }
4442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4443         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4444 }
4445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4446         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4447         CHECK(val->result_ok);
4448         return *val->contents.result;
4449 }
4450 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4451         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4452         CHECK(!val->result_ok);
4453         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4454         return err_conv;
4455 }
4456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4457         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4458 }
4459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4460         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4461         CHECK(val->result_ok);
4462         LDKInvoice res_var = (*val->contents.result);
4463         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4464         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4465         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4466         return res_ref;
4467 }
4468 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4469         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4470         CHECK(!val->result_ok);
4471         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4472         return err_conv;
4473 }
4474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4475         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4476 }
4477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4478         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4479         CHECK(val->result_ok);
4480         LDKDescription res_var = (*val->contents.result);
4481         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4482         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4483         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4484         return res_ref;
4485 }
4486 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4487         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4488         CHECK(!val->result_ok);
4489         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4490         return err_conv;
4491 }
4492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4493         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4494 }
4495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4496         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4497         CHECK(val->result_ok);
4498         LDKExpiryTime res_var = (*val->contents.result);
4499         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4500         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4501         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4502         return res_ref;
4503 }
4504 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4505         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4506         CHECK(!val->result_ok);
4507         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4508         return err_conv;
4509 }
4510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4511         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4512 }
4513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4514         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4515         CHECK(val->result_ok);
4516         LDKPrivateRoute res_var = (*val->contents.result);
4517         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4518         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4519         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4520         return res_ref;
4521 }
4522 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4523         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4524         CHECK(!val->result_ok);
4525         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4526         return err_conv;
4527 }
4528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4529         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4530 }
4531 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4532         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4533         CHECK(val->result_ok);
4534         LDKStr res_str = (*val->contents.result);
4535         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4536         return res_conv;
4537 }
4538 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4539         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4540         CHECK(!val->result_ok);
4541         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4542         return err_conv;
4543 }
4544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4545         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4546 }
4547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4548         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4549         CHECK(val->result_ok);
4550         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4551         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4552         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4553         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4554         return res_ref;
4555 }
4556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4557         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4558         CHECK(!val->result_ok);
4559         LDKDecodeError err_var = (*val->contents.err);
4560         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4561         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4562         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4563         return err_ref;
4564 }
4565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4566         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4567 }
4568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4569         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4570         CHECK(val->result_ok);
4571         LDKHTLCUpdate res_var = (*val->contents.result);
4572         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4573         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4574         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4575         return res_ref;
4576 }
4577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4578         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4579         CHECK(!val->result_ok);
4580         LDKDecodeError err_var = (*val->contents.err);
4581         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4582         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4583         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4584         return err_ref;
4585 }
4586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4587         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4588 }
4589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4590         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4591         CHECK(val->result_ok);
4592         return *val->contents.result;
4593 }
4594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4595         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4596         CHECK(!val->result_ok);
4597         LDKMonitorUpdateError err_var = (*val->contents.err);
4598         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4599         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4600         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4601         return err_ref;
4602 }
4603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4604         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4605         LDKOutPoint a_conv;
4606         a_conv.inner = (void*)(a & (~1));
4607         a_conv.is_owned = (a & 1) || (a == 0);
4608         a_conv = OutPoint_clone(&a_conv);
4609         ret->a = a_conv;
4610         LDKCVec_u8Z b_ref;
4611         b_ref.datalen = (*env)->GetArrayLength(env, b);
4612         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4613         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4614         ret->b = b_ref;
4615         return (uint64_t)ret;
4616 }
4617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4618         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4619         LDKOutPoint a_var = tuple->a;
4620         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4621         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4622         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4623         return a_ref;
4624 }
4625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4626         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4627         LDKCVec_u8Z b_var = tuple->b;
4628         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4629         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4630         return b_arr;
4631 }
4632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4633         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4634         ret->a = a;
4635         LDKCVec_u8Z b_ref;
4636         b_ref.datalen = (*env)->GetArrayLength(env, b);
4637         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4638         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4639         ret->b = b_ref;
4640         return (uint64_t)ret;
4641 }
4642 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4643         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4644         return tuple->a;
4645 }
4646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4647         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4648         LDKCVec_u8Z b_var = tuple->b;
4649         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4650         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4651         return b_arr;
4652 }
4653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4654         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4655         ret->datalen = (*env)->GetArrayLength(env, elems);
4656         if (ret->datalen == 0) {
4657                 ret->data = NULL;
4658         } else {
4659                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4660                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4661                 for (size_t i = 0; i < ret->datalen; i++) {
4662                         int64_t arr_elem = java_elems[i];
4663                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4664                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4665                         ret->data[i] = arr_elem_conv;
4666                 }
4667                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4668         }
4669         return (uint64_t)ret;
4670 }
4671 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4672         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4673         for (size_t i = 0; i < ret.datalen; i++) {
4674                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4675         }
4676         return ret;
4677 }
4678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4679         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4680         LDKThirtyTwoBytes a_ref;
4681         CHECK((*env)->GetArrayLength(env, a) == 32);
4682         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4683         ret->a = a_ref;
4684         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4685         b_constr.datalen = (*env)->GetArrayLength(env, b);
4686         if (b_constr.datalen > 0)
4687                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4688         else
4689                 b_constr.data = NULL;
4690         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4691         for (size_t b = 0; b < b_constr.datalen; b++) {
4692                 int64_t b_conv_27 = b_vals[b];
4693                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4694                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4695                 b_constr.data[b] = b_conv_27_conv;
4696         }
4697         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4698         ret->b = b_constr;
4699         return (uint64_t)ret;
4700 }
4701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4702         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4703         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4704         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4705         return a_arr;
4706 }
4707 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4708         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4709         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4710         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4711         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4712         for (size_t b = 0; b < b_var.datalen; b++) {
4713                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4714                 b_arr_ptr[b] = b_conv_27_ref;
4715         }
4716         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4717         return b_arr;
4718 }
4719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4720         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4721         ret->datalen = (*env)->GetArrayLength(env, elems);
4722         if (ret->datalen == 0) {
4723                 ret->data = NULL;
4724         } else {
4725                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4726                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4727                 for (size_t i = 0; i < ret->datalen; i++) {
4728                         int64_t arr_elem = java_elems[i];
4729                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4730                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4731                         ret->data[i] = arr_elem_conv;
4732                 }
4733                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4734         }
4735         return (uint64_t)ret;
4736 }
4737 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4738         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 };
4739         for (size_t i = 0; i < ret.datalen; i++) {
4740                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4741         }
4742         return ret;
4743 }
4744 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
4745 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
4746 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
4747 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
4748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
4749         LDKPaymentPurpose_InvoicePayment_class =
4750                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
4751         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
4752         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
4753         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
4754         LDKPaymentPurpose_SpontaneousPayment_class =
4755                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
4756         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
4757         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
4758         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
4759 }
4760 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4761         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
4762         switch(obj->tag) {
4763                 case LDKPaymentPurpose_InvoicePayment: {
4764                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4765                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
4766                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4767                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
4768                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
4769                 }
4770                 case LDKPaymentPurpose_SpontaneousPayment: {
4771                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
4772                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
4773                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
4774                 }
4775                 default: abort();
4776         }
4777 }
4778 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4779 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4780 static jclass LDKEvent_PaymentReceived_class = NULL;
4781 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4782 static jclass LDKEvent_PaymentSent_class = NULL;
4783 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4784 static jclass LDKEvent_PaymentFailed_class = NULL;
4785 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4786 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4787 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4788 static jclass LDKEvent_SpendableOutputs_class = NULL;
4789 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4790 static jclass LDKEvent_PaymentForwarded_class = NULL;
4791 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
4792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4793         LDKEvent_FundingGenerationReady_class =
4794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4795         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4796         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4797         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4798         LDKEvent_PaymentReceived_class =
4799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4800         CHECK(LDKEvent_PaymentReceived_class != NULL);
4801         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
4802         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4803         LDKEvent_PaymentSent_class =
4804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4805         CHECK(LDKEvent_PaymentSent_class != NULL);
4806         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4807         CHECK(LDKEvent_PaymentSent_meth != NULL);
4808         LDKEvent_PaymentFailed_class =
4809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4810         CHECK(LDKEvent_PaymentFailed_class != NULL);
4811         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4812         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4813         LDKEvent_PendingHTLCsForwardable_class =
4814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4815         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4816         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4817         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4818         LDKEvent_SpendableOutputs_class =
4819                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4820         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4821         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4822         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4823         LDKEvent_PaymentForwarded_class =
4824                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
4825         CHECK(LDKEvent_PaymentForwarded_class != NULL);
4826         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
4827         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
4828 }
4829 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4830         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4831         switch(obj->tag) {
4832                 case LDKEvent_FundingGenerationReady: {
4833                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4834                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4835                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4836                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4837                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4838                         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);
4839                 }
4840                 case LDKEvent_PaymentReceived: {
4841                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4842                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4843                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
4844                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
4845                 }
4846                 case LDKEvent_PaymentSent: {
4847                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4848                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4849                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4850                 }
4851                 case LDKEvent_PaymentFailed: {
4852                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4853                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4854                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4855                 }
4856                 case LDKEvent_PendingHTLCsForwardable: {
4857                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4858                 }
4859                 case LDKEvent_SpendableOutputs: {
4860                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4861                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4862                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4863                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4864                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4865                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4866                         }
4867                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4868                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4869                 }
4870                 case LDKEvent_PaymentForwarded: {
4871                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
4872                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
4873                 }
4874                 default: abort();
4875         }
4876 }
4877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4878         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4879         ret->datalen = (*env)->GetArrayLength(env, elems);
4880         if (ret->datalen == 0) {
4881                 ret->data = NULL;
4882         } else {
4883                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4884                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4885                 for (size_t i = 0; i < ret->datalen; i++) {
4886                         int64_t arr_elem = java_elems[i];
4887                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4888                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4889                         ret->data[i] = arr_elem_conv;
4890                 }
4891                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4892         }
4893         return (uint64_t)ret;
4894 }
4895 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4896         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4897         for (size_t i = 0; i < ret.datalen; i++) {
4898                 ret.data[i] = Event_clone(&orig->data[i]);
4899         }
4900         return ret;
4901 }
4902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4903         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4904         ret->a = a;
4905         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4906         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4907         ret->b = b_conv;
4908         return (uint64_t)ret;
4909 }
4910 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4911         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4912         return tuple->a;
4913 }
4914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4915         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4916         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4917         return (uint64_t)b_ref;
4918 }
4919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4920         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4921         ret->datalen = (*env)->GetArrayLength(env, elems);
4922         if (ret->datalen == 0) {
4923                 ret->data = NULL;
4924         } else {
4925                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4926                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4927                 for (size_t i = 0; i < ret->datalen; i++) {
4928                         int64_t arr_elem = java_elems[i];
4929                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4930                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4931                         ret->data[i] = arr_elem_conv;
4932                 }
4933                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4934         }
4935         return (uint64_t)ret;
4936 }
4937 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4938         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4939         for (size_t i = 0; i < ret.datalen; i++) {
4940                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4941         }
4942         return ret;
4943 }
4944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4945         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4946         LDKThirtyTwoBytes a_ref;
4947         CHECK((*env)->GetArrayLength(env, a) == 32);
4948         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4949         ret->a = a_ref;
4950         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4951         b_constr.datalen = (*env)->GetArrayLength(env, b);
4952         if (b_constr.datalen > 0)
4953                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4954         else
4955                 b_constr.data = NULL;
4956         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4957         for (size_t a = 0; a < b_constr.datalen; a++) {
4958                 int64_t b_conv_26 = b_vals[a];
4959                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4960                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4961                 b_constr.data[a] = b_conv_26_conv;
4962         }
4963         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4964         ret->b = b_constr;
4965         return (uint64_t)ret;
4966 }
4967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4968         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4969         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4970         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4971         return a_arr;
4972 }
4973 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4974         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4975         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4976         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4977         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4978         for (size_t a = 0; a < b_var.datalen; a++) {
4979                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4980                 b_arr_ptr[a] = b_conv_26_ref;
4981         }
4982         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4983         return b_arr;
4984 }
4985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4986         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4987         ret->datalen = (*env)->GetArrayLength(env, elems);
4988         if (ret->datalen == 0) {
4989                 ret->data = NULL;
4990         } else {
4991                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4992                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4993                 for (size_t i = 0; i < ret->datalen; i++) {
4994                         int64_t arr_elem = java_elems[i];
4995                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4996                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4997                         ret->data[i] = arr_elem_conv;
4998                 }
4999                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5000         }
5001         return (uint64_t)ret;
5002 }
5003 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5004         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 };
5005         for (size_t i = 0; i < ret.datalen; i++) {
5006                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5007         }
5008         return ret;
5009 }
5010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5011         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5012 }
5013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5014         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5015         CHECK(val->result_ok);
5016         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
5017         return res_ref;
5018 }
5019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5020         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5021         CHECK(!val->result_ok);
5022         LDKDecodeError err_var = (*val->contents.err);
5023         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5024         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5025         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5026         return err_ref;
5027 }
5028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5029         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5030 }
5031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5032         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5033         CHECK(val->result_ok);
5034         return *val->contents.result;
5035 }
5036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5037         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5038         CHECK(!val->result_ok);
5039         LDKLightningError err_var = (*val->contents.err);
5040         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5041         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5042         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5043         return err_ref;
5044 }
5045 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) {
5046         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5047         LDKChannelAnnouncement a_conv;
5048         a_conv.inner = (void*)(a & (~1));
5049         a_conv.is_owned = (a & 1) || (a == 0);
5050         a_conv = ChannelAnnouncement_clone(&a_conv);
5051         ret->a = a_conv;
5052         LDKChannelUpdate b_conv;
5053         b_conv.inner = (void*)(b & (~1));
5054         b_conv.is_owned = (b & 1) || (b == 0);
5055         b_conv = ChannelUpdate_clone(&b_conv);
5056         ret->b = b_conv;
5057         LDKChannelUpdate c_conv;
5058         c_conv.inner = (void*)(c & (~1));
5059         c_conv.is_owned = (c & 1) || (c == 0);
5060         c_conv = ChannelUpdate_clone(&c_conv);
5061         ret->c = c_conv;
5062         return (uint64_t)ret;
5063 }
5064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
5065         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5066         LDKChannelAnnouncement a_var = tuple->a;
5067         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5068         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5069         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
5070         return a_ref;
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
5073         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5074         LDKChannelUpdate b_var = tuple->b;
5075         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5076         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5077         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
5078         return b_ref;
5079 }
5080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
5081         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5082         LDKChannelUpdate c_var = tuple->c;
5083         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5084         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5085         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
5086         return c_ref;
5087 }
5088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5089         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5090         ret->datalen = (*env)->GetArrayLength(env, elems);
5091         if (ret->datalen == 0) {
5092                 ret->data = NULL;
5093         } else {
5094                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5095                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5096                 for (size_t i = 0; i < ret->datalen; i++) {
5097                         int64_t arr_elem = java_elems[i];
5098                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
5099                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5100                         ret->data[i] = arr_elem_conv;
5101                 }
5102                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5103         }
5104         return (uint64_t)ret;
5105 }
5106 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5107         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5108         for (size_t i = 0; i < ret.datalen; i++) {
5109                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5110         }
5111         return ret;
5112 }
5113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5114         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5115         ret->datalen = (*env)->GetArrayLength(env, elems);
5116         if (ret->datalen == 0) {
5117                 ret->data = NULL;
5118         } else {
5119                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5120                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5121                 for (size_t i = 0; i < ret->datalen; i++) {
5122                         int64_t arr_elem = java_elems[i];
5123                         LDKNodeAnnouncement arr_elem_conv;
5124                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5125                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5126                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5127                         ret->data[i] = arr_elem_conv;
5128                 }
5129                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5130         }
5131         return (uint64_t)ret;
5132 }
5133 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5134         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5135         for (size_t i = 0; i < ret.datalen; i++) {
5136                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5137         }
5138         return ret;
5139 }
5140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5141         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5142 }
5143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5144         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5145         CHECK(val->result_ok);
5146         return *val->contents.result;
5147 }
5148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5149         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5150         CHECK(!val->result_ok);
5151         LDKLightningError err_var = (*val->contents.err);
5152         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5153         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5154         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5155         return err_ref;
5156 }
5157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5158         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5159 }
5160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5161         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5162         CHECK(val->result_ok);
5163         LDKCVec_u8Z res_var = (*val->contents.result);
5164         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5165         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5166         return res_arr;
5167 }
5168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5169         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5170         CHECK(!val->result_ok);
5171         LDKPeerHandleError err_var = (*val->contents.err);
5172         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5173         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5174         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5175         return err_ref;
5176 }
5177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5178         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5179 }
5180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5181         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5182         CHECK(val->result_ok);
5183         return *val->contents.result;
5184 }
5185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5186         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5187         CHECK(!val->result_ok);
5188         LDKPeerHandleError err_var = (*val->contents.err);
5189         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5190         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5191         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5192         return err_ref;
5193 }
5194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5195         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5196 }
5197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5198         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5199         CHECK(val->result_ok);
5200         return *val->contents.result;
5201 }
5202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5203         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5204         CHECK(!val->result_ok);
5205         LDKPeerHandleError err_var = (*val->contents.err);
5206         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5207         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5208         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5209         return err_ref;
5210 }
5211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5212         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5213 }
5214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5215         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5216         CHECK(val->result_ok);
5217         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5218         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5219         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5220         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5221         return res_ref;
5222 }
5223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5224         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5225         CHECK(!val->result_ok);
5226         LDKDecodeError err_var = (*val->contents.err);
5227         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5228         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5229         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5230         return err_ref;
5231 }
5232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5233         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5234 }
5235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5236         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5237         CHECK(val->result_ok);
5238         LDKChannelInfo res_var = (*val->contents.result);
5239         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5240         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5241         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5242         return res_ref;
5243 }
5244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5245         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5246         CHECK(!val->result_ok);
5247         LDKDecodeError err_var = (*val->contents.err);
5248         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5249         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5250         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5251         return err_ref;
5252 }
5253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5254         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5255 }
5256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5257         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5258         CHECK(val->result_ok);
5259         LDKRoutingFees res_var = (*val->contents.result);
5260         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5261         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5262         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5263         return res_ref;
5264 }
5265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5266         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5267         CHECK(!val->result_ok);
5268         LDKDecodeError err_var = (*val->contents.err);
5269         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5270         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5271         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5272         return err_ref;
5273 }
5274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5275         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5276 }
5277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5278         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5279         CHECK(val->result_ok);
5280         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5281         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5282         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5283         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5284         return res_ref;
5285 }
5286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5287         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5288         CHECK(!val->result_ok);
5289         LDKDecodeError err_var = (*val->contents.err);
5290         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5291         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5292         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5293         return err_ref;
5294 }
5295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5296         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5297         ret->datalen = (*env)->GetArrayLength(env, elems);
5298         if (ret->datalen == 0) {
5299                 ret->data = NULL;
5300         } else {
5301                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5302                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5303                 for (size_t i = 0; i < ret->datalen; i++) {
5304                         ret->data[i] = java_elems[i];
5305                 }
5306                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5307         }
5308         return (uint64_t)ret;
5309 }
5310 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5311         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5312         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5313         return ret;
5314 }
5315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5316         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5317 }
5318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5319         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5320         CHECK(val->result_ok);
5321         LDKNodeInfo res_var = (*val->contents.result);
5322         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5323         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5324         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5325         return res_ref;
5326 }
5327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5328         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5329         CHECK(!val->result_ok);
5330         LDKDecodeError err_var = (*val->contents.err);
5331         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5332         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5333         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5334         return err_ref;
5335 }
5336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5337         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5338 }
5339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5340         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5341         CHECK(val->result_ok);
5342         LDKNetworkGraph res_var = (*val->contents.result);
5343         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5344         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5345         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5346         return res_ref;
5347 }
5348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5349         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5350         CHECK(!val->result_ok);
5351         LDKDecodeError err_var = (*val->contents.err);
5352         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5353         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5354         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5355         return err_ref;
5356 }
5357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5358         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5359 }
5360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5361         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5362         CHECK(val->result_ok);
5363         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5364         return res_ref;
5365 }
5366 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5367         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5368         CHECK(!val->result_ok);
5369         return *val->contents.err;
5370 }
5371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5372         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5373 }
5374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5375         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5376         CHECK(val->result_ok);
5377         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5378         *res_conv = (*val->contents.result);
5379         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5380         return (uint64_t)res_conv;
5381 }
5382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5383         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5384         CHECK(!val->result_ok);
5385         LDKDecodeError err_var = (*val->contents.err);
5386         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5387         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5388         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5389         return err_ref;
5390 }
5391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5392         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5393 }
5394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5395         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5396         CHECK(val->result_ok);
5397         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5398         return res_ref;
5399 }
5400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5401         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5402         CHECK(!val->result_ok);
5403         LDKDecodeError err_var = (*val->contents.err);
5404         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5405         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5406         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5407         return err_ref;
5408 }
5409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5410         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5411         ret->datalen = (*env)->GetArrayLength(env, elems);
5412         if (ret->datalen == 0) {
5413                 ret->data = NULL;
5414         } else {
5415                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5416                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5417                 for (size_t i = 0; i < ret->datalen; i++) {
5418                         int64_t arr_elem = java_elems[i];
5419                         LDKUpdateAddHTLC arr_elem_conv;
5420                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5421                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5422                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5423                         ret->data[i] = arr_elem_conv;
5424                 }
5425                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5426         }
5427         return (uint64_t)ret;
5428 }
5429 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5430         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5431         for (size_t i = 0; i < ret.datalen; i++) {
5432                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5433         }
5434         return ret;
5435 }
5436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5437         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5438         ret->datalen = (*env)->GetArrayLength(env, elems);
5439         if (ret->datalen == 0) {
5440                 ret->data = NULL;
5441         } else {
5442                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5443                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5444                 for (size_t i = 0; i < ret->datalen; i++) {
5445                         int64_t arr_elem = java_elems[i];
5446                         LDKUpdateFulfillHTLC arr_elem_conv;
5447                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5448                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5449                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5450                         ret->data[i] = arr_elem_conv;
5451                 }
5452                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5453         }
5454         return (uint64_t)ret;
5455 }
5456 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5457         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5458         for (size_t i = 0; i < ret.datalen; i++) {
5459                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5460         }
5461         return ret;
5462 }
5463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5464         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5465         ret->datalen = (*env)->GetArrayLength(env, elems);
5466         if (ret->datalen == 0) {
5467                 ret->data = NULL;
5468         } else {
5469                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5470                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5471                 for (size_t i = 0; i < ret->datalen; i++) {
5472                         int64_t arr_elem = java_elems[i];
5473                         LDKUpdateFailHTLC arr_elem_conv;
5474                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5475                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5476                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5477                         ret->data[i] = arr_elem_conv;
5478                 }
5479                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5480         }
5481         return (uint64_t)ret;
5482 }
5483 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5484         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5485         for (size_t i = 0; i < ret.datalen; i++) {
5486                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5487         }
5488         return ret;
5489 }
5490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5491         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5492         ret->datalen = (*env)->GetArrayLength(env, elems);
5493         if (ret->datalen == 0) {
5494                 ret->data = NULL;
5495         } else {
5496                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5497                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5498                 for (size_t i = 0; i < ret->datalen; i++) {
5499                         int64_t arr_elem = java_elems[i];
5500                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5501                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5502                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5503                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5504                         ret->data[i] = arr_elem_conv;
5505                 }
5506                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5507         }
5508         return (uint64_t)ret;
5509 }
5510 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5511         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5512         for (size_t i = 0; i < ret.datalen; i++) {
5513                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5514         }
5515         return ret;
5516 }
5517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5518         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5519 }
5520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5521         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5522         CHECK(val->result_ok);
5523         LDKAcceptChannel res_var = (*val->contents.result);
5524         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5525         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5526         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5527         return res_ref;
5528 }
5529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5530         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5531         CHECK(!val->result_ok);
5532         LDKDecodeError err_var = (*val->contents.err);
5533         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5534         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5535         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5536         return err_ref;
5537 }
5538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5539         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5540 }
5541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5542         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5543         CHECK(val->result_ok);
5544         LDKAnnouncementSignatures res_var = (*val->contents.result);
5545         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5546         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5547         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5548         return res_ref;
5549 }
5550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5551         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5552         CHECK(!val->result_ok);
5553         LDKDecodeError err_var = (*val->contents.err);
5554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5556         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5557         return err_ref;
5558 }
5559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5560         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5561 }
5562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5563         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5564         CHECK(val->result_ok);
5565         LDKChannelReestablish res_var = (*val->contents.result);
5566         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5567         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5568         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5569         return res_ref;
5570 }
5571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5572         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5573         CHECK(!val->result_ok);
5574         LDKDecodeError err_var = (*val->contents.err);
5575         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5576         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5577         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5578         return err_ref;
5579 }
5580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5581         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5582 }
5583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5584         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5585         CHECK(val->result_ok);
5586         LDKClosingSigned res_var = (*val->contents.result);
5587         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5588         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5589         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5590         return res_ref;
5591 }
5592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5593         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5594         CHECK(!val->result_ok);
5595         LDKDecodeError err_var = (*val->contents.err);
5596         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5597         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5598         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5599         return err_ref;
5600 }
5601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5602         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
5603 }
5604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5605         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
5606         CHECK(val->result_ok);
5607         LDKClosingSignedFeeRange res_var = (*val->contents.result);
5608         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5609         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5610         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5611         return res_ref;
5612 }
5613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5614         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
5615         CHECK(!val->result_ok);
5616         LDKDecodeError err_var = (*val->contents.err);
5617         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5618         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5619         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5620         return err_ref;
5621 }
5622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5623         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5624 }
5625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5626         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5627         CHECK(val->result_ok);
5628         LDKCommitmentSigned res_var = (*val->contents.result);
5629         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5630         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5631         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5632         return res_ref;
5633 }
5634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5635         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5636         CHECK(!val->result_ok);
5637         LDKDecodeError err_var = (*val->contents.err);
5638         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5639         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5640         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5641         return err_ref;
5642 }
5643 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5644         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5645 }
5646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5647         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5648         CHECK(val->result_ok);
5649         LDKFundingCreated res_var = (*val->contents.result);
5650         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5651         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5652         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5653         return res_ref;
5654 }
5655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5656         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5657         CHECK(!val->result_ok);
5658         LDKDecodeError err_var = (*val->contents.err);
5659         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5660         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5661         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5662         return err_ref;
5663 }
5664 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5665         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5666 }
5667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5668         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5669         CHECK(val->result_ok);
5670         LDKFundingSigned res_var = (*val->contents.result);
5671         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5672         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5673         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5674         return res_ref;
5675 }
5676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5677         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5678         CHECK(!val->result_ok);
5679         LDKDecodeError err_var = (*val->contents.err);
5680         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5681         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5682         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5683         return err_ref;
5684 }
5685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5686         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5687 }
5688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5689         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5690         CHECK(val->result_ok);
5691         LDKFundingLocked res_var = (*val->contents.result);
5692         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5693         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5694         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5695         return res_ref;
5696 }
5697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5698         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5699         CHECK(!val->result_ok);
5700         LDKDecodeError err_var = (*val->contents.err);
5701         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5702         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5703         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5704         return err_ref;
5705 }
5706 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5707         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5708 }
5709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5710         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5711         CHECK(val->result_ok);
5712         LDKInit res_var = (*val->contents.result);
5713         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5714         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5715         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5716         return res_ref;
5717 }
5718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5719         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5720         CHECK(!val->result_ok);
5721         LDKDecodeError err_var = (*val->contents.err);
5722         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5723         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5724         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5725         return err_ref;
5726 }
5727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5728         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5729 }
5730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5731         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5732         CHECK(val->result_ok);
5733         LDKOpenChannel res_var = (*val->contents.result);
5734         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5735         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5736         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5737         return res_ref;
5738 }
5739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5740         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5741         CHECK(!val->result_ok);
5742         LDKDecodeError err_var = (*val->contents.err);
5743         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5744         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5745         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5746         return err_ref;
5747 }
5748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5749         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5750 }
5751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5752         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5753         CHECK(val->result_ok);
5754         LDKRevokeAndACK res_var = (*val->contents.result);
5755         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5756         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5757         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5758         return res_ref;
5759 }
5760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5761         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5762         CHECK(!val->result_ok);
5763         LDKDecodeError err_var = (*val->contents.err);
5764         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5765         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5766         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5767         return err_ref;
5768 }
5769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5770         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5771 }
5772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5773         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5774         CHECK(val->result_ok);
5775         LDKShutdown res_var = (*val->contents.result);
5776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5778         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5779         return res_ref;
5780 }
5781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5782         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5783         CHECK(!val->result_ok);
5784         LDKDecodeError err_var = (*val->contents.err);
5785         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5786         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5787         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5788         return err_ref;
5789 }
5790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5791         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5792 }
5793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5794         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5795         CHECK(val->result_ok);
5796         LDKUpdateFailHTLC res_var = (*val->contents.result);
5797         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5798         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5799         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5800         return res_ref;
5801 }
5802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5803         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5804         CHECK(!val->result_ok);
5805         LDKDecodeError err_var = (*val->contents.err);
5806         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5807         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5808         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5809         return err_ref;
5810 }
5811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5812         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5813 }
5814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5815         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5816         CHECK(val->result_ok);
5817         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5818         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5819         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5820         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5821         return res_ref;
5822 }
5823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5824         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5825         CHECK(!val->result_ok);
5826         LDKDecodeError err_var = (*val->contents.err);
5827         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5828         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5829         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5830         return err_ref;
5831 }
5832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5833         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5834 }
5835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5836         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5837         CHECK(val->result_ok);
5838         LDKUpdateFee res_var = (*val->contents.result);
5839         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5840         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5841         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5842         return res_ref;
5843 }
5844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5845         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5846         CHECK(!val->result_ok);
5847         LDKDecodeError err_var = (*val->contents.err);
5848         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5849         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5850         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5851         return err_ref;
5852 }
5853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5854         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5855 }
5856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5857         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5858         CHECK(val->result_ok);
5859         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5860         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5861         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5862         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5863         return res_ref;
5864 }
5865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5866         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5867         CHECK(!val->result_ok);
5868         LDKDecodeError err_var = (*val->contents.err);
5869         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5870         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5871         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5872         return err_ref;
5873 }
5874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5875         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5876 }
5877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5878         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5879         CHECK(val->result_ok);
5880         LDKUpdateAddHTLC res_var = (*val->contents.result);
5881         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5882         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5883         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5884         return res_ref;
5885 }
5886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5887         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5888         CHECK(!val->result_ok);
5889         LDKDecodeError err_var = (*val->contents.err);
5890         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5891         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5892         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5893         return err_ref;
5894 }
5895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5896         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5897 }
5898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5899         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5900         CHECK(val->result_ok);
5901         LDKPing res_var = (*val->contents.result);
5902         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5903         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5904         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5905         return res_ref;
5906 }
5907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5908         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5909         CHECK(!val->result_ok);
5910         LDKDecodeError err_var = (*val->contents.err);
5911         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5912         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5913         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5914         return err_ref;
5915 }
5916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5917         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5918 }
5919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5920         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5921         CHECK(val->result_ok);
5922         LDKPong res_var = (*val->contents.result);
5923         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5924         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5925         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5926         return res_ref;
5927 }
5928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5929         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5930         CHECK(!val->result_ok);
5931         LDKDecodeError err_var = (*val->contents.err);
5932         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5933         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5934         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5935         return err_ref;
5936 }
5937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5938         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5939 }
5940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5941         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5942         CHECK(val->result_ok);
5943         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5944         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5945         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5946         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5947         return res_ref;
5948 }
5949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5950         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5951         CHECK(!val->result_ok);
5952         LDKDecodeError err_var = (*val->contents.err);
5953         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5954         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5955         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5956         return err_ref;
5957 }
5958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5959         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5960 }
5961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5962         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5963         CHECK(val->result_ok);
5964         LDKChannelAnnouncement res_var = (*val->contents.result);
5965         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5966         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5967         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5968         return res_ref;
5969 }
5970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5971         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5972         CHECK(!val->result_ok);
5973         LDKDecodeError err_var = (*val->contents.err);
5974         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5975         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5976         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5977         return err_ref;
5978 }
5979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5980         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5981 }
5982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5983         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5984         CHECK(val->result_ok);
5985         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5986         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5987         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5988         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5989         return res_ref;
5990 }
5991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5992         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5993         CHECK(!val->result_ok);
5994         LDKDecodeError err_var = (*val->contents.err);
5995         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5996         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5997         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5998         return err_ref;
5999 }
6000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6001         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
6002 }
6003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6004         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6005         CHECK(val->result_ok);
6006         LDKChannelUpdate res_var = (*val->contents.result);
6007         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6008         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6009         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6010         return res_ref;
6011 }
6012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6013         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6014         CHECK(!val->result_ok);
6015         LDKDecodeError err_var = (*val->contents.err);
6016         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6017         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6018         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6019         return err_ref;
6020 }
6021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6022         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
6023 }
6024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6025         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6026         CHECK(val->result_ok);
6027         LDKErrorMessage res_var = (*val->contents.result);
6028         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6029         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6030         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6031         return res_ref;
6032 }
6033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6034         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6035         CHECK(!val->result_ok);
6036         LDKDecodeError err_var = (*val->contents.err);
6037         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6038         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6039         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6040         return err_ref;
6041 }
6042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6043         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6044 }
6045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6046         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6047         CHECK(val->result_ok);
6048         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6049         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6050         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6051         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6052         return res_ref;
6053 }
6054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6055         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6056         CHECK(!val->result_ok);
6057         LDKDecodeError err_var = (*val->contents.err);
6058         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6059         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6060         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6061         return err_ref;
6062 }
6063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6064         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6065 }
6066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6067         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6068         CHECK(val->result_ok);
6069         LDKNodeAnnouncement res_var = (*val->contents.result);
6070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6072         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6073         return res_ref;
6074 }
6075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6076         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6077         CHECK(!val->result_ok);
6078         LDKDecodeError err_var = (*val->contents.err);
6079         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6080         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6081         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6082         return err_ref;
6083 }
6084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6085         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
6086 }
6087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6088         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6089         CHECK(val->result_ok);
6090         LDKQueryShortChannelIds res_var = (*val->contents.result);
6091         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6092         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6093         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6094         return res_ref;
6095 }
6096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6097         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6098         CHECK(!val->result_ok);
6099         LDKDecodeError err_var = (*val->contents.err);
6100         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6101         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6102         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6103         return err_ref;
6104 }
6105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6106         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
6107 }
6108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6109         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6110         CHECK(val->result_ok);
6111         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6112         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6113         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6114         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6115         return res_ref;
6116 }
6117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6118         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6119         CHECK(!val->result_ok);
6120         LDKDecodeError err_var = (*val->contents.err);
6121         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6122         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6123         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6124         return err_ref;
6125 }
6126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6127         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
6128 }
6129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6130         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6131         CHECK(val->result_ok);
6132         LDKQueryChannelRange res_var = (*val->contents.result);
6133         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6134         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6135         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6136         return res_ref;
6137 }
6138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6139         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6140         CHECK(!val->result_ok);
6141         LDKDecodeError err_var = (*val->contents.err);
6142         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6143         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6144         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6145         return err_ref;
6146 }
6147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6148         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
6149 }
6150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6151         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6152         CHECK(val->result_ok);
6153         LDKReplyChannelRange res_var = (*val->contents.result);
6154         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6155         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6156         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6157         return res_ref;
6158 }
6159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6160         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6161         CHECK(!val->result_ok);
6162         LDKDecodeError err_var = (*val->contents.err);
6163         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6164         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6165         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6166         return err_ref;
6167 }
6168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6169         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6170 }
6171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6172         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6173         CHECK(val->result_ok);
6174         LDKGossipTimestampFilter res_var = (*val->contents.result);
6175         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6176         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6177         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6178         return res_ref;
6179 }
6180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6181         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6182         CHECK(!val->result_ok);
6183         LDKDecodeError err_var = (*val->contents.err);
6184         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6185         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6186         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6187         return err_ref;
6188 }
6189 static jclass LDKSignOrCreationError_SignError_class = NULL;
6190 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6191 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6192 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6194         LDKSignOrCreationError_SignError_class =
6195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6196         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6197         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6198         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6199         LDKSignOrCreationError_CreationError_class =
6200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6201         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6202         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6203         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6204 }
6205 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6206         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6207         switch(obj->tag) {
6208                 case LDKSignOrCreationError_SignError: {
6209                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6210                 }
6211                 case LDKSignOrCreationError_CreationError: {
6212                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6213                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6214                 }
6215                 default: abort();
6216         }
6217 }
6218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6219         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6220 }
6221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6222         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6223         CHECK(val->result_ok);
6224         LDKInvoice res_var = (*val->contents.result);
6225         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6226         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6227         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6228         return res_ref;
6229 }
6230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6231         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6232         CHECK(!val->result_ok);
6233         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6234         return err_ref;
6235 }
6236 typedef struct LDKMessageSendEventsProvider_JCalls {
6237         atomic_size_t refcnt;
6238         JavaVM *vm;
6239         jweak o;
6240         jmethodID get_and_clear_pending_msg_events_meth;
6241 } LDKMessageSendEventsProvider_JCalls;
6242 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6243         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6244         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6245                 JNIEnv *env;
6246                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6247                 if (get_jenv_res == JNI_EDETACHED) {
6248                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6249                 } else {
6250                         DO_ASSERT(get_jenv_res == JNI_OK);
6251                 }
6252                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6253                 if (get_jenv_res == JNI_EDETACHED) {
6254                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6255                 }
6256                 FREE(j_calls);
6257         }
6258 }
6259 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6260         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6261         JNIEnv *env;
6262         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6263         if (get_jenv_res == JNI_EDETACHED) {
6264                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6265         } else {
6266                 DO_ASSERT(get_jenv_res == JNI_OK);
6267         }
6268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6269         CHECK(obj != NULL);
6270         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6271         if ((*env)->ExceptionCheck(env)) {
6272                 (*env)->ExceptionDescribe(env);
6273                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6274         }
6275         LDKCVec_MessageSendEventZ ret_constr;
6276         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6277         if (ret_constr.datalen > 0)
6278                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6279         else
6280                 ret_constr.data = NULL;
6281         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6282         for (size_t s = 0; s < ret_constr.datalen; s++) {
6283                 int64_t ret_conv_18 = ret_vals[s];
6284                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6285                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6286                 ret_constr.data[s] = ret_conv_18_conv;
6287         }
6288         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6289         if (get_jenv_res == JNI_EDETACHED) {
6290                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6291         }
6292         return ret_constr;
6293 }
6294 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6295         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6296         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6297 }
6298 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6299         jclass c = (*env)->GetObjectClass(env, o);
6300         CHECK(c != NULL);
6301         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6302         atomic_init(&calls->refcnt, 1);
6303         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6304         calls->o = (*env)->NewWeakGlobalRef(env, o);
6305         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6306         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6307
6308         LDKMessageSendEventsProvider ret = {
6309                 .this_arg = (void*) calls,
6310                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6311                 .free = LDKMessageSendEventsProvider_JCalls_free,
6312         };
6313         return ret;
6314 }
6315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6316         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6317         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6318         return (uint64_t)res_ptr;
6319 }
6320 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6321         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6322         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6323         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6324         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6325         for (size_t s = 0; s < ret_var.datalen; s++) {
6326                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6327                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6328                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6329                 ret_arr_ptr[s] = ret_conv_18_ref;
6330         }
6331         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6332         FREE(ret_var.data);
6333         return ret_arr;
6334 }
6335
6336 typedef struct LDKEventHandler_JCalls {
6337         atomic_size_t refcnt;
6338         JavaVM *vm;
6339         jweak o;
6340         jmethodID handle_event_meth;
6341 } LDKEventHandler_JCalls;
6342 static void LDKEventHandler_JCalls_free(void* this_arg) {
6343         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6344         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6345                 JNIEnv *env;
6346                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6347                 if (get_jenv_res == JNI_EDETACHED) {
6348                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6349                 } else {
6350                         DO_ASSERT(get_jenv_res == JNI_OK);
6351                 }
6352                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6353                 if (get_jenv_res == JNI_EDETACHED) {
6354                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6355                 }
6356                 FREE(j_calls);
6357         }
6358 }
6359 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6360         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6361         JNIEnv *env;
6362         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6363         if (get_jenv_res == JNI_EDETACHED) {
6364                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6365         } else {
6366                 DO_ASSERT(get_jenv_res == JNI_OK);
6367         }
6368         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6369         *event_copy = event;
6370         uint64_t event_ref = (uint64_t)event_copy;
6371         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6372         CHECK(obj != NULL);
6373         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6374         if ((*env)->ExceptionCheck(env)) {
6375                 (*env)->ExceptionDescribe(env);
6376                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6377         }
6378         if (get_jenv_res == JNI_EDETACHED) {
6379                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6380         }
6381 }
6382 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6383         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6384         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6385 }
6386 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6387         jclass c = (*env)->GetObjectClass(env, o);
6388         CHECK(c != NULL);
6389         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6390         atomic_init(&calls->refcnt, 1);
6391         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6392         calls->o = (*env)->NewWeakGlobalRef(env, o);
6393         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6394         CHECK(calls->handle_event_meth != NULL);
6395
6396         LDKEventHandler ret = {
6397                 .this_arg = (void*) calls,
6398                 .handle_event = handle_event_LDKEventHandler_jcall,
6399                 .free = LDKEventHandler_JCalls_free,
6400         };
6401         return ret;
6402 }
6403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6404         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6405         *res_ptr = LDKEventHandler_init(env, clz, o);
6406         return (uint64_t)res_ptr;
6407 }
6408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6409         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6410         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6411         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6412 }
6413
6414 typedef struct LDKEventsProvider_JCalls {
6415         atomic_size_t refcnt;
6416         JavaVM *vm;
6417         jweak o;
6418         jmethodID process_pending_events_meth;
6419 } LDKEventsProvider_JCalls;
6420 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6421         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6422         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6423                 JNIEnv *env;
6424                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6425                 if (get_jenv_res == JNI_EDETACHED) {
6426                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6427                 } else {
6428                         DO_ASSERT(get_jenv_res == JNI_OK);
6429                 }
6430                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6431                 if (get_jenv_res == JNI_EDETACHED) {
6432                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6433                 }
6434                 FREE(j_calls);
6435         }
6436 }
6437 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6438         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6439         JNIEnv *env;
6440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6441         if (get_jenv_res == JNI_EDETACHED) {
6442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6443         } else {
6444                 DO_ASSERT(get_jenv_res == JNI_OK);
6445         }
6446         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6447         *ret = handler;
6448         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6449         CHECK(obj != NULL);
6450         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6451         if ((*env)->ExceptionCheck(env)) {
6452                 (*env)->ExceptionDescribe(env);
6453                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6454         }
6455         if (get_jenv_res == JNI_EDETACHED) {
6456                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6457         }
6458 }
6459 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6460         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6461         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6462 }
6463 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6464         jclass c = (*env)->GetObjectClass(env, o);
6465         CHECK(c != NULL);
6466         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6467         atomic_init(&calls->refcnt, 1);
6468         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6469         calls->o = (*env)->NewWeakGlobalRef(env, o);
6470         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6471         CHECK(calls->process_pending_events_meth != NULL);
6472
6473         LDKEventsProvider ret = {
6474                 .this_arg = (void*) calls,
6475                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6476                 .free = LDKEventsProvider_JCalls_free,
6477         };
6478         return ret;
6479 }
6480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6481         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6482         *res_ptr = LDKEventsProvider_init(env, clz, o);
6483         return (uint64_t)res_ptr;
6484 }
6485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6486         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6487         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6488         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6489                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6490                 LDKEventHandler_JCalls_cloned(&handler_conv);
6491         }
6492         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6493 }
6494
6495 typedef struct LDKAccess_JCalls {
6496         atomic_size_t refcnt;
6497         JavaVM *vm;
6498         jweak o;
6499         jmethodID get_utxo_meth;
6500 } LDKAccess_JCalls;
6501 static void LDKAccess_JCalls_free(void* this_arg) {
6502         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6503         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6504                 JNIEnv *env;
6505                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6506                 if (get_jenv_res == JNI_EDETACHED) {
6507                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6508                 } else {
6509                         DO_ASSERT(get_jenv_res == JNI_OK);
6510                 }
6511                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6512                 if (get_jenv_res == JNI_EDETACHED) {
6513                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6514                 }
6515                 FREE(j_calls);
6516         }
6517 }
6518 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6519         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6520         JNIEnv *env;
6521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6522         if (get_jenv_res == JNI_EDETACHED) {
6523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6524         } else {
6525                 DO_ASSERT(get_jenv_res == JNI_OK);
6526         }
6527         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6528         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6529         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6530         CHECK(obj != NULL);
6531         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6532         if ((*env)->ExceptionCheck(env)) {
6533                 (*env)->ExceptionDescribe(env);
6534                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6535         }
6536         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6537         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6538         if (get_jenv_res == JNI_EDETACHED) {
6539                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6540         }
6541         return ret_conv;
6542 }
6543 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6544         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6545         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6546 }
6547 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6548         jclass c = (*env)->GetObjectClass(env, o);
6549         CHECK(c != NULL);
6550         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6551         atomic_init(&calls->refcnt, 1);
6552         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6553         calls->o = (*env)->NewWeakGlobalRef(env, o);
6554         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6555         CHECK(calls->get_utxo_meth != NULL);
6556
6557         LDKAccess ret = {
6558                 .this_arg = (void*) calls,
6559                 .get_utxo = get_utxo_LDKAccess_jcall,
6560                 .free = LDKAccess_JCalls_free,
6561         };
6562         return ret;
6563 }
6564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6565         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6566         *res_ptr = LDKAccess_init(env, clz, o);
6567         return (uint64_t)res_ptr;
6568 }
6569 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) {
6570         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6571         unsigned char genesis_hash_arr[32];
6572         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6573         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6574         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6575         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6576         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6577         return (uint64_t)ret_conv;
6578 }
6579
6580 typedef struct LDKListen_JCalls {
6581         atomic_size_t refcnt;
6582         JavaVM *vm;
6583         jweak o;
6584         jmethodID block_connected_meth;
6585         jmethodID block_disconnected_meth;
6586 } LDKListen_JCalls;
6587 static void LDKListen_JCalls_free(void* this_arg) {
6588         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6589         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6590                 JNIEnv *env;
6591                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6592                 if (get_jenv_res == JNI_EDETACHED) {
6593                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6594                 } else {
6595                         DO_ASSERT(get_jenv_res == JNI_OK);
6596                 }
6597                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6598                 if (get_jenv_res == JNI_EDETACHED) {
6599                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6600                 }
6601                 FREE(j_calls);
6602         }
6603 }
6604 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6605         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6606         JNIEnv *env;
6607         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6608         if (get_jenv_res == JNI_EDETACHED) {
6609                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6610         } else {
6611                 DO_ASSERT(get_jenv_res == JNI_OK);
6612         }
6613         LDKu8slice block_var = block;
6614         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6615         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6616         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6617         CHECK(obj != NULL);
6618         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6619         if ((*env)->ExceptionCheck(env)) {
6620                 (*env)->ExceptionDescribe(env);
6621                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6622         }
6623         if (get_jenv_res == JNI_EDETACHED) {
6624                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6625         }
6626 }
6627 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6628         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6629         JNIEnv *env;
6630         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6631         if (get_jenv_res == JNI_EDETACHED) {
6632                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6633         } else {
6634                 DO_ASSERT(get_jenv_res == JNI_OK);
6635         }
6636         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6637         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6638         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6639         CHECK(obj != NULL);
6640         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6641         if ((*env)->ExceptionCheck(env)) {
6642                 (*env)->ExceptionDescribe(env);
6643                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6644         }
6645         if (get_jenv_res == JNI_EDETACHED) {
6646                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6647         }
6648 }
6649 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6650         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6651         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6652 }
6653 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6654         jclass c = (*env)->GetObjectClass(env, o);
6655         CHECK(c != NULL);
6656         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6657         atomic_init(&calls->refcnt, 1);
6658         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6659         calls->o = (*env)->NewWeakGlobalRef(env, o);
6660         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6661         CHECK(calls->block_connected_meth != NULL);
6662         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6663         CHECK(calls->block_disconnected_meth != NULL);
6664
6665         LDKListen ret = {
6666                 .this_arg = (void*) calls,
6667                 .block_connected = block_connected_LDKListen_jcall,
6668                 .block_disconnected = block_disconnected_LDKListen_jcall,
6669                 .free = LDKListen_JCalls_free,
6670         };
6671         return ret;
6672 }
6673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6674         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6675         *res_ptr = LDKListen_init(env, clz, o);
6676         return (uint64_t)res_ptr;
6677 }
6678 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) {
6679         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6680         LDKu8slice block_ref;
6681         block_ref.datalen = (*env)->GetArrayLength(env, block);
6682         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6683         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6684         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6685 }
6686
6687 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) {
6688         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6689         unsigned char header_arr[80];
6690         CHECK((*env)->GetArrayLength(env, header) == 80);
6691         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6692         unsigned char (*header_ref)[80] = &header_arr;
6693         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6694 }
6695
6696 typedef struct LDKConfirm_JCalls {
6697         atomic_size_t refcnt;
6698         JavaVM *vm;
6699         jweak o;
6700         jmethodID transactions_confirmed_meth;
6701         jmethodID transaction_unconfirmed_meth;
6702         jmethodID best_block_updated_meth;
6703         jmethodID get_relevant_txids_meth;
6704 } LDKConfirm_JCalls;
6705 static void LDKConfirm_JCalls_free(void* this_arg) {
6706         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6707         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6708                 JNIEnv *env;
6709                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6710                 if (get_jenv_res == JNI_EDETACHED) {
6711                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6712                 } else {
6713                         DO_ASSERT(get_jenv_res == JNI_OK);
6714                 }
6715                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6716                 if (get_jenv_res == JNI_EDETACHED) {
6717                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6718                 }
6719                 FREE(j_calls);
6720         }
6721 }
6722 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6723         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6724         JNIEnv *env;
6725         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6726         if (get_jenv_res == JNI_EDETACHED) {
6727                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6728         } else {
6729                 DO_ASSERT(get_jenv_res == JNI_OK);
6730         }
6731         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6732         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6733         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6734         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6735         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6736         for (size_t y = 0; y < txdata_var.datalen; y++) {
6737                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6738                 *txdata_conv_24_ref = txdata_var.data[y];
6739                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6740         }
6741         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6742         FREE(txdata_var.data);
6743         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6744         CHECK(obj != NULL);
6745         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6746         if ((*env)->ExceptionCheck(env)) {
6747                 (*env)->ExceptionDescribe(env);
6748                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6749         }
6750         if (get_jenv_res == JNI_EDETACHED) {
6751                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6752         }
6753 }
6754 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6755         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6756         JNIEnv *env;
6757         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6758         if (get_jenv_res == JNI_EDETACHED) {
6759                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6760         } else {
6761                 DO_ASSERT(get_jenv_res == JNI_OK);
6762         }
6763         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6764         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6765         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6766         CHECK(obj != NULL);
6767         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6768         if ((*env)->ExceptionCheck(env)) {
6769                 (*env)->ExceptionDescribe(env);
6770                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6771         }
6772         if (get_jenv_res == JNI_EDETACHED) {
6773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6774         }
6775 }
6776 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6777         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6778         JNIEnv *env;
6779         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6780         if (get_jenv_res == JNI_EDETACHED) {
6781                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6782         } else {
6783                 DO_ASSERT(get_jenv_res == JNI_OK);
6784         }
6785         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6786         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6788         CHECK(obj != NULL);
6789         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6790         if ((*env)->ExceptionCheck(env)) {
6791                 (*env)->ExceptionDescribe(env);
6792                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6793         }
6794         if (get_jenv_res == JNI_EDETACHED) {
6795                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6796         }
6797 }
6798 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6799         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6800         JNIEnv *env;
6801         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6802         if (get_jenv_res == JNI_EDETACHED) {
6803                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6804         } else {
6805                 DO_ASSERT(get_jenv_res == JNI_OK);
6806         }
6807         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6808         CHECK(obj != NULL);
6809         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6810         if ((*env)->ExceptionCheck(env)) {
6811                 (*env)->ExceptionDescribe(env);
6812                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6813         }
6814         LDKCVec_TxidZ ret_constr;
6815         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6816         if (ret_constr.datalen > 0)
6817                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6818         else
6819                 ret_constr.data = NULL;
6820         for (size_t i = 0; i < ret_constr.datalen; i++) {
6821                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6822                 LDKThirtyTwoBytes ret_conv_8_ref;
6823                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6824                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6825                 ret_constr.data[i] = ret_conv_8_ref;
6826         }
6827         if (get_jenv_res == JNI_EDETACHED) {
6828                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6829         }
6830         return ret_constr;
6831 }
6832 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6833         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6834         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6835 }
6836 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6837         jclass c = (*env)->GetObjectClass(env, o);
6838         CHECK(c != NULL);
6839         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6840         atomic_init(&calls->refcnt, 1);
6841         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6842         calls->o = (*env)->NewWeakGlobalRef(env, o);
6843         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6844         CHECK(calls->transactions_confirmed_meth != NULL);
6845         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6846         CHECK(calls->transaction_unconfirmed_meth != NULL);
6847         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6848         CHECK(calls->best_block_updated_meth != NULL);
6849         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6850         CHECK(calls->get_relevant_txids_meth != NULL);
6851
6852         LDKConfirm ret = {
6853                 .this_arg = (void*) calls,
6854                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6855                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6856                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6857                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6858                 .free = LDKConfirm_JCalls_free,
6859         };
6860         return ret;
6861 }
6862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6863         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6864         *res_ptr = LDKConfirm_init(env, clz, o);
6865         return (uint64_t)res_ptr;
6866 }
6867 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) {
6868         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6869         unsigned char header_arr[80];
6870         CHECK((*env)->GetArrayLength(env, header) == 80);
6871         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6872         unsigned char (*header_ref)[80] = &header_arr;
6873         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6874         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6875         if (txdata_constr.datalen > 0)
6876                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6877         else
6878                 txdata_constr.data = NULL;
6879         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6880         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6881                 int64_t txdata_conv_24 = txdata_vals[y];
6882                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6883                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6884                 txdata_constr.data[y] = txdata_conv_24_conv;
6885         }
6886         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6887         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6888 }
6889
6890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6891         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6892         unsigned char txid_arr[32];
6893         CHECK((*env)->GetArrayLength(env, txid) == 32);
6894         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6895         unsigned char (*txid_ref)[32] = &txid_arr;
6896         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6897 }
6898
6899 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) {
6900         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6901         unsigned char header_arr[80];
6902         CHECK((*env)->GetArrayLength(env, header) == 80);
6903         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6904         unsigned char (*header_ref)[80] = &header_arr;
6905         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6906 }
6907
6908 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6909         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6910         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6911         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6912         ;
6913         for (size_t i = 0; i < ret_var.datalen; i++) {
6914                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6915                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6916                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6917         }
6918         FREE(ret_var.data);
6919         return ret_arr;
6920 }
6921
6922 typedef struct LDKFilter_JCalls {
6923         atomic_size_t refcnt;
6924         JavaVM *vm;
6925         jweak o;
6926         jmethodID register_tx_meth;
6927         jmethodID register_output_meth;
6928 } LDKFilter_JCalls;
6929 static void LDKFilter_JCalls_free(void* this_arg) {
6930         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6931         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6932                 JNIEnv *env;
6933                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6934                 if (get_jenv_res == JNI_EDETACHED) {
6935                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6936                 } else {
6937                         DO_ASSERT(get_jenv_res == JNI_OK);
6938                 }
6939                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6940                 if (get_jenv_res == JNI_EDETACHED) {
6941                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6942                 }
6943                 FREE(j_calls);
6944         }
6945 }
6946 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6947         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6948         JNIEnv *env;
6949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6950         if (get_jenv_res == JNI_EDETACHED) {
6951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6952         } else {
6953                 DO_ASSERT(get_jenv_res == JNI_OK);
6954         }
6955         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6956         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6957         LDKu8slice script_pubkey_var = script_pubkey;
6958         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6959         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6961         CHECK(obj != NULL);
6962         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6963         if ((*env)->ExceptionCheck(env)) {
6964                 (*env)->ExceptionDescribe(env);
6965                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6966         }
6967         if (get_jenv_res == JNI_EDETACHED) {
6968                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6969         }
6970 }
6971 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6972         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6973         JNIEnv *env;
6974         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6975         if (get_jenv_res == JNI_EDETACHED) {
6976                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6977         } else {
6978                 DO_ASSERT(get_jenv_res == JNI_OK);
6979         }
6980         LDKWatchedOutput output_var = output;
6981         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6982         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6983         uint64_t output_ref = (uint64_t)output_var.inner;
6984         if (output_var.is_owned) {
6985                 output_ref |= 1;
6986         }
6987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6988         CHECK(obj != NULL);
6989         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6990         if ((*env)->ExceptionCheck(env)) {
6991                 (*env)->ExceptionDescribe(env);
6992                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
6993         }
6994         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6995         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6996         if (get_jenv_res == JNI_EDETACHED) {
6997                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6998         }
6999         return ret_conv;
7000 }
7001 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7002         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7003         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7004 }
7005 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7006         jclass c = (*env)->GetObjectClass(env, o);
7007         CHECK(c != NULL);
7008         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7009         atomic_init(&calls->refcnt, 1);
7010         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7011         calls->o = (*env)->NewWeakGlobalRef(env, o);
7012         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7013         CHECK(calls->register_tx_meth != NULL);
7014         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7015         CHECK(calls->register_output_meth != NULL);
7016
7017         LDKFilter ret = {
7018                 .this_arg = (void*) calls,
7019                 .register_tx = register_tx_LDKFilter_jcall,
7020                 .register_output = register_output_LDKFilter_jcall,
7021                 .free = LDKFilter_JCalls_free,
7022         };
7023         return ret;
7024 }
7025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7026         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7027         *res_ptr = LDKFilter_init(env, clz, o);
7028         return (uint64_t)res_ptr;
7029 }
7030 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) {
7031         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7032         unsigned char txid_arr[32];
7033         CHECK((*env)->GetArrayLength(env, txid) == 32);
7034         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7035         unsigned char (*txid_ref)[32] = &txid_arr;
7036         LDKu8slice script_pubkey_ref;
7037         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7038         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7039         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7040         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7041 }
7042
7043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7044         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7045         LDKWatchedOutput output_conv;
7046         output_conv.inner = (void*)(output & (~1));
7047         output_conv.is_owned = (output & 1) || (output == 0);
7048         output_conv = WatchedOutput_clone(&output_conv);
7049         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7050         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7051         uint64_t ret_ref = (uint64_t)ret_copy;
7052         return ret_ref;
7053 }
7054
7055 typedef struct LDKPersist_JCalls {
7056         atomic_size_t refcnt;
7057         JavaVM *vm;
7058         jweak o;
7059         jmethodID persist_new_channel_meth;
7060         jmethodID update_persisted_channel_meth;
7061 } LDKPersist_JCalls;
7062 static void LDKPersist_JCalls_free(void* this_arg) {
7063         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7064         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7065                 JNIEnv *env;
7066                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7067                 if (get_jenv_res == JNI_EDETACHED) {
7068                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7069                 } else {
7070                         DO_ASSERT(get_jenv_res == JNI_OK);
7071                 }
7072                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7073                 if (get_jenv_res == JNI_EDETACHED) {
7074                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7075                 }
7076                 FREE(j_calls);
7077         }
7078 }
7079 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
7080         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7081         JNIEnv *env;
7082         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7083         if (get_jenv_res == JNI_EDETACHED) {
7084                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7085         } else {
7086                 DO_ASSERT(get_jenv_res == JNI_OK);
7087         }
7088         LDKOutPoint id_var = id;
7089         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7090         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7091         uint64_t id_ref = (uint64_t)id_var.inner;
7092         if (id_var.is_owned) {
7093                 id_ref |= 1;
7094         }
7095         LDKChannelMonitor data_var = *data;
7096         data_var = ChannelMonitor_clone(data);
7097         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7098         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7099         uint64_t data_ref = (uint64_t)data_var.inner;
7100         if (data_var.is_owned) {
7101                 data_ref |= 1;
7102         }
7103         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7104         CHECK(obj != NULL);
7105         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
7106         if ((*env)->ExceptionCheck(env)) {
7107                 (*env)->ExceptionDescribe(env);
7108                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7109         }
7110         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7111         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7112         if (get_jenv_res == JNI_EDETACHED) {
7113                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7114         }
7115         return ret_conv;
7116 }
7117 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
7118         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7119         JNIEnv *env;
7120         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7121         if (get_jenv_res == JNI_EDETACHED) {
7122                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7123         } else {
7124                 DO_ASSERT(get_jenv_res == JNI_OK);
7125         }
7126         LDKOutPoint id_var = id;
7127         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7128         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7129         uint64_t id_ref = (uint64_t)id_var.inner;
7130         if (id_var.is_owned) {
7131                 id_ref |= 1;
7132         }
7133         LDKChannelMonitorUpdate update_var = *update;
7134         update_var = ChannelMonitorUpdate_clone(update);
7135         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7136         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7137         uint64_t update_ref = (uint64_t)update_var.inner;
7138         if (update_var.is_owned) {
7139                 update_ref |= 1;
7140         }
7141         LDKChannelMonitor data_var = *data;
7142         data_var = ChannelMonitor_clone(data);
7143         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7144         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7145         uint64_t data_ref = (uint64_t)data_var.inner;
7146         if (data_var.is_owned) {
7147                 data_ref |= 1;
7148         }
7149         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7150         CHECK(obj != NULL);
7151         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7152         if ((*env)->ExceptionCheck(env)) {
7153                 (*env)->ExceptionDescribe(env);
7154                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7155         }
7156         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7157         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7158         if (get_jenv_res == JNI_EDETACHED) {
7159                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7160         }
7161         return ret_conv;
7162 }
7163 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7164         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7165         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7166 }
7167 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7168         jclass c = (*env)->GetObjectClass(env, o);
7169         CHECK(c != NULL);
7170         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7171         atomic_init(&calls->refcnt, 1);
7172         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7173         calls->o = (*env)->NewWeakGlobalRef(env, o);
7174         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7175         CHECK(calls->persist_new_channel_meth != NULL);
7176         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7177         CHECK(calls->update_persisted_channel_meth != NULL);
7178
7179         LDKPersist ret = {
7180                 .this_arg = (void*) calls,
7181                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7182                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7183                 .free = LDKPersist_JCalls_free,
7184         };
7185         return ret;
7186 }
7187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7188         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7189         *res_ptr = LDKPersist_init(env, clz, o);
7190         return (uint64_t)res_ptr;
7191 }
7192 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) {
7193         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7194         LDKOutPoint id_conv;
7195         id_conv.inner = (void*)(id & (~1));
7196         id_conv.is_owned = (id & 1) || (id == 0);
7197         id_conv = OutPoint_clone(&id_conv);
7198         LDKChannelMonitor data_conv;
7199         data_conv.inner = (void*)(data & (~1));
7200         data_conv.is_owned = false;
7201         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7202         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7203         return (uint64_t)ret_conv;
7204 }
7205
7206 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) {
7207         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7208         LDKOutPoint id_conv;
7209         id_conv.inner = (void*)(id & (~1));
7210         id_conv.is_owned = (id & 1) || (id == 0);
7211         id_conv = OutPoint_clone(&id_conv);
7212         LDKChannelMonitorUpdate update_conv;
7213         update_conv.inner = (void*)(update & (~1));
7214         update_conv.is_owned = false;
7215         LDKChannelMonitor data_conv;
7216         data_conv.inner = (void*)(data & (~1));
7217         data_conv.is_owned = false;
7218         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7219         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7220         return (uint64_t)ret_conv;
7221 }
7222
7223 typedef struct LDKChannelMessageHandler_JCalls {
7224         atomic_size_t refcnt;
7225         JavaVM *vm;
7226         jweak o;
7227         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7228         jmethodID handle_open_channel_meth;
7229         jmethodID handle_accept_channel_meth;
7230         jmethodID handle_funding_created_meth;
7231         jmethodID handle_funding_signed_meth;
7232         jmethodID handle_funding_locked_meth;
7233         jmethodID handle_shutdown_meth;
7234         jmethodID handle_closing_signed_meth;
7235         jmethodID handle_update_add_htlc_meth;
7236         jmethodID handle_update_fulfill_htlc_meth;
7237         jmethodID handle_update_fail_htlc_meth;
7238         jmethodID handle_update_fail_malformed_htlc_meth;
7239         jmethodID handle_commitment_signed_meth;
7240         jmethodID handle_revoke_and_ack_meth;
7241         jmethodID handle_update_fee_meth;
7242         jmethodID handle_announcement_signatures_meth;
7243         jmethodID peer_disconnected_meth;
7244         jmethodID peer_connected_meth;
7245         jmethodID handle_channel_reestablish_meth;
7246         jmethodID handle_channel_update_meth;
7247         jmethodID handle_error_meth;
7248 } LDKChannelMessageHandler_JCalls;
7249 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7250         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7251         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7252                 JNIEnv *env;
7253                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7254                 if (get_jenv_res == JNI_EDETACHED) {
7255                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7256                 } else {
7257                         DO_ASSERT(get_jenv_res == JNI_OK);
7258                 }
7259                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7260                 if (get_jenv_res == JNI_EDETACHED) {
7261                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7262                 }
7263                 FREE(j_calls);
7264         }
7265 }
7266 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7267         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7268         JNIEnv *env;
7269         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7270         if (get_jenv_res == JNI_EDETACHED) {
7271                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7272         } else {
7273                 DO_ASSERT(get_jenv_res == JNI_OK);
7274         }
7275         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7276         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7277         LDKInitFeatures their_features_var = their_features;
7278         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7279         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7280         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7281         if (their_features_var.is_owned) {
7282                 their_features_ref |= 1;
7283         }
7284         LDKOpenChannel msg_var = *msg;
7285         msg_var = OpenChannel_clone(msg);
7286         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7287         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7288         uint64_t msg_ref = (uint64_t)msg_var.inner;
7289         if (msg_var.is_owned) {
7290                 msg_ref |= 1;
7291         }
7292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7293         CHECK(obj != NULL);
7294         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7295         if ((*env)->ExceptionCheck(env)) {
7296                 (*env)->ExceptionDescribe(env);
7297                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7298         }
7299         if (get_jenv_res == JNI_EDETACHED) {
7300                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7301         }
7302 }
7303 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7304         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7305         JNIEnv *env;
7306         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7307         if (get_jenv_res == JNI_EDETACHED) {
7308                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7309         } else {
7310                 DO_ASSERT(get_jenv_res == JNI_OK);
7311         }
7312         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7313         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7314         LDKInitFeatures their_features_var = their_features;
7315         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7316         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7317         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7318         if (their_features_var.is_owned) {
7319                 their_features_ref |= 1;
7320         }
7321         LDKAcceptChannel msg_var = *msg;
7322         msg_var = AcceptChannel_clone(msg);
7323         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7324         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7325         uint64_t msg_ref = (uint64_t)msg_var.inner;
7326         if (msg_var.is_owned) {
7327                 msg_ref |= 1;
7328         }
7329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7330         CHECK(obj != NULL);
7331         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7332         if ((*env)->ExceptionCheck(env)) {
7333                 (*env)->ExceptionDescribe(env);
7334                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7335         }
7336         if (get_jenv_res == JNI_EDETACHED) {
7337                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7338         }
7339 }
7340 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7341         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7342         JNIEnv *env;
7343         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7344         if (get_jenv_res == JNI_EDETACHED) {
7345                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7346         } else {
7347                 DO_ASSERT(get_jenv_res == JNI_OK);
7348         }
7349         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7350         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7351         LDKFundingCreated msg_var = *msg;
7352         msg_var = FundingCreated_clone(msg);
7353         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7354         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7355         uint64_t msg_ref = (uint64_t)msg_var.inner;
7356         if (msg_var.is_owned) {
7357                 msg_ref |= 1;
7358         }
7359         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7360         CHECK(obj != NULL);
7361         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7362         if ((*env)->ExceptionCheck(env)) {
7363                 (*env)->ExceptionDescribe(env);
7364                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7365         }
7366         if (get_jenv_res == JNI_EDETACHED) {
7367                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7368         }
7369 }
7370 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7371         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7372         JNIEnv *env;
7373         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7374         if (get_jenv_res == JNI_EDETACHED) {
7375                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7376         } else {
7377                 DO_ASSERT(get_jenv_res == JNI_OK);
7378         }
7379         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7380         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7381         LDKFundingSigned msg_var = *msg;
7382         msg_var = FundingSigned_clone(msg);
7383         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7384         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7385         uint64_t msg_ref = (uint64_t)msg_var.inner;
7386         if (msg_var.is_owned) {
7387                 msg_ref |= 1;
7388         }
7389         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7390         CHECK(obj != NULL);
7391         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7392         if ((*env)->ExceptionCheck(env)) {
7393                 (*env)->ExceptionDescribe(env);
7394                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7395         }
7396         if (get_jenv_res == JNI_EDETACHED) {
7397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7398         }
7399 }
7400 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7401         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7402         JNIEnv *env;
7403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7404         if (get_jenv_res == JNI_EDETACHED) {
7405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7406         } else {
7407                 DO_ASSERT(get_jenv_res == JNI_OK);
7408         }
7409         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7410         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7411         LDKFundingLocked msg_var = *msg;
7412         msg_var = FundingLocked_clone(msg);
7413         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7414         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7415         uint64_t msg_ref = (uint64_t)msg_var.inner;
7416         if (msg_var.is_owned) {
7417                 msg_ref |= 1;
7418         }
7419         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7420         CHECK(obj != NULL);
7421         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7422         if ((*env)->ExceptionCheck(env)) {
7423                 (*env)->ExceptionDescribe(env);
7424                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7425         }
7426         if (get_jenv_res == JNI_EDETACHED) {
7427                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7428         }
7429 }
7430 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7431         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7432         JNIEnv *env;
7433         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7434         if (get_jenv_res == JNI_EDETACHED) {
7435                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7436         } else {
7437                 DO_ASSERT(get_jenv_res == JNI_OK);
7438         }
7439         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7440         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7441         LDKInitFeatures their_features_var = *their_features;
7442         their_features_var = InitFeatures_clone(their_features);
7443         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7444         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7445         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7446         if (their_features_var.is_owned) {
7447                 their_features_ref |= 1;
7448         }
7449         LDKShutdown msg_var = *msg;
7450         msg_var = Shutdown_clone(msg);
7451         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7452         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7453         uint64_t msg_ref = (uint64_t)msg_var.inner;
7454         if (msg_var.is_owned) {
7455                 msg_ref |= 1;
7456         }
7457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7458         CHECK(obj != NULL);
7459         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7460         if ((*env)->ExceptionCheck(env)) {
7461                 (*env)->ExceptionDescribe(env);
7462                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7463         }
7464         if (get_jenv_res == JNI_EDETACHED) {
7465                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7466         }
7467 }
7468 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7469         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7470         JNIEnv *env;
7471         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7472         if (get_jenv_res == JNI_EDETACHED) {
7473                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7474         } else {
7475                 DO_ASSERT(get_jenv_res == JNI_OK);
7476         }
7477         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7478         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7479         LDKClosingSigned msg_var = *msg;
7480         msg_var = ClosingSigned_clone(msg);
7481         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7482         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7483         uint64_t msg_ref = (uint64_t)msg_var.inner;
7484         if (msg_var.is_owned) {
7485                 msg_ref |= 1;
7486         }
7487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7488         CHECK(obj != NULL);
7489         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7490         if ((*env)->ExceptionCheck(env)) {
7491                 (*env)->ExceptionDescribe(env);
7492                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7493         }
7494         if (get_jenv_res == JNI_EDETACHED) {
7495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7496         }
7497 }
7498 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7499         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7500         JNIEnv *env;
7501         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7502         if (get_jenv_res == JNI_EDETACHED) {
7503                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7504         } else {
7505                 DO_ASSERT(get_jenv_res == JNI_OK);
7506         }
7507         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7508         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7509         LDKUpdateAddHTLC msg_var = *msg;
7510         msg_var = UpdateAddHTLC_clone(msg);
7511         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7512         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7513         uint64_t msg_ref = (uint64_t)msg_var.inner;
7514         if (msg_var.is_owned) {
7515                 msg_ref |= 1;
7516         }
7517         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7518         CHECK(obj != NULL);
7519         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7520         if ((*env)->ExceptionCheck(env)) {
7521                 (*env)->ExceptionDescribe(env);
7522                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7523         }
7524         if (get_jenv_res == JNI_EDETACHED) {
7525                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7526         }
7527 }
7528 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7529         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7530         JNIEnv *env;
7531         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7532         if (get_jenv_res == JNI_EDETACHED) {
7533                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7534         } else {
7535                 DO_ASSERT(get_jenv_res == JNI_OK);
7536         }
7537         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7538         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7539         LDKUpdateFulfillHTLC msg_var = *msg;
7540         msg_var = UpdateFulfillHTLC_clone(msg);
7541         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7542         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7543         uint64_t msg_ref = (uint64_t)msg_var.inner;
7544         if (msg_var.is_owned) {
7545                 msg_ref |= 1;
7546         }
7547         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7548         CHECK(obj != NULL);
7549         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7550         if ((*env)->ExceptionCheck(env)) {
7551                 (*env)->ExceptionDescribe(env);
7552                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7553         }
7554         if (get_jenv_res == JNI_EDETACHED) {
7555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7556         }
7557 }
7558 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7559         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7560         JNIEnv *env;
7561         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7562         if (get_jenv_res == JNI_EDETACHED) {
7563                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7564         } else {
7565                 DO_ASSERT(get_jenv_res == JNI_OK);
7566         }
7567         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7568         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7569         LDKUpdateFailHTLC msg_var = *msg;
7570         msg_var = UpdateFailHTLC_clone(msg);
7571         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7572         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7573         uint64_t msg_ref = (uint64_t)msg_var.inner;
7574         if (msg_var.is_owned) {
7575                 msg_ref |= 1;
7576         }
7577         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7578         CHECK(obj != NULL);
7579         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7580         if ((*env)->ExceptionCheck(env)) {
7581                 (*env)->ExceptionDescribe(env);
7582                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7583         }
7584         if (get_jenv_res == JNI_EDETACHED) {
7585                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7586         }
7587 }
7588 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7589         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7590         JNIEnv *env;
7591         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7592         if (get_jenv_res == JNI_EDETACHED) {
7593                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7594         } else {
7595                 DO_ASSERT(get_jenv_res == JNI_OK);
7596         }
7597         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7598         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7599         LDKUpdateFailMalformedHTLC msg_var = *msg;
7600         msg_var = UpdateFailMalformedHTLC_clone(msg);
7601         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7602         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7603         uint64_t msg_ref = (uint64_t)msg_var.inner;
7604         if (msg_var.is_owned) {
7605                 msg_ref |= 1;
7606         }
7607         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7608         CHECK(obj != NULL);
7609         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7610         if ((*env)->ExceptionCheck(env)) {
7611                 (*env)->ExceptionDescribe(env);
7612                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7613         }
7614         if (get_jenv_res == JNI_EDETACHED) {
7615                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7616         }
7617 }
7618 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7619         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7620         JNIEnv *env;
7621         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7622         if (get_jenv_res == JNI_EDETACHED) {
7623                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7624         } else {
7625                 DO_ASSERT(get_jenv_res == JNI_OK);
7626         }
7627         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7628         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7629         LDKCommitmentSigned msg_var = *msg;
7630         msg_var = CommitmentSigned_clone(msg);
7631         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7632         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7633         uint64_t msg_ref = (uint64_t)msg_var.inner;
7634         if (msg_var.is_owned) {
7635                 msg_ref |= 1;
7636         }
7637         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7638         CHECK(obj != NULL);
7639         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7640         if ((*env)->ExceptionCheck(env)) {
7641                 (*env)->ExceptionDescribe(env);
7642                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7643         }
7644         if (get_jenv_res == JNI_EDETACHED) {
7645                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7646         }
7647 }
7648 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7649         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7650         JNIEnv *env;
7651         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7652         if (get_jenv_res == JNI_EDETACHED) {
7653                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7654         } else {
7655                 DO_ASSERT(get_jenv_res == JNI_OK);
7656         }
7657         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7658         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7659         LDKRevokeAndACK msg_var = *msg;
7660         msg_var = RevokeAndACK_clone(msg);
7661         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7662         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7663         uint64_t msg_ref = (uint64_t)msg_var.inner;
7664         if (msg_var.is_owned) {
7665                 msg_ref |= 1;
7666         }
7667         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7668         CHECK(obj != NULL);
7669         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7670         if ((*env)->ExceptionCheck(env)) {
7671                 (*env)->ExceptionDescribe(env);
7672                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7673         }
7674         if (get_jenv_res == JNI_EDETACHED) {
7675                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7676         }
7677 }
7678 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7679         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7680         JNIEnv *env;
7681         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7682         if (get_jenv_res == JNI_EDETACHED) {
7683                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7684         } else {
7685                 DO_ASSERT(get_jenv_res == JNI_OK);
7686         }
7687         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7688         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7689         LDKUpdateFee msg_var = *msg;
7690         msg_var = UpdateFee_clone(msg);
7691         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7692         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7693         uint64_t msg_ref = (uint64_t)msg_var.inner;
7694         if (msg_var.is_owned) {
7695                 msg_ref |= 1;
7696         }
7697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7698         CHECK(obj != NULL);
7699         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7700         if ((*env)->ExceptionCheck(env)) {
7701                 (*env)->ExceptionDescribe(env);
7702                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7703         }
7704         if (get_jenv_res == JNI_EDETACHED) {
7705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7706         }
7707 }
7708 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7709         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7710         JNIEnv *env;
7711         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7712         if (get_jenv_res == JNI_EDETACHED) {
7713                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7714         } else {
7715                 DO_ASSERT(get_jenv_res == JNI_OK);
7716         }
7717         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7718         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7719         LDKAnnouncementSignatures msg_var = *msg;
7720         msg_var = AnnouncementSignatures_clone(msg);
7721         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7722         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7723         uint64_t msg_ref = (uint64_t)msg_var.inner;
7724         if (msg_var.is_owned) {
7725                 msg_ref |= 1;
7726         }
7727         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7728         CHECK(obj != NULL);
7729         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7730         if ((*env)->ExceptionCheck(env)) {
7731                 (*env)->ExceptionDescribe(env);
7732                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7733         }
7734         if (get_jenv_res == JNI_EDETACHED) {
7735                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7736         }
7737 }
7738 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7739         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7740         JNIEnv *env;
7741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7742         if (get_jenv_res == JNI_EDETACHED) {
7743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7744         } else {
7745                 DO_ASSERT(get_jenv_res == JNI_OK);
7746         }
7747         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7748         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7749         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7750         CHECK(obj != NULL);
7751         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7752         if ((*env)->ExceptionCheck(env)) {
7753                 (*env)->ExceptionDescribe(env);
7754                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7755         }
7756         if (get_jenv_res == JNI_EDETACHED) {
7757                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7758         }
7759 }
7760 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7761         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7762         JNIEnv *env;
7763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7764         if (get_jenv_res == JNI_EDETACHED) {
7765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7766         } else {
7767                 DO_ASSERT(get_jenv_res == JNI_OK);
7768         }
7769         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7770         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7771         LDKInit msg_var = *msg;
7772         msg_var = Init_clone(msg);
7773         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7774         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7775         uint64_t msg_ref = (uint64_t)msg_var.inner;
7776         if (msg_var.is_owned) {
7777                 msg_ref |= 1;
7778         }
7779         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7780         CHECK(obj != NULL);
7781         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7782         if ((*env)->ExceptionCheck(env)) {
7783                 (*env)->ExceptionDescribe(env);
7784                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7785         }
7786         if (get_jenv_res == JNI_EDETACHED) {
7787                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7788         }
7789 }
7790 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7791         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7792         JNIEnv *env;
7793         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7794         if (get_jenv_res == JNI_EDETACHED) {
7795                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7796         } else {
7797                 DO_ASSERT(get_jenv_res == JNI_OK);
7798         }
7799         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7800         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7801         LDKChannelReestablish msg_var = *msg;
7802         msg_var = ChannelReestablish_clone(msg);
7803         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7804         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7805         uint64_t msg_ref = (uint64_t)msg_var.inner;
7806         if (msg_var.is_owned) {
7807                 msg_ref |= 1;
7808         }
7809         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7810         CHECK(obj != NULL);
7811         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7812         if ((*env)->ExceptionCheck(env)) {
7813                 (*env)->ExceptionDescribe(env);
7814                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7815         }
7816         if (get_jenv_res == JNI_EDETACHED) {
7817                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7818         }
7819 }
7820 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7821         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7822         JNIEnv *env;
7823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7824         if (get_jenv_res == JNI_EDETACHED) {
7825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7826         } else {
7827                 DO_ASSERT(get_jenv_res == JNI_OK);
7828         }
7829         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7830         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7831         LDKChannelUpdate msg_var = *msg;
7832         msg_var = ChannelUpdate_clone(msg);
7833         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7834         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7835         uint64_t msg_ref = (uint64_t)msg_var.inner;
7836         if (msg_var.is_owned) {
7837                 msg_ref |= 1;
7838         }
7839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7840         CHECK(obj != NULL);
7841         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7842         if ((*env)->ExceptionCheck(env)) {
7843                 (*env)->ExceptionDescribe(env);
7844                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7845         }
7846         if (get_jenv_res == JNI_EDETACHED) {
7847                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7848         }
7849 }
7850 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7851         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7852         JNIEnv *env;
7853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7854         if (get_jenv_res == JNI_EDETACHED) {
7855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7856         } else {
7857                 DO_ASSERT(get_jenv_res == JNI_OK);
7858         }
7859         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7860         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7861         LDKErrorMessage msg_var = *msg;
7862         msg_var = ErrorMessage_clone(msg);
7863         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7864         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7865         uint64_t msg_ref = (uint64_t)msg_var.inner;
7866         if (msg_var.is_owned) {
7867                 msg_ref |= 1;
7868         }
7869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7870         CHECK(obj != NULL);
7871         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7872         if ((*env)->ExceptionCheck(env)) {
7873                 (*env)->ExceptionDescribe(env);
7874                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7875         }
7876         if (get_jenv_res == JNI_EDETACHED) {
7877                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7878         }
7879 }
7880 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7881         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7882         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7883         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7884 }
7885 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7886         jclass c = (*env)->GetObjectClass(env, o);
7887         CHECK(c != NULL);
7888         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7889         atomic_init(&calls->refcnt, 1);
7890         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7891         calls->o = (*env)->NewWeakGlobalRef(env, o);
7892         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7893         CHECK(calls->handle_open_channel_meth != NULL);
7894         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7895         CHECK(calls->handle_accept_channel_meth != NULL);
7896         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7897         CHECK(calls->handle_funding_created_meth != NULL);
7898         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7899         CHECK(calls->handle_funding_signed_meth != NULL);
7900         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7901         CHECK(calls->handle_funding_locked_meth != NULL);
7902         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7903         CHECK(calls->handle_shutdown_meth != NULL);
7904         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7905         CHECK(calls->handle_closing_signed_meth != NULL);
7906         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7907         CHECK(calls->handle_update_add_htlc_meth != NULL);
7908         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7909         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7910         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7911         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7912         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7913         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7914         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7915         CHECK(calls->handle_commitment_signed_meth != NULL);
7916         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7917         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7918         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7919         CHECK(calls->handle_update_fee_meth != NULL);
7920         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7921         CHECK(calls->handle_announcement_signatures_meth != NULL);
7922         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7923         CHECK(calls->peer_disconnected_meth != NULL);
7924         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7925         CHECK(calls->peer_connected_meth != NULL);
7926         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7927         CHECK(calls->handle_channel_reestablish_meth != NULL);
7928         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7929         CHECK(calls->handle_channel_update_meth != NULL);
7930         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7931         CHECK(calls->handle_error_meth != NULL);
7932
7933         LDKChannelMessageHandler ret = {
7934                 .this_arg = (void*) calls,
7935                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7936                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7937                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7938                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7939                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7940                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7941                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7942                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7943                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7944                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7945                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7946                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7947                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7948                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7949                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7950                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7951                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7952                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7953                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7954                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7955                 .free = LDKChannelMessageHandler_JCalls_free,
7956                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7957         };
7958         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7959         return ret;
7960 }
7961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7962         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7963         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7964         return (uint64_t)res_ptr;
7965 }
7966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
7967         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
7968         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
7969         DO_ASSERT((res_ptr & 1) == 0);
7970         return (int64_t)(res_ptr | 1);
7971 }
7972 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) {
7973         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7974         LDKPublicKey their_node_id_ref;
7975         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7976         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7977         LDKInitFeatures their_features_conv;
7978         their_features_conv.inner = (void*)(their_features & (~1));
7979         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7980         their_features_conv = InitFeatures_clone(&their_features_conv);
7981         LDKOpenChannel msg_conv;
7982         msg_conv.inner = (void*)(msg & (~1));
7983         msg_conv.is_owned = false;
7984         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7985 }
7986
7987 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) {
7988         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7989         LDKPublicKey their_node_id_ref;
7990         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7991         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7992         LDKInitFeatures their_features_conv;
7993         their_features_conv.inner = (void*)(their_features & (~1));
7994         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7995         their_features_conv = InitFeatures_clone(&their_features_conv);
7996         LDKAcceptChannel msg_conv;
7997         msg_conv.inner = (void*)(msg & (~1));
7998         msg_conv.is_owned = false;
7999         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8000 }
8001
8002 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) {
8003         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8004         LDKPublicKey their_node_id_ref;
8005         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8006         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8007         LDKFundingCreated msg_conv;
8008         msg_conv.inner = (void*)(msg & (~1));
8009         msg_conv.is_owned = false;
8010         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8011 }
8012
8013 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) {
8014         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8015         LDKPublicKey their_node_id_ref;
8016         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8017         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8018         LDKFundingSigned msg_conv;
8019         msg_conv.inner = (void*)(msg & (~1));
8020         msg_conv.is_owned = false;
8021         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8022 }
8023
8024 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) {
8025         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8026         LDKPublicKey their_node_id_ref;
8027         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8028         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8029         LDKFundingLocked msg_conv;
8030         msg_conv.inner = (void*)(msg & (~1));
8031         msg_conv.is_owned = false;
8032         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8033 }
8034
8035 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) {
8036         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8037         LDKPublicKey their_node_id_ref;
8038         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8039         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8040         LDKInitFeatures their_features_conv;
8041         their_features_conv.inner = (void*)(their_features & (~1));
8042         their_features_conv.is_owned = false;
8043         LDKShutdown msg_conv;
8044         msg_conv.inner = (void*)(msg & (~1));
8045         msg_conv.is_owned = false;
8046         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8047 }
8048
8049 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) {
8050         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8051         LDKPublicKey their_node_id_ref;
8052         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8053         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8054         LDKClosingSigned msg_conv;
8055         msg_conv.inner = (void*)(msg & (~1));
8056         msg_conv.is_owned = false;
8057         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8058 }
8059
8060 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) {
8061         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8062         LDKPublicKey their_node_id_ref;
8063         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8064         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8065         LDKUpdateAddHTLC msg_conv;
8066         msg_conv.inner = (void*)(msg & (~1));
8067         msg_conv.is_owned = false;
8068         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8069 }
8070
8071 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) {
8072         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8073         LDKPublicKey their_node_id_ref;
8074         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8075         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8076         LDKUpdateFulfillHTLC msg_conv;
8077         msg_conv.inner = (void*)(msg & (~1));
8078         msg_conv.is_owned = false;
8079         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8080 }
8081
8082 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) {
8083         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8084         LDKPublicKey their_node_id_ref;
8085         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8086         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8087         LDKUpdateFailHTLC msg_conv;
8088         msg_conv.inner = (void*)(msg & (~1));
8089         msg_conv.is_owned = false;
8090         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8091 }
8092
8093 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) {
8094         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8095         LDKPublicKey their_node_id_ref;
8096         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8097         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8098         LDKUpdateFailMalformedHTLC msg_conv;
8099         msg_conv.inner = (void*)(msg & (~1));
8100         msg_conv.is_owned = false;
8101         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8102 }
8103
8104 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) {
8105         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8106         LDKPublicKey their_node_id_ref;
8107         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8108         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8109         LDKCommitmentSigned msg_conv;
8110         msg_conv.inner = (void*)(msg & (~1));
8111         msg_conv.is_owned = false;
8112         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8113 }
8114
8115 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) {
8116         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8117         LDKPublicKey their_node_id_ref;
8118         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8119         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8120         LDKRevokeAndACK msg_conv;
8121         msg_conv.inner = (void*)(msg & (~1));
8122         msg_conv.is_owned = false;
8123         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8124 }
8125
8126 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) {
8127         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8128         LDKPublicKey their_node_id_ref;
8129         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8130         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8131         LDKUpdateFee msg_conv;
8132         msg_conv.inner = (void*)(msg & (~1));
8133         msg_conv.is_owned = false;
8134         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8135 }
8136
8137 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) {
8138         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8139         LDKPublicKey their_node_id_ref;
8140         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8141         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8142         LDKAnnouncementSignatures msg_conv;
8143         msg_conv.inner = (void*)(msg & (~1));
8144         msg_conv.is_owned = false;
8145         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8146 }
8147
8148 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) {
8149         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8150         LDKPublicKey their_node_id_ref;
8151         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8152         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8153         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8154 }
8155
8156 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) {
8157         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8158         LDKPublicKey their_node_id_ref;
8159         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8160         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8161         LDKInit msg_conv;
8162         msg_conv.inner = (void*)(msg & (~1));
8163         msg_conv.is_owned = false;
8164         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8165 }
8166
8167 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) {
8168         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8169         LDKPublicKey their_node_id_ref;
8170         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8171         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8172         LDKChannelReestablish msg_conv;
8173         msg_conv.inner = (void*)(msg & (~1));
8174         msg_conv.is_owned = false;
8175         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8176 }
8177
8178 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) {
8179         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8180         LDKPublicKey their_node_id_ref;
8181         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8182         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8183         LDKChannelUpdate msg_conv;
8184         msg_conv.inner = (void*)(msg & (~1));
8185         msg_conv.is_owned = false;
8186         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8187 }
8188
8189 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) {
8190         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8191         LDKPublicKey their_node_id_ref;
8192         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8193         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8194         LDKErrorMessage msg_conv;
8195         msg_conv.inner = (void*)(msg & (~1));
8196         msg_conv.is_owned = false;
8197         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8198 }
8199
8200 typedef struct LDKRoutingMessageHandler_JCalls {
8201         atomic_size_t refcnt;
8202         JavaVM *vm;
8203         jweak o;
8204         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8205         jmethodID handle_node_announcement_meth;
8206         jmethodID handle_channel_announcement_meth;
8207         jmethodID handle_channel_update_meth;
8208         jmethodID handle_htlc_fail_channel_update_meth;
8209         jmethodID get_next_channel_announcements_meth;
8210         jmethodID get_next_node_announcements_meth;
8211         jmethodID sync_routing_table_meth;
8212         jmethodID handle_reply_channel_range_meth;
8213         jmethodID handle_reply_short_channel_ids_end_meth;
8214         jmethodID handle_query_channel_range_meth;
8215         jmethodID handle_query_short_channel_ids_meth;
8216 } LDKRoutingMessageHandler_JCalls;
8217 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8218         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8219         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8220                 JNIEnv *env;
8221                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8222                 if (get_jenv_res == JNI_EDETACHED) {
8223                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8224                 } else {
8225                         DO_ASSERT(get_jenv_res == JNI_OK);
8226                 }
8227                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8228                 if (get_jenv_res == JNI_EDETACHED) {
8229                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8230                 }
8231                 FREE(j_calls);
8232         }
8233 }
8234 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8235         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8236         JNIEnv *env;
8237         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8238         if (get_jenv_res == JNI_EDETACHED) {
8239                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8240         } else {
8241                 DO_ASSERT(get_jenv_res == JNI_OK);
8242         }
8243         LDKNodeAnnouncement msg_var = *msg;
8244         msg_var = NodeAnnouncement_clone(msg);
8245         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8246         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8247         uint64_t msg_ref = (uint64_t)msg_var.inner;
8248         if (msg_var.is_owned) {
8249                 msg_ref |= 1;
8250         }
8251         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8252         CHECK(obj != NULL);
8253         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8254         if ((*env)->ExceptionCheck(env)) {
8255                 (*env)->ExceptionDescribe(env);
8256                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8257         }
8258         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8259         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8260         if (get_jenv_res == JNI_EDETACHED) {
8261                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8262         }
8263         return ret_conv;
8264 }
8265 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8266         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8267         JNIEnv *env;
8268         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8269         if (get_jenv_res == JNI_EDETACHED) {
8270                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8271         } else {
8272                 DO_ASSERT(get_jenv_res == JNI_OK);
8273         }
8274         LDKChannelAnnouncement msg_var = *msg;
8275         msg_var = ChannelAnnouncement_clone(msg);
8276         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8277         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8278         uint64_t msg_ref = (uint64_t)msg_var.inner;
8279         if (msg_var.is_owned) {
8280                 msg_ref |= 1;
8281         }
8282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8283         CHECK(obj != NULL);
8284         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8285         if ((*env)->ExceptionCheck(env)) {
8286                 (*env)->ExceptionDescribe(env);
8287                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8288         }
8289         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8290         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8291         if (get_jenv_res == JNI_EDETACHED) {
8292                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8293         }
8294         return ret_conv;
8295 }
8296 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8297         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8298         JNIEnv *env;
8299         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8300         if (get_jenv_res == JNI_EDETACHED) {
8301                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8302         } else {
8303                 DO_ASSERT(get_jenv_res == JNI_OK);
8304         }
8305         LDKChannelUpdate msg_var = *msg;
8306         msg_var = ChannelUpdate_clone(msg);
8307         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8308         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8309         uint64_t msg_ref = (uint64_t)msg_var.inner;
8310         if (msg_var.is_owned) {
8311                 msg_ref |= 1;
8312         }
8313         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8314         CHECK(obj != NULL);
8315         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8316         if ((*env)->ExceptionCheck(env)) {
8317                 (*env)->ExceptionDescribe(env);
8318                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8319         }
8320         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8321         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8322         if (get_jenv_res == JNI_EDETACHED) {
8323                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8324         }
8325         return ret_conv;
8326 }
8327 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8328         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8329         JNIEnv *env;
8330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8331         if (get_jenv_res == JNI_EDETACHED) {
8332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8333         } else {
8334                 DO_ASSERT(get_jenv_res == JNI_OK);
8335         }
8336         uint64_t ret_update = (uint64_t)update;
8337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8338         CHECK(obj != NULL);
8339         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8340         if ((*env)->ExceptionCheck(env)) {
8341                 (*env)->ExceptionDescribe(env);
8342                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8343         }
8344         if (get_jenv_res == JNI_EDETACHED) {
8345                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8346         }
8347 }
8348 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8349         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8350         JNIEnv *env;
8351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8352         if (get_jenv_res == JNI_EDETACHED) {
8353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8354         } else {
8355                 DO_ASSERT(get_jenv_res == JNI_OK);
8356         }
8357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8358         CHECK(obj != NULL);
8359         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8360         if ((*env)->ExceptionCheck(env)) {
8361                 (*env)->ExceptionDescribe(env);
8362                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8363         }
8364         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8365         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8366         if (ret_constr.datalen > 0)
8367                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8368         else
8369                 ret_constr.data = NULL;
8370         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8371         for (size_t l = 0; l < ret_constr.datalen; l++) {
8372                 int64_t ret_conv_63 = ret_vals[l];
8373                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8374                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8375                 ret_constr.data[l] = ret_conv_63_conv;
8376         }
8377         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8378         if (get_jenv_res == JNI_EDETACHED) {
8379                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8380         }
8381         return ret_constr;
8382 }
8383 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8384         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8385         JNIEnv *env;
8386         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8387         if (get_jenv_res == JNI_EDETACHED) {
8388                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8389         } else {
8390                 DO_ASSERT(get_jenv_res == JNI_OK);
8391         }
8392         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8393         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8394         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8395         CHECK(obj != NULL);
8396         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8397         if ((*env)->ExceptionCheck(env)) {
8398                 (*env)->ExceptionDescribe(env);
8399                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8400         }
8401         LDKCVec_NodeAnnouncementZ ret_constr;
8402         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8403         if (ret_constr.datalen > 0)
8404                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8405         else
8406                 ret_constr.data = NULL;
8407         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8408         for (size_t s = 0; s < ret_constr.datalen; s++) {
8409                 int64_t ret_conv_18 = ret_vals[s];
8410                 LDKNodeAnnouncement ret_conv_18_conv;
8411                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8412                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8413                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8414                 ret_constr.data[s] = ret_conv_18_conv;
8415         }
8416         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8417         if (get_jenv_res == JNI_EDETACHED) {
8418                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8419         }
8420         return ret_constr;
8421 }
8422 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8423         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8424         JNIEnv *env;
8425         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8426         if (get_jenv_res == JNI_EDETACHED) {
8427                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8428         } else {
8429                 DO_ASSERT(get_jenv_res == JNI_OK);
8430         }
8431         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8432         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8433         LDKInit init_var = *init;
8434         init_var = Init_clone(init);
8435         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8436         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8437         uint64_t init_ref = (uint64_t)init_var.inner;
8438         if (init_var.is_owned) {
8439                 init_ref |= 1;
8440         }
8441         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8442         CHECK(obj != NULL);
8443         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8444         if ((*env)->ExceptionCheck(env)) {
8445                 (*env)->ExceptionDescribe(env);
8446                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8447         }
8448         if (get_jenv_res == JNI_EDETACHED) {
8449                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8450         }
8451 }
8452 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8453         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8454         JNIEnv *env;
8455         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8456         if (get_jenv_res == JNI_EDETACHED) {
8457                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8458         } else {
8459                 DO_ASSERT(get_jenv_res == JNI_OK);
8460         }
8461         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8462         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8463         LDKReplyChannelRange msg_var = msg;
8464         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8465         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8466         uint64_t msg_ref = (uint64_t)msg_var.inner;
8467         if (msg_var.is_owned) {
8468                 msg_ref |= 1;
8469         }
8470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8471         CHECK(obj != NULL);
8472         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8473         if ((*env)->ExceptionCheck(env)) {
8474                 (*env)->ExceptionDescribe(env);
8475                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8476         }
8477         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8478         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8479         if (get_jenv_res == JNI_EDETACHED) {
8480                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8481         }
8482         return ret_conv;
8483 }
8484 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8485         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8486         JNIEnv *env;
8487         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8488         if (get_jenv_res == JNI_EDETACHED) {
8489                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8490         } else {
8491                 DO_ASSERT(get_jenv_res == JNI_OK);
8492         }
8493         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8494         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8495         LDKReplyShortChannelIdsEnd msg_var = msg;
8496         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8497         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8498         uint64_t msg_ref = (uint64_t)msg_var.inner;
8499         if (msg_var.is_owned) {
8500                 msg_ref |= 1;
8501         }
8502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8503         CHECK(obj != NULL);
8504         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8505         if ((*env)->ExceptionCheck(env)) {
8506                 (*env)->ExceptionDescribe(env);
8507                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8508         }
8509         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8510         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8511         if (get_jenv_res == JNI_EDETACHED) {
8512                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8513         }
8514         return ret_conv;
8515 }
8516 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8517         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8518         JNIEnv *env;
8519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8520         if (get_jenv_res == JNI_EDETACHED) {
8521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8522         } else {
8523                 DO_ASSERT(get_jenv_res == JNI_OK);
8524         }
8525         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8526         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8527         LDKQueryChannelRange msg_var = msg;
8528         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8529         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8530         uint64_t msg_ref = (uint64_t)msg_var.inner;
8531         if (msg_var.is_owned) {
8532                 msg_ref |= 1;
8533         }
8534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8535         CHECK(obj != NULL);
8536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8537         if ((*env)->ExceptionCheck(env)) {
8538                 (*env)->ExceptionDescribe(env);
8539                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8540         }
8541         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8542         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8543         if (get_jenv_res == JNI_EDETACHED) {
8544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8545         }
8546         return ret_conv;
8547 }
8548 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8549         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8550         JNIEnv *env;
8551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8552         if (get_jenv_res == JNI_EDETACHED) {
8553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8554         } else {
8555                 DO_ASSERT(get_jenv_res == JNI_OK);
8556         }
8557         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8558         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8559         LDKQueryShortChannelIds msg_var = msg;
8560         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8561         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8562         uint64_t msg_ref = (uint64_t)msg_var.inner;
8563         if (msg_var.is_owned) {
8564                 msg_ref |= 1;
8565         }
8566         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8567         CHECK(obj != NULL);
8568         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8569         if ((*env)->ExceptionCheck(env)) {
8570                 (*env)->ExceptionDescribe(env);
8571                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8572         }
8573         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8574         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8575         if (get_jenv_res == JNI_EDETACHED) {
8576                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8577         }
8578         return ret_conv;
8579 }
8580 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8581         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8582         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8583         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8584 }
8585 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8586         jclass c = (*env)->GetObjectClass(env, o);
8587         CHECK(c != NULL);
8588         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8589         atomic_init(&calls->refcnt, 1);
8590         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8591         calls->o = (*env)->NewWeakGlobalRef(env, o);
8592         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8593         CHECK(calls->handle_node_announcement_meth != NULL);
8594         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8595         CHECK(calls->handle_channel_announcement_meth != NULL);
8596         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8597         CHECK(calls->handle_channel_update_meth != NULL);
8598         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8599         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8600         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8601         CHECK(calls->get_next_channel_announcements_meth != NULL);
8602         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8603         CHECK(calls->get_next_node_announcements_meth != NULL);
8604         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8605         CHECK(calls->sync_routing_table_meth != NULL);
8606         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8607         CHECK(calls->handle_reply_channel_range_meth != NULL);
8608         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8609         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8610         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8611         CHECK(calls->handle_query_channel_range_meth != NULL);
8612         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8613         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8614
8615         LDKRoutingMessageHandler ret = {
8616                 .this_arg = (void*) calls,
8617                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8618                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8619                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8620                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8621                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8622                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8623                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8624                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8625                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8626                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8627                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8628                 .free = LDKRoutingMessageHandler_JCalls_free,
8629                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8630         };
8631         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8632         return ret;
8633 }
8634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8635         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8636         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8637         return (uint64_t)res_ptr;
8638 }
8639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8640         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
8641         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8642         DO_ASSERT((res_ptr & 1) == 0);
8643         return (int64_t)(res_ptr | 1);
8644 }
8645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8646         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8647         LDKNodeAnnouncement msg_conv;
8648         msg_conv.inner = (void*)(msg & (~1));
8649         msg_conv.is_owned = false;
8650         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8651         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8652         return (uint64_t)ret_conv;
8653 }
8654
8655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8656         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8657         LDKChannelAnnouncement msg_conv;
8658         msg_conv.inner = (void*)(msg & (~1));
8659         msg_conv.is_owned = false;
8660         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8661         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8662         return (uint64_t)ret_conv;
8663 }
8664
8665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8666         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8667         LDKChannelUpdate msg_conv;
8668         msg_conv.inner = (void*)(msg & (~1));
8669         msg_conv.is_owned = false;
8670         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8671         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8672         return (uint64_t)ret_conv;
8673 }
8674
8675 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) {
8676         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8677         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8678         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8679 }
8680
8681 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) {
8682         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8683         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8684         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8685         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8686         for (size_t l = 0; l < ret_var.datalen; l++) {
8687                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8688                 *ret_conv_63_ref = ret_var.data[l];
8689                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8690         }
8691         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8692         FREE(ret_var.data);
8693         return ret_arr;
8694 }
8695
8696 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) {
8697         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8698         LDKPublicKey starting_point_ref;
8699         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8700         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8701         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8702         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8703         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8704         for (size_t s = 0; s < ret_var.datalen; s++) {
8705                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8706                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8707                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8708                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8709                 if (ret_conv_18_var.is_owned) {
8710                         ret_conv_18_ref |= 1;
8711                 }
8712                 ret_arr_ptr[s] = ret_conv_18_ref;
8713         }
8714         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8715         FREE(ret_var.data);
8716         return ret_arr;
8717 }
8718
8719 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) {
8720         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8721         LDKPublicKey their_node_id_ref;
8722         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8723         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8724         LDKInit init_conv;
8725         init_conv.inner = (void*)(init & (~1));
8726         init_conv.is_owned = false;
8727         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8728 }
8729
8730 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) {
8731         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8732         LDKPublicKey their_node_id_ref;
8733         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8734         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8735         LDKReplyChannelRange msg_conv;
8736         msg_conv.inner = (void*)(msg & (~1));
8737         msg_conv.is_owned = (msg & 1) || (msg == 0);
8738         msg_conv = ReplyChannelRange_clone(&msg_conv);
8739         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8740         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8741         return (uint64_t)ret_conv;
8742 }
8743
8744 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) {
8745         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8746         LDKPublicKey their_node_id_ref;
8747         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8748         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8749         LDKReplyShortChannelIdsEnd msg_conv;
8750         msg_conv.inner = (void*)(msg & (~1));
8751         msg_conv.is_owned = (msg & 1) || (msg == 0);
8752         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8753         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8754         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8755         return (uint64_t)ret_conv;
8756 }
8757
8758 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) {
8759         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8760         LDKPublicKey their_node_id_ref;
8761         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8762         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8763         LDKQueryChannelRange msg_conv;
8764         msg_conv.inner = (void*)(msg & (~1));
8765         msg_conv.is_owned = (msg & 1) || (msg == 0);
8766         msg_conv = QueryChannelRange_clone(&msg_conv);
8767         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8768         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8769         return (uint64_t)ret_conv;
8770 }
8771
8772 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) {
8773         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8774         LDKPublicKey their_node_id_ref;
8775         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8776         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8777         LDKQueryShortChannelIds msg_conv;
8778         msg_conv.inner = (void*)(msg & (~1));
8779         msg_conv.is_owned = (msg & 1) || (msg == 0);
8780         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8781         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8782         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8783         return (uint64_t)ret_conv;
8784 }
8785
8786 typedef struct LDKSocketDescriptor_JCalls {
8787         atomic_size_t refcnt;
8788         JavaVM *vm;
8789         jweak o;
8790         jmethodID send_data_meth;
8791         jmethodID disconnect_socket_meth;
8792         jmethodID eq_meth;
8793         jmethodID hash_meth;
8794 } LDKSocketDescriptor_JCalls;
8795 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8796         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8797         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8798                 JNIEnv *env;
8799                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8800                 if (get_jenv_res == JNI_EDETACHED) {
8801                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8802                 } else {
8803                         DO_ASSERT(get_jenv_res == JNI_OK);
8804                 }
8805                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8806                 if (get_jenv_res == JNI_EDETACHED) {
8807                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8808                 }
8809                 FREE(j_calls);
8810         }
8811 }
8812 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8813         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8814         JNIEnv *env;
8815         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8816         if (get_jenv_res == JNI_EDETACHED) {
8817                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8818         } else {
8819                 DO_ASSERT(get_jenv_res == JNI_OK);
8820         }
8821         LDKu8slice data_var = data;
8822         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8823         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8824         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8825         CHECK(obj != NULL);
8826         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8827         if ((*env)->ExceptionCheck(env)) {
8828                 (*env)->ExceptionDescribe(env);
8829                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8830         }
8831         if (get_jenv_res == JNI_EDETACHED) {
8832                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8833         }
8834         return ret;
8835 }
8836 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8837         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8838         JNIEnv *env;
8839         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8840         if (get_jenv_res == JNI_EDETACHED) {
8841                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8842         } else {
8843                 DO_ASSERT(get_jenv_res == JNI_OK);
8844         }
8845         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8846         CHECK(obj != NULL);
8847         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8848         if ((*env)->ExceptionCheck(env)) {
8849                 (*env)->ExceptionDescribe(env);
8850                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8851         }
8852         if (get_jenv_res == JNI_EDETACHED) {
8853                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8854         }
8855 }
8856 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8857         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8858         JNIEnv *env;
8859         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8860         if (get_jenv_res == JNI_EDETACHED) {
8861                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8862         } else {
8863                 DO_ASSERT(get_jenv_res == JNI_OK);
8864         }
8865         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8866         *other_arg_clone = SocketDescriptor_clone(other_arg);
8867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8868         CHECK(obj != NULL);
8869         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8870         if ((*env)->ExceptionCheck(env)) {
8871                 (*env)->ExceptionDescribe(env);
8872                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8873         }
8874         if (get_jenv_res == JNI_EDETACHED) {
8875                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8876         }
8877         return ret;
8878 }
8879 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8880         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8881         JNIEnv *env;
8882         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8883         if (get_jenv_res == JNI_EDETACHED) {
8884                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8885         } else {
8886                 DO_ASSERT(get_jenv_res == JNI_OK);
8887         }
8888         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8889         CHECK(obj != NULL);
8890         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8891         if ((*env)->ExceptionCheck(env)) {
8892                 (*env)->ExceptionDescribe(env);
8893                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8894         }
8895         if (get_jenv_res == JNI_EDETACHED) {
8896                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8897         }
8898         return ret;
8899 }
8900 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8901         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8902         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8903 }
8904 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8905         jclass c = (*env)->GetObjectClass(env, o);
8906         CHECK(c != NULL);
8907         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8908         atomic_init(&calls->refcnt, 1);
8909         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8910         calls->o = (*env)->NewWeakGlobalRef(env, o);
8911         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8912         CHECK(calls->send_data_meth != NULL);
8913         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8914         CHECK(calls->disconnect_socket_meth != NULL);
8915         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8916         CHECK(calls->eq_meth != NULL);
8917         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8918         CHECK(calls->hash_meth != NULL);
8919
8920         LDKSocketDescriptor ret = {
8921                 .this_arg = (void*) calls,
8922                 .send_data = send_data_LDKSocketDescriptor_jcall,
8923                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8924                 .eq = eq_LDKSocketDescriptor_jcall,
8925                 .hash = hash_LDKSocketDescriptor_jcall,
8926                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8927                 .free = LDKSocketDescriptor_JCalls_free,
8928         };
8929         return ret;
8930 }
8931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8932         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8933         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8934         return (uint64_t)res_ptr;
8935 }
8936 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) {
8937         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8938         LDKu8slice data_ref;
8939         data_ref.datalen = (*env)->GetArrayLength(env, data);
8940         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8941         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8942         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8943         return ret_val;
8944 }
8945
8946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8947         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8948         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8949 }
8950
8951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8952         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8953         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8954         return ret_val;
8955 }
8956
8957 typedef struct LDKChannelManagerPersister_JCalls {
8958         atomic_size_t refcnt;
8959         JavaVM *vm;
8960         jweak o;
8961         jmethodID persist_manager_meth;
8962 } LDKChannelManagerPersister_JCalls;
8963 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8964         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8965         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8966                 JNIEnv *env;
8967                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8968                 if (get_jenv_res == JNI_EDETACHED) {
8969                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8970                 } else {
8971                         DO_ASSERT(get_jenv_res == JNI_OK);
8972                 }
8973                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8974                 if (get_jenv_res == JNI_EDETACHED) {
8975                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8976                 }
8977                 FREE(j_calls);
8978         }
8979 }
8980 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8981         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8982         JNIEnv *env;
8983         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8984         if (get_jenv_res == JNI_EDETACHED) {
8985                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8986         } else {
8987                 DO_ASSERT(get_jenv_res == JNI_OK);
8988         }
8989         LDKChannelManager channel_manager_var = *channel_manager;
8990         // Warning: we may need a move here but no clone is available for LDKChannelManager
8991         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8992         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8993         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8994         if (channel_manager_var.is_owned) {
8995                 channel_manager_ref |= 1;
8996         }
8997         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8998         CHECK(obj != NULL);
8999         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
9000         if ((*env)->ExceptionCheck(env)) {
9001                 (*env)->ExceptionDescribe(env);
9002                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
9003         }
9004         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
9005         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
9006         if (get_jenv_res == JNI_EDETACHED) {
9007                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9008         }
9009         return ret_conv;
9010 }
9011 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
9012         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
9013         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9014 }
9015 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
9016         jclass c = (*env)->GetObjectClass(env, o);
9017         CHECK(c != NULL);
9018         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
9019         atomic_init(&calls->refcnt, 1);
9020         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9021         calls->o = (*env)->NewWeakGlobalRef(env, o);
9022         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
9023         CHECK(calls->persist_manager_meth != NULL);
9024
9025         LDKChannelManagerPersister ret = {
9026                 .this_arg = (void*) calls,
9027                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
9028                 .free = LDKChannelManagerPersister_JCalls_free,
9029         };
9030         return ret;
9031 }
9032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
9033         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
9034         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
9035         return (uint64_t)res_ptr;
9036 }
9037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
9038         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
9039         LDKChannelManager channel_manager_conv;
9040         channel_manager_conv.inner = (void*)(channel_manager & (~1));
9041         channel_manager_conv.is_owned = false;
9042         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9043         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
9044         return (uint64_t)ret_conv;
9045 }
9046
9047 static jclass LDKFallback_SegWitProgram_class = NULL;
9048 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
9049 static jclass LDKFallback_PubKeyHash_class = NULL;
9050 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
9051 static jclass LDKFallback_ScriptHash_class = NULL;
9052 static jmethodID LDKFallback_ScriptHash_meth = NULL;
9053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
9054         LDKFallback_SegWitProgram_class =
9055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
9056         CHECK(LDKFallback_SegWitProgram_class != NULL);
9057         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
9058         CHECK(LDKFallback_SegWitProgram_meth != NULL);
9059         LDKFallback_PubKeyHash_class =
9060                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
9061         CHECK(LDKFallback_PubKeyHash_class != NULL);
9062         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
9063         CHECK(LDKFallback_PubKeyHash_meth != NULL);
9064         LDKFallback_ScriptHash_class =
9065                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
9066         CHECK(LDKFallback_ScriptHash_class != NULL);
9067         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
9068         CHECK(LDKFallback_ScriptHash_meth != NULL);
9069 }
9070 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9071         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9072         switch(obj->tag) {
9073                 case LDKFallback_SegWitProgram: {
9074                         uint8_t version_val = obj->seg_wit_program.version._0;
9075                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
9076                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
9077                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
9078                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
9079                 }
9080                 case LDKFallback_PubKeyHash: {
9081                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
9082                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
9083                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
9084                 }
9085                 case LDKFallback_ScriptHash: {
9086                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
9087                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
9088                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
9089                 }
9090                 default: abort();
9091         }
9092 }
9093 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9094         LDKStr ret_str = _ldk_get_compiled_version();
9095         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9096         Str_free(ret_str);
9097         return ret_conv;
9098 }
9099
9100 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9101         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
9102         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9103         Str_free(ret_str);
9104         return ret_conv;
9105 }
9106
9107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9108         LDKTransaction _res_ref;
9109         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9110         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
9111         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9112         _res_ref.data_is_owned = true;
9113         Transaction_free(_res_ref);
9114 }
9115
9116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
9117         LDKCVec_u8Z script_pubkey_ref;
9118         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9119         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
9120         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
9121         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9122         *ret_ref = TxOut_new(script_pubkey_ref, value);
9123         return (uint64_t)ret_ref;
9124 }
9125
9126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
9127         if ((_res & 1) != 0) return;
9128         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
9129         FREE((void*)_res);
9130         TxOut_free(_res_conv);
9131 }
9132
9133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9134         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
9135         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9136         *ret_ref = TxOut_clone(orig_conv);
9137         return (uint64_t)ret_ref;
9138 }
9139
9140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
9141         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
9142         Str_free(dummy);
9143 }
9144
9145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9146         LDKSecretKey o_ref;
9147         CHECK((*env)->GetArrayLength(env, o) == 32);
9148         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
9149         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9150         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9151         return (uint64_t)ret_conv;
9152 }
9153
9154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9155         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9156         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9157         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9158         return (uint64_t)ret_conv;
9159 }
9160
9161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9162         if ((_res & 1) != 0) return;
9163         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9164         FREE((void*)_res);
9165         CResult_SecretKeyErrorZ_free(_res_conv);
9166 }
9167
9168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9169         LDKPublicKey o_ref;
9170         CHECK((*env)->GetArrayLength(env, o) == 33);
9171         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9172         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9173         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9174         return (uint64_t)ret_conv;
9175 }
9176
9177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9178         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9179         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9180         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9181         return (uint64_t)ret_conv;
9182 }
9183
9184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9185         if ((_res & 1) != 0) return;
9186         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9187         FREE((void*)_res);
9188         CResult_PublicKeyErrorZ_free(_res_conv);
9189 }
9190
9191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9192         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9193         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9194         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9195         return (uint64_t)ret_conv;
9196 }
9197
9198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9199         LDKTxCreationKeys o_conv;
9200         o_conv.inner = (void*)(o & (~1));
9201         o_conv.is_owned = (o & 1) || (o == 0);
9202         o_conv = TxCreationKeys_clone(&o_conv);
9203         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9204         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9205         return (uint64_t)ret_conv;
9206 }
9207
9208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9209         LDKDecodeError e_conv;
9210         e_conv.inner = (void*)(e & (~1));
9211         e_conv.is_owned = (e & 1) || (e == 0);
9212         e_conv = DecodeError_clone(&e_conv);
9213         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9214         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9215         return (uint64_t)ret_conv;
9216 }
9217
9218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9219         if ((_res & 1) != 0) return;
9220         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9221         FREE((void*)_res);
9222         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9223 }
9224
9225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9226         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9227         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9228         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9229         return (uint64_t)ret_conv;
9230 }
9231
9232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9233         LDKChannelPublicKeys o_conv;
9234         o_conv.inner = (void*)(o & (~1));
9235         o_conv.is_owned = (o & 1) || (o == 0);
9236         o_conv = ChannelPublicKeys_clone(&o_conv);
9237         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9238         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9239         return (uint64_t)ret_conv;
9240 }
9241
9242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9243         LDKDecodeError e_conv;
9244         e_conv.inner = (void*)(e & (~1));
9245         e_conv.is_owned = (e & 1) || (e == 0);
9246         e_conv = DecodeError_clone(&e_conv);
9247         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9248         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9249         return (uint64_t)ret_conv;
9250 }
9251
9252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9253         if ((_res & 1) != 0) return;
9254         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9255         FREE((void*)_res);
9256         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9257 }
9258
9259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9260         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9261         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9262         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9263         return (uint64_t)ret_conv;
9264 }
9265
9266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9267         LDKTxCreationKeys o_conv;
9268         o_conv.inner = (void*)(o & (~1));
9269         o_conv.is_owned = (o & 1) || (o == 0);
9270         o_conv = TxCreationKeys_clone(&o_conv);
9271         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9272         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9273         return (uint64_t)ret_conv;
9274 }
9275
9276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9277         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9278         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9279         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9280         return (uint64_t)ret_conv;
9281 }
9282
9283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9284         if ((_res & 1) != 0) return;
9285         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9286         FREE((void*)_res);
9287         CResult_TxCreationKeysErrorZ_free(_res_conv);
9288 }
9289
9290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9291         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9292         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9293         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9294         return (uint64_t)ret_conv;
9295 }
9296
9297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9298         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9299         *ret_copy = COption_u32Z_some(o);
9300         uint64_t ret_ref = (uint64_t)ret_copy;
9301         return ret_ref;
9302 }
9303
9304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9305         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9306         *ret_copy = COption_u32Z_none();
9307         uint64_t ret_ref = (uint64_t)ret_copy;
9308         return ret_ref;
9309 }
9310
9311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9312         if ((_res & 1) != 0) return;
9313         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9314         FREE((void*)_res);
9315         COption_u32Z_free(_res_conv);
9316 }
9317
9318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9319         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9320         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9321         *ret_copy = COption_u32Z_clone(orig_conv);
9322         uint64_t ret_ref = (uint64_t)ret_copy;
9323         return ret_ref;
9324 }
9325
9326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9327         LDKHTLCOutputInCommitment o_conv;
9328         o_conv.inner = (void*)(o & (~1));
9329         o_conv.is_owned = (o & 1) || (o == 0);
9330         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9331         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9332         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9333         return (uint64_t)ret_conv;
9334 }
9335
9336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9337         LDKDecodeError e_conv;
9338         e_conv.inner = (void*)(e & (~1));
9339         e_conv.is_owned = (e & 1) || (e == 0);
9340         e_conv = DecodeError_clone(&e_conv);
9341         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9342         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9343         return (uint64_t)ret_conv;
9344 }
9345
9346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9347         if ((_res & 1) != 0) return;
9348         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9349         FREE((void*)_res);
9350         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9351 }
9352
9353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9354         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9355         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9356         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9357         return (uint64_t)ret_conv;
9358 }
9359
9360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9361         LDKCounterpartyChannelTransactionParameters o_conv;
9362         o_conv.inner = (void*)(o & (~1));
9363         o_conv.is_owned = (o & 1) || (o == 0);
9364         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9365         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9366         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9367         return (uint64_t)ret_conv;
9368 }
9369
9370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9371         LDKDecodeError e_conv;
9372         e_conv.inner = (void*)(e & (~1));
9373         e_conv.is_owned = (e & 1) || (e == 0);
9374         e_conv = DecodeError_clone(&e_conv);
9375         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9376         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9377         return (uint64_t)ret_conv;
9378 }
9379
9380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9381         if ((_res & 1) != 0) return;
9382         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9383         FREE((void*)_res);
9384         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9385 }
9386
9387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9388         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9389         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9390         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9391         return (uint64_t)ret_conv;
9392 }
9393
9394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9395         LDKChannelTransactionParameters o_conv;
9396         o_conv.inner = (void*)(o & (~1));
9397         o_conv.is_owned = (o & 1) || (o == 0);
9398         o_conv = ChannelTransactionParameters_clone(&o_conv);
9399         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9400         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9401         return (uint64_t)ret_conv;
9402 }
9403
9404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9405         LDKDecodeError e_conv;
9406         e_conv.inner = (void*)(e & (~1));
9407         e_conv.is_owned = (e & 1) || (e == 0);
9408         e_conv = DecodeError_clone(&e_conv);
9409         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9410         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9411         return (uint64_t)ret_conv;
9412 }
9413
9414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9415         if ((_res & 1) != 0) return;
9416         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9417         FREE((void*)_res);
9418         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9419 }
9420
9421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9422         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9423         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9424         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9425         return (uint64_t)ret_conv;
9426 }
9427
9428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9429         LDKCVec_SignatureZ _res_constr;
9430         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9431         if (_res_constr.datalen > 0)
9432                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9433         else
9434                 _res_constr.data = NULL;
9435         for (size_t i = 0; i < _res_constr.datalen; i++) {
9436                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9437                 LDKSignature _res_conv_8_ref;
9438                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9439                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9440                 _res_constr.data[i] = _res_conv_8_ref;
9441         }
9442         CVec_SignatureZ_free(_res_constr);
9443 }
9444
9445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9446         LDKHolderCommitmentTransaction o_conv;
9447         o_conv.inner = (void*)(o & (~1));
9448         o_conv.is_owned = (o & 1) || (o == 0);
9449         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9450         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9451         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9452         return (uint64_t)ret_conv;
9453 }
9454
9455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9456         LDKDecodeError e_conv;
9457         e_conv.inner = (void*)(e & (~1));
9458         e_conv.is_owned = (e & 1) || (e == 0);
9459         e_conv = DecodeError_clone(&e_conv);
9460         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9461         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9462         return (uint64_t)ret_conv;
9463 }
9464
9465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9466         if ((_res & 1) != 0) return;
9467         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9468         FREE((void*)_res);
9469         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9470 }
9471
9472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9473         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9474         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9475         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9476         return (uint64_t)ret_conv;
9477 }
9478
9479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9480         LDKBuiltCommitmentTransaction o_conv;
9481         o_conv.inner = (void*)(o & (~1));
9482         o_conv.is_owned = (o & 1) || (o == 0);
9483         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9484         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9485         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9486         return (uint64_t)ret_conv;
9487 }
9488
9489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9490         LDKDecodeError e_conv;
9491         e_conv.inner = (void*)(e & (~1));
9492         e_conv.is_owned = (e & 1) || (e == 0);
9493         e_conv = DecodeError_clone(&e_conv);
9494         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9495         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9496         return (uint64_t)ret_conv;
9497 }
9498
9499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9500         if ((_res & 1) != 0) return;
9501         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9502         FREE((void*)_res);
9503         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9504 }
9505
9506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9507         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9508         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9509         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9510         return (uint64_t)ret_conv;
9511 }
9512
9513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9514         LDKCommitmentTransaction o_conv;
9515         o_conv.inner = (void*)(o & (~1));
9516         o_conv.is_owned = (o & 1) || (o == 0);
9517         o_conv = CommitmentTransaction_clone(&o_conv);
9518         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9519         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9520         return (uint64_t)ret_conv;
9521 }
9522
9523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9524         LDKDecodeError e_conv;
9525         e_conv.inner = (void*)(e & (~1));
9526         e_conv.is_owned = (e & 1) || (e == 0);
9527         e_conv = DecodeError_clone(&e_conv);
9528         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9529         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9530         return (uint64_t)ret_conv;
9531 }
9532
9533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9534         if ((_res & 1) != 0) return;
9535         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9536         FREE((void*)_res);
9537         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9538 }
9539
9540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9541         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9542         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9543         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9544         return (uint64_t)ret_conv;
9545 }
9546
9547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9548         LDKTrustedCommitmentTransaction o_conv;
9549         o_conv.inner = (void*)(o & (~1));
9550         o_conv.is_owned = (o & 1) || (o == 0);
9551         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9552         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9553         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9554         return (uint64_t)ret_conv;
9555 }
9556
9557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9558         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9559         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9560         return (uint64_t)ret_conv;
9561 }
9562
9563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9564         if ((_res & 1) != 0) return;
9565         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9566         FREE((void*)_res);
9567         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9568 }
9569
9570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9571         LDKCVec_SignatureZ o_constr;
9572         o_constr.datalen = (*env)->GetArrayLength(env, o);
9573         if (o_constr.datalen > 0)
9574                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9575         else
9576                 o_constr.data = NULL;
9577         for (size_t i = 0; i < o_constr.datalen; i++) {
9578                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9579                 LDKSignature o_conv_8_ref;
9580                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9581                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9582                 o_constr.data[i] = o_conv_8_ref;
9583         }
9584         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9585         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9586         return (uint64_t)ret_conv;
9587 }
9588
9589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9590         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9591         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9592         return (uint64_t)ret_conv;
9593 }
9594
9595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9596         if ((_res & 1) != 0) return;
9597         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9598         FREE((void*)_res);
9599         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9600 }
9601
9602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9603         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9604         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9605         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9606         return (uint64_t)ret_conv;
9607 }
9608
9609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9610         LDKShutdownScript o_conv;
9611         o_conv.inner = (void*)(o & (~1));
9612         o_conv.is_owned = (o & 1) || (o == 0);
9613         o_conv = ShutdownScript_clone(&o_conv);
9614         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9615         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
9616         return (uint64_t)ret_conv;
9617 }
9618
9619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9620         LDKDecodeError e_conv;
9621         e_conv.inner = (void*)(e & (~1));
9622         e_conv.is_owned = (e & 1) || (e == 0);
9623         e_conv = DecodeError_clone(&e_conv);
9624         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9625         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
9626         return (uint64_t)ret_conv;
9627 }
9628
9629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9630         if ((_res & 1) != 0) return;
9631         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
9632         FREE((void*)_res);
9633         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
9634 }
9635
9636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9637         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
9638         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9639         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
9640         return (uint64_t)ret_conv;
9641 }
9642
9643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9644         LDKShutdownScript o_conv;
9645         o_conv.inner = (void*)(o & (~1));
9646         o_conv.is_owned = (o & 1) || (o == 0);
9647         o_conv = ShutdownScript_clone(&o_conv);
9648         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9649         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
9650         return (uint64_t)ret_conv;
9651 }
9652
9653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9654         LDKInvalidShutdownScript e_conv;
9655         e_conv.inner = (void*)(e & (~1));
9656         e_conv.is_owned = (e & 1) || (e == 0);
9657         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
9658         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9659         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
9660         return (uint64_t)ret_conv;
9661 }
9662
9663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9664         if ((_res & 1) != 0) return;
9665         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
9666         FREE((void*)_res);
9667         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
9668 }
9669
9670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9671         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9672         *ret_conv = CResult_NoneErrorZ_ok();
9673         return (uint64_t)ret_conv;
9674 }
9675
9676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9677         LDKIOError e_conv = LDKIOError_from_java(env, e);
9678         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9679         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9680         return (uint64_t)ret_conv;
9681 }
9682
9683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9684         if ((_res & 1) != 0) return;
9685         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9686         FREE((void*)_res);
9687         CResult_NoneErrorZ_free(_res_conv);
9688 }
9689
9690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9691         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9692         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9693         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9694         return (uint64_t)ret_conv;
9695 }
9696
9697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9698         LDKRouteHop o_conv;
9699         o_conv.inner = (void*)(o & (~1));
9700         o_conv.is_owned = (o & 1) || (o == 0);
9701         o_conv = RouteHop_clone(&o_conv);
9702         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9703         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9704         return (uint64_t)ret_conv;
9705 }
9706
9707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9708         LDKDecodeError e_conv;
9709         e_conv.inner = (void*)(e & (~1));
9710         e_conv.is_owned = (e & 1) || (e == 0);
9711         e_conv = DecodeError_clone(&e_conv);
9712         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9713         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9714         return (uint64_t)ret_conv;
9715 }
9716
9717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9718         if ((_res & 1) != 0) return;
9719         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9720         FREE((void*)_res);
9721         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9722 }
9723
9724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9725         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9726         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9727         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9728         return (uint64_t)ret_conv;
9729 }
9730
9731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9732         LDKCVec_RouteHopZ _res_constr;
9733         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9734         if (_res_constr.datalen > 0)
9735                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9736         else
9737                 _res_constr.data = NULL;
9738         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9739         for (size_t k = 0; k < _res_constr.datalen; k++) {
9740                 int64_t _res_conv_10 = _res_vals[k];
9741                 LDKRouteHop _res_conv_10_conv;
9742                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9743                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9744                 _res_constr.data[k] = _res_conv_10_conv;
9745         }
9746         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9747         CVec_RouteHopZ_free(_res_constr);
9748 }
9749
9750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9751         LDKCVec_CVec_RouteHopZZ _res_constr;
9752         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9753         if (_res_constr.datalen > 0)
9754                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9755         else
9756                 _res_constr.data = NULL;
9757         for (size_t m = 0; m < _res_constr.datalen; m++) {
9758                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9759                 LDKCVec_RouteHopZ _res_conv_12_constr;
9760                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9761                 if (_res_conv_12_constr.datalen > 0)
9762                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9763                 else
9764                         _res_conv_12_constr.data = NULL;
9765                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9766                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9767                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9768                         LDKRouteHop _res_conv_12_conv_10_conv;
9769                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9770                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9771                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9772                 }
9773                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9774                 _res_constr.data[m] = _res_conv_12_constr;
9775         }
9776         CVec_CVec_RouteHopZZ_free(_res_constr);
9777 }
9778
9779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9780         LDKRoute o_conv;
9781         o_conv.inner = (void*)(o & (~1));
9782         o_conv.is_owned = (o & 1) || (o == 0);
9783         o_conv = Route_clone(&o_conv);
9784         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9785         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9786         return (uint64_t)ret_conv;
9787 }
9788
9789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9790         LDKDecodeError e_conv;
9791         e_conv.inner = (void*)(e & (~1));
9792         e_conv.is_owned = (e & 1) || (e == 0);
9793         e_conv = DecodeError_clone(&e_conv);
9794         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9795         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9796         return (uint64_t)ret_conv;
9797 }
9798
9799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9800         if ((_res & 1) != 0) return;
9801         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9802         FREE((void*)_res);
9803         CResult_RouteDecodeErrorZ_free(_res_conv);
9804 }
9805
9806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9807         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9808         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9809         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9810         return (uint64_t)ret_conv;
9811 }
9812
9813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9814         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9815         *ret_copy = COption_u64Z_some(o);
9816         uint64_t ret_ref = (uint64_t)ret_copy;
9817         return ret_ref;
9818 }
9819
9820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9821         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9822         *ret_copy = COption_u64Z_none();
9823         uint64_t ret_ref = (uint64_t)ret_copy;
9824         return ret_ref;
9825 }
9826
9827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9828         if ((_res & 1) != 0) return;
9829         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9830         FREE((void*)_res);
9831         COption_u64Z_free(_res_conv);
9832 }
9833
9834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9835         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9836         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9837         *ret_copy = COption_u64Z_clone(orig_conv);
9838         uint64_t ret_ref = (uint64_t)ret_copy;
9839         return ret_ref;
9840 }
9841
9842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9843         LDKCVec_ChannelDetailsZ _res_constr;
9844         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9845         if (_res_constr.datalen > 0)
9846                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9847         else
9848                 _res_constr.data = NULL;
9849         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9850         for (size_t q = 0; q < _res_constr.datalen; q++) {
9851                 int64_t _res_conv_16 = _res_vals[q];
9852                 LDKChannelDetails _res_conv_16_conv;
9853                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9854                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9855                 _res_constr.data[q] = _res_conv_16_conv;
9856         }
9857         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9858         CVec_ChannelDetailsZ_free(_res_constr);
9859 }
9860
9861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9862         LDKCVec_RouteHintZ _res_constr;
9863         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9864         if (_res_constr.datalen > 0)
9865                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9866         else
9867                 _res_constr.data = NULL;
9868         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9869         for (size_t l = 0; l < _res_constr.datalen; l++) {
9870                 int64_t _res_conv_11 = _res_vals[l];
9871                 LDKRouteHint _res_conv_11_conv;
9872                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9873                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9874                 _res_constr.data[l] = _res_conv_11_conv;
9875         }
9876         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9877         CVec_RouteHintZ_free(_res_constr);
9878 }
9879
9880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9881         LDKRoute o_conv;
9882         o_conv.inner = (void*)(o & (~1));
9883         o_conv.is_owned = (o & 1) || (o == 0);
9884         o_conv = Route_clone(&o_conv);
9885         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9886         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9887         return (uint64_t)ret_conv;
9888 }
9889
9890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9891         LDKLightningError e_conv;
9892         e_conv.inner = (void*)(e & (~1));
9893         e_conv.is_owned = (e & 1) || (e == 0);
9894         e_conv = LightningError_clone(&e_conv);
9895         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9896         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9897         return (uint64_t)ret_conv;
9898 }
9899
9900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9901         if ((_res & 1) != 0) return;
9902         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9903         FREE((void*)_res);
9904         CResult_RouteLightningErrorZ_free(_res_conv);
9905 }
9906
9907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9908         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9909         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9910         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9911         return (uint64_t)ret_conv;
9912 }
9913
9914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9915         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9916         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9917         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9918         return (uint64_t)ret_conv;
9919 }
9920
9921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9922         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9923         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9924         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9925         return (uint64_t)ret_conv;
9926 }
9927
9928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9929         if ((_res & 1) != 0) return;
9930         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9931         FREE((void*)_res);
9932         CResult_TxOutAccessErrorZ_free(_res_conv);
9933 }
9934
9935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9936         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9937         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9938         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9939         return (uint64_t)ret_conv;
9940 }
9941
9942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9943         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9944         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9945         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9946         return (uint64_t)ret_ref;
9947 }
9948
9949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9950         LDKTransaction b_ref;
9951         b_ref.datalen = (*env)->GetArrayLength(env, b);
9952         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9953         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9954         b_ref.data_is_owned = true;
9955         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9956         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9957         return (uint64_t)ret_ref;
9958 }
9959
9960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9961         if ((_res & 1) != 0) return;
9962         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9963         FREE((void*)_res);
9964         C2Tuple_usizeTransactionZ_free(_res_conv);
9965 }
9966
9967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9968         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9969         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9970         if (_res_constr.datalen > 0)
9971                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9972         else
9973                 _res_constr.data = NULL;
9974         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9975         for (size_t y = 0; y < _res_constr.datalen; y++) {
9976                 int64_t _res_conv_24 = _res_vals[y];
9977                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9978                 FREE((void*)_res_conv_24);
9979                 _res_constr.data[y] = _res_conv_24_conv;
9980         }
9981         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9982         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9983 }
9984
9985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9986         LDKCVec_TxidZ _res_constr;
9987         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9988         if (_res_constr.datalen > 0)
9989                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9990         else
9991                 _res_constr.data = NULL;
9992         for (size_t i = 0; i < _res_constr.datalen; i++) {
9993                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9994                 LDKThirtyTwoBytes _res_conv_8_ref;
9995                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9996                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9997                 _res_constr.data[i] = _res_conv_8_ref;
9998         }
9999         CVec_TxidZ_free(_res_constr);
10000 }
10001
10002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
10003         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10004         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
10005         return (uint64_t)ret_conv;
10006 }
10007
10008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
10009         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
10010         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10011         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
10012         return (uint64_t)ret_conv;
10013 }
10014
10015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10016         if ((_res & 1) != 0) return;
10017         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
10018         FREE((void*)_res);
10019         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
10020 }
10021
10022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10023         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
10024         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10025         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
10026         return (uint64_t)ret_conv;
10027 }
10028
10029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10030         LDKCVec_MonitorEventZ _res_constr;
10031         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10032         if (_res_constr.datalen > 0)
10033                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
10034         else
10035                 _res_constr.data = NULL;
10036         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10037         for (size_t o = 0; o < _res_constr.datalen; o++) {
10038                 int64_t _res_conv_14 = _res_vals[o];
10039                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
10040                 FREE((void*)_res_conv_14);
10041                 _res_constr.data[o] = _res_conv_14_conv;
10042         }
10043         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10044         CVec_MonitorEventZ_free(_res_constr);
10045 }
10046
10047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
10048         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
10049         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10050         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
10051         uint64_t ret_ref = (uint64_t)ret_copy;
10052         return ret_ref;
10053 }
10054
10055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
10056         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10057         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
10058         uint64_t ret_ref = (uint64_t)ret_copy;
10059         return ret_ref;
10060 }
10061
10062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10063         if ((_res & 1) != 0) return;
10064         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
10065         FREE((void*)_res);
10066         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
10067 }
10068
10069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10070         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
10071         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10072         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
10073         uint64_t ret_ref = (uint64_t)ret_copy;
10074         return ret_ref;
10075 }
10076
10077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10078         LDKCVec_SpendableOutputDescriptorZ _res_constr;
10079         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10080         if (_res_constr.datalen > 0)
10081                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10082         else
10083                 _res_constr.data = NULL;
10084         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10085         for (size_t b = 0; b < _res_constr.datalen; b++) {
10086                 int64_t _res_conv_27 = _res_vals[b];
10087                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
10088                 FREE((void*)_res_conv_27);
10089                 _res_constr.data[b] = _res_conv_27_conv;
10090         }
10091         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10092         CVec_SpendableOutputDescriptorZ_free(_res_constr);
10093 }
10094
10095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10096         LDKCVec_MessageSendEventZ _res_constr;
10097         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10098         if (_res_constr.datalen > 0)
10099                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10100         else
10101                 _res_constr.data = NULL;
10102         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10103         for (size_t s = 0; s < _res_constr.datalen; s++) {
10104                 int64_t _res_conv_18 = _res_vals[s];
10105                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
10106                 FREE((void*)_res_conv_18);
10107                 _res_constr.data[s] = _res_conv_18_conv;
10108         }
10109         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10110         CVec_MessageSendEventZ_free(_res_constr);
10111 }
10112
10113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10114         LDKInitFeatures o_conv;
10115         o_conv.inner = (void*)(o & (~1));
10116         o_conv.is_owned = (o & 1) || (o == 0);
10117         o_conv = InitFeatures_clone(&o_conv);
10118         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10119         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
10120         return (uint64_t)ret_conv;
10121 }
10122
10123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10124         LDKDecodeError e_conv;
10125         e_conv.inner = (void*)(e & (~1));
10126         e_conv.is_owned = (e & 1) || (e == 0);
10127         e_conv = DecodeError_clone(&e_conv);
10128         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10129         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
10130         return (uint64_t)ret_conv;
10131 }
10132
10133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10134         if ((_res & 1) != 0) return;
10135         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10136         FREE((void*)_res);
10137         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
10138 }
10139
10140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10141         LDKNodeFeatures o_conv;
10142         o_conv.inner = (void*)(o & (~1));
10143         o_conv.is_owned = (o & 1) || (o == 0);
10144         o_conv = NodeFeatures_clone(&o_conv);
10145         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10146         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
10147         return (uint64_t)ret_conv;
10148 }
10149
10150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10151         LDKDecodeError e_conv;
10152         e_conv.inner = (void*)(e & (~1));
10153         e_conv.is_owned = (e & 1) || (e == 0);
10154         e_conv = DecodeError_clone(&e_conv);
10155         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10156         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
10157         return (uint64_t)ret_conv;
10158 }
10159
10160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10161         if ((_res & 1) != 0) return;
10162         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10163         FREE((void*)_res);
10164         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
10165 }
10166
10167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10168         LDKChannelFeatures o_conv;
10169         o_conv.inner = (void*)(o & (~1));
10170         o_conv.is_owned = (o & 1) || (o == 0);
10171         o_conv = ChannelFeatures_clone(&o_conv);
10172         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10173         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
10174         return (uint64_t)ret_conv;
10175 }
10176
10177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10178         LDKDecodeError e_conv;
10179         e_conv.inner = (void*)(e & (~1));
10180         e_conv.is_owned = (e & 1) || (e == 0);
10181         e_conv = DecodeError_clone(&e_conv);
10182         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10183         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
10184         return (uint64_t)ret_conv;
10185 }
10186
10187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10188         if ((_res & 1) != 0) return;
10189         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10190         FREE((void*)_res);
10191         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
10192 }
10193
10194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10195         LDKInvoiceFeatures o_conv;
10196         o_conv.inner = (void*)(o & (~1));
10197         o_conv.is_owned = (o & 1) || (o == 0);
10198         o_conv = InvoiceFeatures_clone(&o_conv);
10199         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10200         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
10201         return (uint64_t)ret_conv;
10202 }
10203
10204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10205         LDKDecodeError e_conv;
10206         e_conv.inner = (void*)(e & (~1));
10207         e_conv.is_owned = (e & 1) || (e == 0);
10208         e_conv = DecodeError_clone(&e_conv);
10209         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10210         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10211         return (uint64_t)ret_conv;
10212 }
10213
10214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10215         if ((_res & 1) != 0) return;
10216         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10217         FREE((void*)_res);
10218         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10219 }
10220
10221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10222         LDKDelayedPaymentOutputDescriptor o_conv;
10223         o_conv.inner = (void*)(o & (~1));
10224         o_conv.is_owned = (o & 1) || (o == 0);
10225         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10226         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10227         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10228         return (uint64_t)ret_conv;
10229 }
10230
10231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10232         LDKDecodeError e_conv;
10233         e_conv.inner = (void*)(e & (~1));
10234         e_conv.is_owned = (e & 1) || (e == 0);
10235         e_conv = DecodeError_clone(&e_conv);
10236         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10237         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10238         return (uint64_t)ret_conv;
10239 }
10240
10241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10242         if ((_res & 1) != 0) return;
10243         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10244         FREE((void*)_res);
10245         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10246 }
10247
10248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10249         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10250         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10251         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10252         return (uint64_t)ret_conv;
10253 }
10254
10255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10256         LDKStaticPaymentOutputDescriptor o_conv;
10257         o_conv.inner = (void*)(o & (~1));
10258         o_conv.is_owned = (o & 1) || (o == 0);
10259         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10260         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10261         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10262         return (uint64_t)ret_conv;
10263 }
10264
10265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10266         LDKDecodeError e_conv;
10267         e_conv.inner = (void*)(e & (~1));
10268         e_conv.is_owned = (e & 1) || (e == 0);
10269         e_conv = DecodeError_clone(&e_conv);
10270         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10271         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10272         return (uint64_t)ret_conv;
10273 }
10274
10275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10276         if ((_res & 1) != 0) return;
10277         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10278         FREE((void*)_res);
10279         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10280 }
10281
10282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10283         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10284         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10285         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10286         return (uint64_t)ret_conv;
10287 }
10288
10289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10290         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10291         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10292         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10293         return (uint64_t)ret_conv;
10294 }
10295
10296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10297         LDKDecodeError e_conv;
10298         e_conv.inner = (void*)(e & (~1));
10299         e_conv.is_owned = (e & 1) || (e == 0);
10300         e_conv = DecodeError_clone(&e_conv);
10301         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10302         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10303         return (uint64_t)ret_conv;
10304 }
10305
10306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10307         if ((_res & 1) != 0) return;
10308         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10309         FREE((void*)_res);
10310         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10311 }
10312
10313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10314         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10315         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10316         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10317         return (uint64_t)ret_conv;
10318 }
10319
10320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10321         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10322         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10323         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10324         return (uint64_t)ret_ref;
10325 }
10326
10327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10328         LDKSignature a_ref;
10329         CHECK((*env)->GetArrayLength(env, a) == 64);
10330         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10331         LDKCVec_SignatureZ b_constr;
10332         b_constr.datalen = (*env)->GetArrayLength(env, b);
10333         if (b_constr.datalen > 0)
10334                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10335         else
10336                 b_constr.data = NULL;
10337         for (size_t i = 0; i < b_constr.datalen; i++) {
10338                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10339                 LDKSignature b_conv_8_ref;
10340                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10341                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10342                 b_constr.data[i] = b_conv_8_ref;
10343         }
10344         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10345         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10346         return (uint64_t)ret_ref;
10347 }
10348
10349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10350         if ((_res & 1) != 0) return;
10351         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10352         FREE((void*)_res);
10353         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10354 }
10355
10356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10357         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10358         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10359         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10360         return (uint64_t)ret_conv;
10361 }
10362
10363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10364         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10365         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10366         return (uint64_t)ret_conv;
10367 }
10368
10369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10370         if ((_res & 1) != 0) return;
10371         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10372         FREE((void*)_res);
10373         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10374 }
10375
10376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10377         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10378         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10379         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10380         return (uint64_t)ret_conv;
10381 }
10382
10383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10384         LDKSignature o_ref;
10385         CHECK((*env)->GetArrayLength(env, o) == 64);
10386         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10387         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10388         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10389         return (uint64_t)ret_conv;
10390 }
10391
10392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10393         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10394         *ret_conv = CResult_SignatureNoneZ_err();
10395         return (uint64_t)ret_conv;
10396 }
10397
10398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10399         if ((_res & 1) != 0) return;
10400         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10401         FREE((void*)_res);
10402         CResult_SignatureNoneZ_free(_res_conv);
10403 }
10404
10405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10406         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10407         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10408         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10409         return (uint64_t)ret_conv;
10410 }
10411
10412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10413         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10414         if (o_conv.free == LDKSign_JCalls_free) {
10415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10416                 LDKSign_JCalls_cloned(&o_conv);
10417         }
10418         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10419         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10420         return (uint64_t)ret_conv;
10421 }
10422
10423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10424         LDKDecodeError e_conv;
10425         e_conv.inner = (void*)(e & (~1));
10426         e_conv.is_owned = (e & 1) || (e == 0);
10427         e_conv = DecodeError_clone(&e_conv);
10428         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10429         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10430         return (uint64_t)ret_conv;
10431 }
10432
10433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10434         if ((_res & 1) != 0) return;
10435         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10436         FREE((void*)_res);
10437         CResult_SignDecodeErrorZ_free(_res_conv);
10438 }
10439
10440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10441         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10442         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10443         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10444         return (uint64_t)ret_conv;
10445 }
10446
10447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10448         LDKCVec_u8Z _res_ref;
10449         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10450         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10451         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10452         CVec_u8Z_free(_res_ref);
10453 }
10454
10455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10456         LDKRecoverableSignature arg_ref;
10457         CHECK((*env)->GetArrayLength(env, arg) == 68);
10458         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10459         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10460         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10461         return (uint64_t)ret_conv;
10462 }
10463
10464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10465         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10466         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10467         return (uint64_t)ret_conv;
10468 }
10469
10470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10471         if ((_res & 1) != 0) return;
10472         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10473         FREE((void*)_res);
10474         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10475 }
10476
10477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10478         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10479         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10480         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10481         return (uint64_t)ret_conv;
10482 }
10483
10484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10485         LDKCVec_CVec_u8ZZ _res_constr;
10486         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10487         if (_res_constr.datalen > 0)
10488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10489         else
10490                 _res_constr.data = NULL;
10491         for (size_t i = 0; i < _res_constr.datalen; i++) {
10492                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10493                 LDKCVec_u8Z _res_conv_8_ref;
10494                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10495                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10496                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10497                 _res_constr.data[i] = _res_conv_8_ref;
10498         }
10499         CVec_CVec_u8ZZ_free(_res_constr);
10500 }
10501
10502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10503         LDKCVec_CVec_u8ZZ o_constr;
10504         o_constr.datalen = (*env)->GetArrayLength(env, o);
10505         if (o_constr.datalen > 0)
10506                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10507         else
10508                 o_constr.data = NULL;
10509         for (size_t i = 0; i < o_constr.datalen; i++) {
10510                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10511                 LDKCVec_u8Z o_conv_8_ref;
10512                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10513                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10514                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10515                 o_constr.data[i] = o_conv_8_ref;
10516         }
10517         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10518         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10519         return (uint64_t)ret_conv;
10520 }
10521
10522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10523         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10524         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10525         return (uint64_t)ret_conv;
10526 }
10527
10528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10529         if ((_res & 1) != 0) return;
10530         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10531         FREE((void*)_res);
10532         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10533 }
10534
10535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10536         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10537         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10538         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10539         return (uint64_t)ret_conv;
10540 }
10541
10542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10543         LDKInMemorySigner o_conv;
10544         o_conv.inner = (void*)(o & (~1));
10545         o_conv.is_owned = (o & 1) || (o == 0);
10546         o_conv = InMemorySigner_clone(&o_conv);
10547         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10548         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10549         return (uint64_t)ret_conv;
10550 }
10551
10552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10553         LDKDecodeError e_conv;
10554         e_conv.inner = (void*)(e & (~1));
10555         e_conv.is_owned = (e & 1) || (e == 0);
10556         e_conv = DecodeError_clone(&e_conv);
10557         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10558         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10559         return (uint64_t)ret_conv;
10560 }
10561
10562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10563         if ((_res & 1) != 0) return;
10564         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10565         FREE((void*)_res);
10566         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10567 }
10568
10569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10570         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10571         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10572         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10573         return (uint64_t)ret_conv;
10574 }
10575
10576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10577         LDKCVec_TxOutZ _res_constr;
10578         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10579         if (_res_constr.datalen > 0)
10580                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10581         else
10582                 _res_constr.data = NULL;
10583         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10584         for (size_t h = 0; h < _res_constr.datalen; h++) {
10585                 int64_t _res_conv_7 = _res_vals[h];
10586                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10587                 FREE((void*)_res_conv_7);
10588                 _res_constr.data[h] = _res_conv_7_conv;
10589         }
10590         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10591         CVec_TxOutZ_free(_res_constr);
10592 }
10593
10594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10595         LDKTransaction o_ref;
10596         o_ref.datalen = (*env)->GetArrayLength(env, o);
10597         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10598         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10599         o_ref.data_is_owned = true;
10600         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10601         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10602         return (uint64_t)ret_conv;
10603 }
10604
10605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10606         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10607         *ret_conv = CResult_TransactionNoneZ_err();
10608         return (uint64_t)ret_conv;
10609 }
10610
10611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10612         if ((_res & 1) != 0) return;
10613         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10614         FREE((void*)_res);
10615         CResult_TransactionNoneZ_free(_res_conv);
10616 }
10617
10618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10619         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10620         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10621         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10622         return (uint64_t)ret_conv;
10623 }
10624
10625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10626         LDKThirtyTwoBytes a_ref;
10627         CHECK((*env)->GetArrayLength(env, a) == 32);
10628         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10629         LDKChannelMonitor b_conv;
10630         b_conv.inner = (void*)(b & (~1));
10631         b_conv.is_owned = (b & 1) || (b == 0);
10632         b_conv = ChannelMonitor_clone(&b_conv);
10633         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10634         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10635         return (uint64_t)ret_ref;
10636 }
10637
10638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10639         if ((_res & 1) != 0) return;
10640         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10641         FREE((void*)_res);
10642         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10643 }
10644
10645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10646         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10647         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10648         if (_res_constr.datalen > 0)
10649                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10650         else
10651                 _res_constr.data = NULL;
10652         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10653         for (size_t i = 0; i < _res_constr.datalen; i++) {
10654                 int64_t _res_conv_34 = _res_vals[i];
10655                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10656                 FREE((void*)_res_conv_34);
10657                 _res_constr.data[i] = _res_conv_34_conv;
10658         }
10659         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10660         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10661 }
10662
10663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10664         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10665         o_constr.datalen = (*env)->GetArrayLength(env, o);
10666         if (o_constr.datalen > 0)
10667                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10668         else
10669                 o_constr.data = NULL;
10670         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10671         for (size_t i = 0; i < o_constr.datalen; i++) {
10672                 int64_t o_conv_34 = o_vals[i];
10673                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10674                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10675                 o_constr.data[i] = o_conv_34_conv;
10676         }
10677         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10678         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10679         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10680         return (uint64_t)ret_conv;
10681 }
10682
10683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10684         LDKIOError e_conv = LDKIOError_from_java(env, e);
10685         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10686         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10687         return (uint64_t)ret_conv;
10688 }
10689
10690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10691         if ((_res & 1) != 0) return;
10692         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10693         FREE((void*)_res);
10694         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10695 }
10696
10697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10698         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10699         *ret_copy = COption_u16Z_some(o);
10700         uint64_t ret_ref = (uint64_t)ret_copy;
10701         return ret_ref;
10702 }
10703
10704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10705         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10706         *ret_copy = COption_u16Z_none();
10707         uint64_t ret_ref = (uint64_t)ret_copy;
10708         return ret_ref;
10709 }
10710
10711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10712         if ((_res & 1) != 0) return;
10713         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10714         FREE((void*)_res);
10715         COption_u16Z_free(_res_conv);
10716 }
10717
10718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10719         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10720         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10721         *ret_copy = COption_u16Z_clone(orig_conv);
10722         uint64_t ret_ref = (uint64_t)ret_copy;
10723         return ret_ref;
10724 }
10725
10726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10727         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10728         *ret_conv = CResult_NoneAPIErrorZ_ok();
10729         return (uint64_t)ret_conv;
10730 }
10731
10732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10733         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10734         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10735         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10736         return (uint64_t)ret_conv;
10737 }
10738
10739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10740         if ((_res & 1) != 0) return;
10741         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10742         FREE((void*)_res);
10743         CResult_NoneAPIErrorZ_free(_res_conv);
10744 }
10745
10746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10747         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10748         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10749         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10750         return (uint64_t)ret_conv;
10751 }
10752
10753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10754         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10755         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10756         if (_res_constr.datalen > 0)
10757                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10758         else
10759                 _res_constr.data = NULL;
10760         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10761         for (size_t w = 0; w < _res_constr.datalen; w++) {
10762                 int64_t _res_conv_22 = _res_vals[w];
10763                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10764                 FREE((void*)_res_conv_22);
10765                 _res_constr.data[w] = _res_conv_22_conv;
10766         }
10767         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10768         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10769 }
10770
10771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10772         LDKCVec_APIErrorZ _res_constr;
10773         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10774         if (_res_constr.datalen > 0)
10775                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10776         else
10777                 _res_constr.data = NULL;
10778         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10779         for (size_t k = 0; k < _res_constr.datalen; k++) {
10780                 int64_t _res_conv_10 = _res_vals[k];
10781                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10782                 FREE((void*)_res_conv_10);
10783                 _res_constr.data[k] = _res_conv_10_conv;
10784         }
10785         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10786         CVec_APIErrorZ_free(_res_constr);
10787 }
10788
10789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10790         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10791         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10792         return (uint64_t)ret_conv;
10793 }
10794
10795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10796         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10797         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10798         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10799         return (uint64_t)ret_conv;
10800 }
10801
10802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10803         if ((_res & 1) != 0) return;
10804         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10805         FREE((void*)_res);
10806         CResult_NonePaymentSendFailureZ_free(_res_conv);
10807 }
10808
10809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10810         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10811         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10812         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10813         return (uint64_t)ret_conv;
10814 }
10815
10816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10817         LDKThirtyTwoBytes o_ref;
10818         CHECK((*env)->GetArrayLength(env, o) == 32);
10819         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10820         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10821         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
10822         return (uint64_t)ret_conv;
10823 }
10824
10825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10826         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10827         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10828         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
10829         return (uint64_t)ret_conv;
10830 }
10831
10832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10833         if ((_res & 1) != 0) return;
10834         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10835         FREE((void*)_res);
10836         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
10837 }
10838
10839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10840         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
10841         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10842         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
10843         return (uint64_t)ret_conv;
10844 }
10845
10846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10847         LDKCVec_NetAddressZ _res_constr;
10848         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10849         if (_res_constr.datalen > 0)
10850                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10851         else
10852                 _res_constr.data = NULL;
10853         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10854         for (size_t m = 0; m < _res_constr.datalen; m++) {
10855                 int64_t _res_conv_12 = _res_vals[m];
10856                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10857                 FREE((void*)_res_conv_12);
10858                 _res_constr.data[m] = _res_conv_12_conv;
10859         }
10860         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10861         CVec_NetAddressZ_free(_res_constr);
10862 }
10863
10864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10865         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10866         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10867         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10868         return (uint64_t)ret_ref;
10869 }
10870
10871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10872         LDKThirtyTwoBytes a_ref;
10873         CHECK((*env)->GetArrayLength(env, a) == 32);
10874         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10875         LDKThirtyTwoBytes b_ref;
10876         CHECK((*env)->GetArrayLength(env, b) == 32);
10877         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10878         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10879         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10880         return (uint64_t)ret_ref;
10881 }
10882
10883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10884         if ((_res & 1) != 0) return;
10885         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10886         FREE((void*)_res);
10887         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10888 }
10889
10890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10891         LDKThirtyTwoBytes o_ref;
10892         CHECK((*env)->GetArrayLength(env, o) == 32);
10893         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10894         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10895         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10896         return (uint64_t)ret_conv;
10897 }
10898
10899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10900         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10901         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10902         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10903         return (uint64_t)ret_conv;
10904 }
10905
10906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10907         if ((_res & 1) != 0) return;
10908         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10909         FREE((void*)_res);
10910         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10911 }
10912
10913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10914         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10915         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10916         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10917         return (uint64_t)ret_conv;
10918 }
10919
10920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10921         LDKCVec_ChannelMonitorZ _res_constr;
10922         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10923         if (_res_constr.datalen > 0)
10924                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10925         else
10926                 _res_constr.data = NULL;
10927         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10928         for (size_t q = 0; q < _res_constr.datalen; q++) {
10929                 int64_t _res_conv_16 = _res_vals[q];
10930                 LDKChannelMonitor _res_conv_16_conv;
10931                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10932                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10933                 _res_constr.data[q] = _res_conv_16_conv;
10934         }
10935         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10936         CVec_ChannelMonitorZ_free(_res_constr);
10937 }
10938
10939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10940         LDKThirtyTwoBytes a_ref;
10941         CHECK((*env)->GetArrayLength(env, a) == 32);
10942         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10943         LDKChannelManager b_conv;
10944         b_conv.inner = (void*)(b & (~1));
10945         b_conv.is_owned = (b & 1) || (b == 0);
10946         // Warning: we need a move here but no clone is available for LDKChannelManager
10947         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10948         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10949         return (uint64_t)ret_ref;
10950 }
10951
10952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10953         if ((_res & 1) != 0) return;
10954         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10955         FREE((void*)_res);
10956         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10957 }
10958
10959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10960         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10961         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10962         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10963         return (uint64_t)ret_conv;
10964 }
10965
10966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10967         LDKDecodeError e_conv;
10968         e_conv.inner = (void*)(e & (~1));
10969         e_conv.is_owned = (e & 1) || (e == 0);
10970         e_conv = DecodeError_clone(&e_conv);
10971         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10972         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10973         return (uint64_t)ret_conv;
10974 }
10975
10976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10977         if ((_res & 1) != 0) return;
10978         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10979         FREE((void*)_res);
10980         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10981 }
10982
10983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10984         LDKChannelConfig o_conv;
10985         o_conv.inner = (void*)(o & (~1));
10986         o_conv.is_owned = (o & 1) || (o == 0);
10987         o_conv = ChannelConfig_clone(&o_conv);
10988         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10989         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10990         return (uint64_t)ret_conv;
10991 }
10992
10993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10994         LDKDecodeError e_conv;
10995         e_conv.inner = (void*)(e & (~1));
10996         e_conv.is_owned = (e & 1) || (e == 0);
10997         e_conv = DecodeError_clone(&e_conv);
10998         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10999         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
11000         return (uint64_t)ret_conv;
11001 }
11002
11003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11004         if ((_res & 1) != 0) return;
11005         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
11006         FREE((void*)_res);
11007         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
11008 }
11009
11010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11011         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
11012         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11013         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
11014         return (uint64_t)ret_conv;
11015 }
11016
11017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11018         LDKOutPoint o_conv;
11019         o_conv.inner = (void*)(o & (~1));
11020         o_conv.is_owned = (o & 1) || (o == 0);
11021         o_conv = OutPoint_clone(&o_conv);
11022         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11023         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
11024         return (uint64_t)ret_conv;
11025 }
11026
11027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11028         LDKDecodeError e_conv;
11029         e_conv.inner = (void*)(e & (~1));
11030         e_conv.is_owned = (e & 1) || (e == 0);
11031         e_conv = DecodeError_clone(&e_conv);
11032         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11033         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
11034         return (uint64_t)ret_conv;
11035 }
11036
11037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11038         if ((_res & 1) != 0) return;
11039         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
11040         FREE((void*)_res);
11041         CResult_OutPointDecodeErrorZ_free(_res_conv);
11042 }
11043
11044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11045         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
11046         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11047         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
11048         return (uint64_t)ret_conv;
11049 }
11050
11051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
11052         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
11053         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11054         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
11055         return (uint64_t)ret_conv;
11056 }
11057
11058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
11059         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11060         *ret_conv = CResult_SiPrefixNoneZ_err();
11061         return (uint64_t)ret_conv;
11062 }
11063
11064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11065         if ((_res & 1) != 0) return;
11066         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
11067         FREE((void*)_res);
11068         CResult_SiPrefixNoneZ_free(_res_conv);
11069 }
11070
11071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11072         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
11073         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11074         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
11075         return (uint64_t)ret_conv;
11076 }
11077
11078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11079         LDKInvoice o_conv;
11080         o_conv.inner = (void*)(o & (~1));
11081         o_conv.is_owned = (o & 1) || (o == 0);
11082         o_conv = Invoice_clone(&o_conv);
11083         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11084         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
11085         return (uint64_t)ret_conv;
11086 }
11087
11088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11089         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11090         *ret_conv = CResult_InvoiceNoneZ_err();
11091         return (uint64_t)ret_conv;
11092 }
11093
11094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11095         if ((_res & 1) != 0) return;
11096         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
11097         FREE((void*)_res);
11098         CResult_InvoiceNoneZ_free(_res_conv);
11099 }
11100
11101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11102         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
11103         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11104         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
11105         return (uint64_t)ret_conv;
11106 }
11107
11108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11109         LDKSignedRawInvoice o_conv;
11110         o_conv.inner = (void*)(o & (~1));
11111         o_conv.is_owned = (o & 1) || (o == 0);
11112         o_conv = SignedRawInvoice_clone(&o_conv);
11113         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11114         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
11115         return (uint64_t)ret_conv;
11116 }
11117
11118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11119         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11120         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
11121         return (uint64_t)ret_conv;
11122 }
11123
11124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11125         if ((_res & 1) != 0) return;
11126         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
11127         FREE((void*)_res);
11128         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
11129 }
11130
11131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11132         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
11133         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11134         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
11135         return (uint64_t)ret_conv;
11136 }
11137
11138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11139         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
11140         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11141         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
11142         return (uint64_t)ret_ref;
11143 }
11144
11145 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) {
11146         LDKRawInvoice a_conv;
11147         a_conv.inner = (void*)(a & (~1));
11148         a_conv.is_owned = (a & 1) || (a == 0);
11149         a_conv = RawInvoice_clone(&a_conv);
11150         LDKThirtyTwoBytes b_ref;
11151         CHECK((*env)->GetArrayLength(env, b) == 32);
11152         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
11153         LDKInvoiceSignature c_conv;
11154         c_conv.inner = (void*)(c & (~1));
11155         c_conv.is_owned = (c & 1) || (c == 0);
11156         c_conv = InvoiceSignature_clone(&c_conv);
11157         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11158         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
11159         return (uint64_t)ret_ref;
11160 }
11161
11162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11163         if ((_res & 1) != 0) return;
11164         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
11165         FREE((void*)_res);
11166         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
11167 }
11168
11169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11170         LDKPayeePubKey o_conv;
11171         o_conv.inner = (void*)(o & (~1));
11172         o_conv.is_owned = (o & 1) || (o == 0);
11173         o_conv = PayeePubKey_clone(&o_conv);
11174         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11175         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
11176         return (uint64_t)ret_conv;
11177 }
11178
11179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11180         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11181         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11182         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
11183         return (uint64_t)ret_conv;
11184 }
11185
11186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11187         if ((_res & 1) != 0) return;
11188         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
11189         FREE((void*)_res);
11190         CResult_PayeePubKeyErrorZ_free(_res_conv);
11191 }
11192
11193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11194         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
11195         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11196         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
11197         return (uint64_t)ret_conv;
11198 }
11199
11200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11201         LDKCVec_PrivateRouteZ _res_constr;
11202         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11203         if (_res_constr.datalen > 0)
11204                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
11205         else
11206                 _res_constr.data = NULL;
11207         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11208         for (size_t o = 0; o < _res_constr.datalen; o++) {
11209                 int64_t _res_conv_14 = _res_vals[o];
11210                 LDKPrivateRoute _res_conv_14_conv;
11211                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11212                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11213                 _res_constr.data[o] = _res_conv_14_conv;
11214         }
11215         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11216         CVec_PrivateRouteZ_free(_res_constr);
11217 }
11218
11219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11220         LDKPositiveTimestamp o_conv;
11221         o_conv.inner = (void*)(o & (~1));
11222         o_conv.is_owned = (o & 1) || (o == 0);
11223         o_conv = PositiveTimestamp_clone(&o_conv);
11224         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11225         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
11226         return (uint64_t)ret_conv;
11227 }
11228
11229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11230         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11231         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11232         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
11233         return (uint64_t)ret_conv;
11234 }
11235
11236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11237         if ((_res & 1) != 0) return;
11238         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
11239         FREE((void*)_res);
11240         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11241 }
11242
11243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11244         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11245         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11246         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11247         return (uint64_t)ret_conv;
11248 }
11249
11250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
11251         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11252         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11253         return (uint64_t)ret_conv;
11254 }
11255
11256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11257         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11258         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11259         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11260         return (uint64_t)ret_conv;
11261 }
11262
11263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11264         if ((_res & 1) != 0) return;
11265         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11266         FREE((void*)_res);
11267         CResult_NoneSemanticErrorZ_free(_res_conv);
11268 }
11269
11270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11271         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11272         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11273         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11274         return (uint64_t)ret_conv;
11275 }
11276
11277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11278         LDKInvoice o_conv;
11279         o_conv.inner = (void*)(o & (~1));
11280         o_conv.is_owned = (o & 1) || (o == 0);
11281         o_conv = Invoice_clone(&o_conv);
11282         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11283         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11284         return (uint64_t)ret_conv;
11285 }
11286
11287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11288         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11289         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11290         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11291         return (uint64_t)ret_conv;
11292 }
11293
11294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11295         if ((_res & 1) != 0) return;
11296         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11297         FREE((void*)_res);
11298         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11299 }
11300
11301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11302         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11303         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11304         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11305         return (uint64_t)ret_conv;
11306 }
11307
11308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11309         LDKDescription o_conv;
11310         o_conv.inner = (void*)(o & (~1));
11311         o_conv.is_owned = (o & 1) || (o == 0);
11312         o_conv = Description_clone(&o_conv);
11313         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11314         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11315         return (uint64_t)ret_conv;
11316 }
11317
11318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11319         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11320         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11321         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11322         return (uint64_t)ret_conv;
11323 }
11324
11325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11326         if ((_res & 1) != 0) return;
11327         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11328         FREE((void*)_res);
11329         CResult_DescriptionCreationErrorZ_free(_res_conv);
11330 }
11331
11332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11333         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11334         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11335         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11336         return (uint64_t)ret_conv;
11337 }
11338
11339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11340         LDKExpiryTime o_conv;
11341         o_conv.inner = (void*)(o & (~1));
11342         o_conv.is_owned = (o & 1) || (o == 0);
11343         o_conv = ExpiryTime_clone(&o_conv);
11344         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11345         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11346         return (uint64_t)ret_conv;
11347 }
11348
11349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11350         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11351         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11352         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11353         return (uint64_t)ret_conv;
11354 }
11355
11356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11357         if ((_res & 1) != 0) return;
11358         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11359         FREE((void*)_res);
11360         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11361 }
11362
11363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11364         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11365         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11366         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11367         return (uint64_t)ret_conv;
11368 }
11369
11370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11371         LDKPrivateRoute o_conv;
11372         o_conv.inner = (void*)(o & (~1));
11373         o_conv.is_owned = (o & 1) || (o == 0);
11374         o_conv = PrivateRoute_clone(&o_conv);
11375         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11376         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11377         return (uint64_t)ret_conv;
11378 }
11379
11380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11381         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11382         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11383         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11384         return (uint64_t)ret_conv;
11385 }
11386
11387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11388         if ((_res & 1) != 0) return;
11389         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11390         FREE((void*)_res);
11391         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11392 }
11393
11394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11395         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11396         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11397         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11398         return (uint64_t)ret_conv;
11399 }
11400
11401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11402         LDKStr o_conv = java_to_owned_str(env, o);
11403         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11404         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11405         return (uint64_t)ret_conv;
11406 }
11407
11408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11409         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11410         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11411         *ret_conv = CResult_StringErrorZ_err(e_conv);
11412         return (uint64_t)ret_conv;
11413 }
11414
11415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11416         if ((_res & 1) != 0) return;
11417         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11418         FREE((void*)_res);
11419         CResult_StringErrorZ_free(_res_conv);
11420 }
11421
11422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11423         LDKChannelMonitorUpdate o_conv;
11424         o_conv.inner = (void*)(o & (~1));
11425         o_conv.is_owned = (o & 1) || (o == 0);
11426         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11427         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11428         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11429         return (uint64_t)ret_conv;
11430 }
11431
11432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11433         LDKDecodeError e_conv;
11434         e_conv.inner = (void*)(e & (~1));
11435         e_conv.is_owned = (e & 1) || (e == 0);
11436         e_conv = DecodeError_clone(&e_conv);
11437         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11438         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11439         return (uint64_t)ret_conv;
11440 }
11441
11442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11443         if ((_res & 1) != 0) return;
11444         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11445         FREE((void*)_res);
11446         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11447 }
11448
11449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11450         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11451         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11452         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11453         return (uint64_t)ret_conv;
11454 }
11455
11456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11457         LDKHTLCUpdate o_conv;
11458         o_conv.inner = (void*)(o & (~1));
11459         o_conv.is_owned = (o & 1) || (o == 0);
11460         o_conv = HTLCUpdate_clone(&o_conv);
11461         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11462         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11463         return (uint64_t)ret_conv;
11464 }
11465
11466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11467         LDKDecodeError e_conv;
11468         e_conv.inner = (void*)(e & (~1));
11469         e_conv.is_owned = (e & 1) || (e == 0);
11470         e_conv = DecodeError_clone(&e_conv);
11471         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11472         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11473         return (uint64_t)ret_conv;
11474 }
11475
11476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11477         if ((_res & 1) != 0) return;
11478         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11479         FREE((void*)_res);
11480         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11481 }
11482
11483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11484         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11485         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11486         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11487         return (uint64_t)ret_conv;
11488 }
11489
11490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11491         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11492         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11493         return (uint64_t)ret_conv;
11494 }
11495
11496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11497         LDKMonitorUpdateError e_conv;
11498         e_conv.inner = (void*)(e & (~1));
11499         e_conv.is_owned = (e & 1) || (e == 0);
11500         e_conv = MonitorUpdateError_clone(&e_conv);
11501         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11502         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11503         return (uint64_t)ret_conv;
11504 }
11505
11506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11507         if ((_res & 1) != 0) return;
11508         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11509         FREE((void*)_res);
11510         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11511 }
11512
11513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11514         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11515         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11516         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11517         return (uint64_t)ret_conv;
11518 }
11519
11520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11521         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11522         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11523         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11524         return (uint64_t)ret_ref;
11525 }
11526
11527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11528         LDKOutPoint a_conv;
11529         a_conv.inner = (void*)(a & (~1));
11530         a_conv.is_owned = (a & 1) || (a == 0);
11531         a_conv = OutPoint_clone(&a_conv);
11532         LDKCVec_u8Z b_ref;
11533         b_ref.datalen = (*env)->GetArrayLength(env, b);
11534         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11535         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11536         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11537         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11538         return (uint64_t)ret_ref;
11539 }
11540
11541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11542         if ((_res & 1) != 0) return;
11543         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11544         FREE((void*)_res);
11545         C2Tuple_OutPointScriptZ_free(_res_conv);
11546 }
11547
11548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11549         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11550         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11551         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11552         return (uint64_t)ret_ref;
11553 }
11554
11555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11556         LDKCVec_u8Z b_ref;
11557         b_ref.datalen = (*env)->GetArrayLength(env, b);
11558         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11559         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11560         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11561         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11562         return (uint64_t)ret_ref;
11563 }
11564
11565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11566         if ((_res & 1) != 0) return;
11567         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11568         FREE((void*)_res);
11569         C2Tuple_u32ScriptZ_free(_res_conv);
11570 }
11571
11572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11573         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11574         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11575         if (_res_constr.datalen > 0)
11576                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11577         else
11578                 _res_constr.data = NULL;
11579         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11580         for (size_t b = 0; b < _res_constr.datalen; b++) {
11581                 int64_t _res_conv_27 = _res_vals[b];
11582                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11583                 FREE((void*)_res_conv_27);
11584                 _res_constr.data[b] = _res_conv_27_conv;
11585         }
11586         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11587         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11588 }
11589
11590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11591         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11592         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11593         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11594         return (uint64_t)ret_ref;
11595 }
11596
11597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11598         LDKThirtyTwoBytes a_ref;
11599         CHECK((*env)->GetArrayLength(env, a) == 32);
11600         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11601         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11602         b_constr.datalen = (*env)->GetArrayLength(env, b);
11603         if (b_constr.datalen > 0)
11604                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11605         else
11606                 b_constr.data = NULL;
11607         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11608         for (size_t b = 0; b < b_constr.datalen; b++) {
11609                 int64_t b_conv_27 = b_vals[b];
11610                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11611                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11612                 b_constr.data[b] = b_conv_27_conv;
11613         }
11614         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11615         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11616         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11617         return (uint64_t)ret_ref;
11618 }
11619
11620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11621         if ((_res & 1) != 0) return;
11622         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11623         FREE((void*)_res);
11624         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11625 }
11626
11627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11628         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11629         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11630         if (_res_constr.datalen > 0)
11631                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11632         else
11633                 _res_constr.data = NULL;
11634         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11635         for (size_t v = 0; v < _res_constr.datalen; v++) {
11636                 int64_t _res_conv_47 = _res_vals[v];
11637                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11638                 FREE((void*)_res_conv_47);
11639                 _res_constr.data[v] = _res_conv_47_conv;
11640         }
11641         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11642         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11643 }
11644
11645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11646         LDKCVec_EventZ _res_constr;
11647         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11648         if (_res_constr.datalen > 0)
11649                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11650         else
11651                 _res_constr.data = NULL;
11652         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11653         for (size_t h = 0; h < _res_constr.datalen; h++) {
11654                 int64_t _res_conv_7 = _res_vals[h];
11655                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11656                 FREE((void*)_res_conv_7);
11657                 _res_constr.data[h] = _res_conv_7_conv;
11658         }
11659         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11660         CVec_EventZ_free(_res_constr);
11661 }
11662
11663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11664         LDKCVec_TransactionZ _res_constr;
11665         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11666         if (_res_constr.datalen > 0)
11667                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11668         else
11669                 _res_constr.data = NULL;
11670         for (size_t i = 0; i < _res_constr.datalen; i++) {
11671                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11672                 LDKTransaction _res_conv_8_ref;
11673                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11674                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11675                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11676                 _res_conv_8_ref.data_is_owned = true;
11677                 _res_constr.data[i] = _res_conv_8_ref;
11678         }
11679         CVec_TransactionZ_free(_res_constr);
11680 }
11681
11682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11683         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11684         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11685         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11686         return (uint64_t)ret_ref;
11687 }
11688
11689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11690         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11691         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11692         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11693         return (uint64_t)ret_ref;
11694 }
11695
11696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11697         if ((_res & 1) != 0) return;
11698         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11699         FREE((void*)_res);
11700         C2Tuple_u32TxOutZ_free(_res_conv);
11701 }
11702
11703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11704         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11705         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11706         if (_res_constr.datalen > 0)
11707                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11708         else
11709                 _res_constr.data = NULL;
11710         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11711         for (size_t a = 0; a < _res_constr.datalen; a++) {
11712                 int64_t _res_conv_26 = _res_vals[a];
11713                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11714                 FREE((void*)_res_conv_26);
11715                 _res_constr.data[a] = _res_conv_26_conv;
11716         }
11717         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11718         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11719 }
11720
11721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11722         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11723         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11724         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11725         return (uint64_t)ret_ref;
11726 }
11727
11728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11729         LDKThirtyTwoBytes a_ref;
11730         CHECK((*env)->GetArrayLength(env, a) == 32);
11731         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11732         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11733         b_constr.datalen = (*env)->GetArrayLength(env, b);
11734         if (b_constr.datalen > 0)
11735                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11736         else
11737                 b_constr.data = NULL;
11738         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11739         for (size_t a = 0; a < b_constr.datalen; a++) {
11740                 int64_t b_conv_26 = b_vals[a];
11741                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11742                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11743                 b_constr.data[a] = b_conv_26_conv;
11744         }
11745         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11746         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11747         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11748         return (uint64_t)ret_ref;
11749 }
11750
11751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11752         if ((_res & 1) != 0) return;
11753         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11754         FREE((void*)_res);
11755         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11756 }
11757
11758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11759         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11760         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11761         if (_res_constr.datalen > 0)
11762                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11763         else
11764                 _res_constr.data = NULL;
11765         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11766         for (size_t u = 0; u < _res_constr.datalen; u++) {
11767                 int64_t _res_conv_46 = _res_vals[u];
11768                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11769                 FREE((void*)_res_conv_46);
11770                 _res_constr.data[u] = _res_conv_46_conv;
11771         }
11772         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11773         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11774 }
11775
11776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11777         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11778         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11779         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11780         return (uint64_t)ret_conv;
11781 }
11782
11783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11784         LDKDecodeError e_conv;
11785         e_conv.inner = (void*)(e & (~1));
11786         e_conv.is_owned = (e & 1) || (e == 0);
11787         e_conv = DecodeError_clone(&e_conv);
11788         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11789         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11790         return (uint64_t)ret_conv;
11791 }
11792
11793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11794         if ((_res & 1) != 0) return;
11795         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11796         FREE((void*)_res);
11797         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11798 }
11799
11800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11801         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11802         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11803         return (uint64_t)ret_conv;
11804 }
11805
11806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11807         LDKLightningError e_conv;
11808         e_conv.inner = (void*)(e & (~1));
11809         e_conv.is_owned = (e & 1) || (e == 0);
11810         e_conv = LightningError_clone(&e_conv);
11811         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11812         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11813         return (uint64_t)ret_conv;
11814 }
11815
11816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11817         if ((_res & 1) != 0) return;
11818         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11819         FREE((void*)_res);
11820         CResult_boolLightningErrorZ_free(_res_conv);
11821 }
11822
11823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11824         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11825         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11826         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11827         return (uint64_t)ret_conv;
11828 }
11829
11830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11831         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11832         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11833         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11834         return (uint64_t)ret_ref;
11835 }
11836
11837 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) {
11838         LDKChannelAnnouncement a_conv;
11839         a_conv.inner = (void*)(a & (~1));
11840         a_conv.is_owned = (a & 1) || (a == 0);
11841         a_conv = ChannelAnnouncement_clone(&a_conv);
11842         LDKChannelUpdate b_conv;
11843         b_conv.inner = (void*)(b & (~1));
11844         b_conv.is_owned = (b & 1) || (b == 0);
11845         b_conv = ChannelUpdate_clone(&b_conv);
11846         LDKChannelUpdate c_conv;
11847         c_conv.inner = (void*)(c & (~1));
11848         c_conv.is_owned = (c & 1) || (c == 0);
11849         c_conv = ChannelUpdate_clone(&c_conv);
11850         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11851         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11852         return (uint64_t)ret_ref;
11853 }
11854
11855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11856         if ((_res & 1) != 0) return;
11857         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11858         FREE((void*)_res);
11859         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11860 }
11861
11862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11863         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11864         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11865         if (_res_constr.datalen > 0)
11866                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11867         else
11868                 _res_constr.data = NULL;
11869         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11870         for (size_t l = 0; l < _res_constr.datalen; l++) {
11871                 int64_t _res_conv_63 = _res_vals[l];
11872                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11873                 FREE((void*)_res_conv_63);
11874                 _res_constr.data[l] = _res_conv_63_conv;
11875         }
11876         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11877         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11878 }
11879
11880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11881         LDKCVec_NodeAnnouncementZ _res_constr;
11882         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11883         if (_res_constr.datalen > 0)
11884                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11885         else
11886                 _res_constr.data = NULL;
11887         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11888         for (size_t s = 0; s < _res_constr.datalen; s++) {
11889                 int64_t _res_conv_18 = _res_vals[s];
11890                 LDKNodeAnnouncement _res_conv_18_conv;
11891                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11892                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11893                 _res_constr.data[s] = _res_conv_18_conv;
11894         }
11895         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11896         CVec_NodeAnnouncementZ_free(_res_constr);
11897 }
11898
11899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11900         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11901         *ret_conv = CResult_NoneLightningErrorZ_ok();
11902         return (uint64_t)ret_conv;
11903 }
11904
11905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11906         LDKLightningError e_conv;
11907         e_conv.inner = (void*)(e & (~1));
11908         e_conv.is_owned = (e & 1) || (e == 0);
11909         e_conv = LightningError_clone(&e_conv);
11910         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11911         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11912         return (uint64_t)ret_conv;
11913 }
11914
11915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11916         if ((_res & 1) != 0) return;
11917         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11918         FREE((void*)_res);
11919         CResult_NoneLightningErrorZ_free(_res_conv);
11920 }
11921
11922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11923         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11924         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11925         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11926         return (uint64_t)ret_conv;
11927 }
11928
11929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11930         LDKCVec_PublicKeyZ _res_constr;
11931         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11932         if (_res_constr.datalen > 0)
11933                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11934         else
11935                 _res_constr.data = NULL;
11936         for (size_t i = 0; i < _res_constr.datalen; i++) {
11937                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11938                 LDKPublicKey _res_conv_8_ref;
11939                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11940                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11941                 _res_constr.data[i] = _res_conv_8_ref;
11942         }
11943         CVec_PublicKeyZ_free(_res_constr);
11944 }
11945
11946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11947         LDKCVec_u8Z o_ref;
11948         o_ref.datalen = (*env)->GetArrayLength(env, o);
11949         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11950         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11951         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11952         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11953         return (uint64_t)ret_conv;
11954 }
11955
11956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11957         LDKPeerHandleError e_conv;
11958         e_conv.inner = (void*)(e & (~1));
11959         e_conv.is_owned = (e & 1) || (e == 0);
11960         e_conv = PeerHandleError_clone(&e_conv);
11961         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11962         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11963         return (uint64_t)ret_conv;
11964 }
11965
11966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11967         if ((_res & 1) != 0) return;
11968         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11969         FREE((void*)_res);
11970         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11971 }
11972
11973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11974         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11975         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11976         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11977         return (uint64_t)ret_conv;
11978 }
11979
11980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11981         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11982         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11983         return (uint64_t)ret_conv;
11984 }
11985
11986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11987         LDKPeerHandleError e_conv;
11988         e_conv.inner = (void*)(e & (~1));
11989         e_conv.is_owned = (e & 1) || (e == 0);
11990         e_conv = PeerHandleError_clone(&e_conv);
11991         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11992         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11993         return (uint64_t)ret_conv;
11994 }
11995
11996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11997         if ((_res & 1) != 0) return;
11998         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11999         FREE((void*)_res);
12000         CResult_NonePeerHandleErrorZ_free(_res_conv);
12001 }
12002
12003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12004         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
12005         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12006         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
12007         return (uint64_t)ret_conv;
12008 }
12009
12010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
12011         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12012         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
12013         return (uint64_t)ret_conv;
12014 }
12015
12016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12017         LDKPeerHandleError e_conv;
12018         e_conv.inner = (void*)(e & (~1));
12019         e_conv.is_owned = (e & 1) || (e == 0);
12020         e_conv = PeerHandleError_clone(&e_conv);
12021         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12022         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
12023         return (uint64_t)ret_conv;
12024 }
12025
12026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12027         if ((_res & 1) != 0) return;
12028         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
12029         FREE((void*)_res);
12030         CResult_boolPeerHandleErrorZ_free(_res_conv);
12031 }
12032
12033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12034         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
12035         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12036         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
12037         return (uint64_t)ret_conv;
12038 }
12039
12040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12041         LDKDirectionalChannelInfo o_conv;
12042         o_conv.inner = (void*)(o & (~1));
12043         o_conv.is_owned = (o & 1) || (o == 0);
12044         o_conv = DirectionalChannelInfo_clone(&o_conv);
12045         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12046         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
12047         return (uint64_t)ret_conv;
12048 }
12049
12050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12051         LDKDecodeError e_conv;
12052         e_conv.inner = (void*)(e & (~1));
12053         e_conv.is_owned = (e & 1) || (e == 0);
12054         e_conv = DecodeError_clone(&e_conv);
12055         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12056         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12057         return (uint64_t)ret_conv;
12058 }
12059
12060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12061         if ((_res & 1) != 0) return;
12062         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12063         FREE((void*)_res);
12064         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12065 }
12066
12067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12068         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12069         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12070         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12071         return (uint64_t)ret_conv;
12072 }
12073
12074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12075         LDKChannelInfo o_conv;
12076         o_conv.inner = (void*)(o & (~1));
12077         o_conv.is_owned = (o & 1) || (o == 0);
12078         o_conv = ChannelInfo_clone(&o_conv);
12079         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12080         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12081         return (uint64_t)ret_conv;
12082 }
12083
12084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12085         LDKDecodeError e_conv;
12086         e_conv.inner = (void*)(e & (~1));
12087         e_conv.is_owned = (e & 1) || (e == 0);
12088         e_conv = DecodeError_clone(&e_conv);
12089         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12090         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12091         return (uint64_t)ret_conv;
12092 }
12093
12094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12095         if ((_res & 1) != 0) return;
12096         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12097         FREE((void*)_res);
12098         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12099 }
12100
12101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12102         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12103         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12104         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12105         return (uint64_t)ret_conv;
12106 }
12107
12108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12109         LDKRoutingFees o_conv;
12110         o_conv.inner = (void*)(o & (~1));
12111         o_conv.is_owned = (o & 1) || (o == 0);
12112         o_conv = RoutingFees_clone(&o_conv);
12113         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12114         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12115         return (uint64_t)ret_conv;
12116 }
12117
12118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12119         LDKDecodeError e_conv;
12120         e_conv.inner = (void*)(e & (~1));
12121         e_conv.is_owned = (e & 1) || (e == 0);
12122         e_conv = DecodeError_clone(&e_conv);
12123         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12124         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12125         return (uint64_t)ret_conv;
12126 }
12127
12128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12129         if ((_res & 1) != 0) return;
12130         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12131         FREE((void*)_res);
12132         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12133 }
12134
12135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12136         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12137         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12138         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12139         return (uint64_t)ret_conv;
12140 }
12141
12142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12143         LDKNodeAnnouncementInfo o_conv;
12144         o_conv.inner = (void*)(o & (~1));
12145         o_conv.is_owned = (o & 1) || (o == 0);
12146         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12147         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12148         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12149         return (uint64_t)ret_conv;
12150 }
12151
12152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12153         LDKDecodeError e_conv;
12154         e_conv.inner = (void*)(e & (~1));
12155         e_conv.is_owned = (e & 1) || (e == 0);
12156         e_conv = DecodeError_clone(&e_conv);
12157         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12158         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12159         return (uint64_t)ret_conv;
12160 }
12161
12162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12163         if ((_res & 1) != 0) return;
12164         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12165         FREE((void*)_res);
12166         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12167 }
12168
12169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12170         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12171         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12172         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12173         return (uint64_t)ret_conv;
12174 }
12175
12176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12177         LDKCVec_u64Z _res_constr;
12178         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12179         if (_res_constr.datalen > 0)
12180                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12181         else
12182                 _res_constr.data = NULL;
12183         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12184         for (size_t g = 0; g < _res_constr.datalen; g++) {
12185                 int64_t _res_conv_6 = _res_vals[g];
12186                 _res_constr.data[g] = _res_conv_6;
12187         }
12188         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12189         CVec_u64Z_free(_res_constr);
12190 }
12191
12192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12193         LDKNodeInfo o_conv;
12194         o_conv.inner = (void*)(o & (~1));
12195         o_conv.is_owned = (o & 1) || (o == 0);
12196         o_conv = NodeInfo_clone(&o_conv);
12197         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12198         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12199         return (uint64_t)ret_conv;
12200 }
12201
12202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12203         LDKDecodeError e_conv;
12204         e_conv.inner = (void*)(e & (~1));
12205         e_conv.is_owned = (e & 1) || (e == 0);
12206         e_conv = DecodeError_clone(&e_conv);
12207         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12208         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12209         return (uint64_t)ret_conv;
12210 }
12211
12212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12213         if ((_res & 1) != 0) return;
12214         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12215         FREE((void*)_res);
12216         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12217 }
12218
12219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12220         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12221         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12222         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12223         return (uint64_t)ret_conv;
12224 }
12225
12226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12227         LDKNetworkGraph o_conv;
12228         o_conv.inner = (void*)(o & (~1));
12229         o_conv.is_owned = (o & 1) || (o == 0);
12230         o_conv = NetworkGraph_clone(&o_conv);
12231         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12232         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12233         return (uint64_t)ret_conv;
12234 }
12235
12236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12237         LDKDecodeError e_conv;
12238         e_conv.inner = (void*)(e & (~1));
12239         e_conv.is_owned = (e & 1) || (e == 0);
12240         e_conv = DecodeError_clone(&e_conv);
12241         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12242         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12243         return (uint64_t)ret_conv;
12244 }
12245
12246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12247         if ((_res & 1) != 0) return;
12248         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
12249         FREE((void*)_res);
12250         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12251 }
12252
12253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12254         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12255         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12256         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12257         return (uint64_t)ret_conv;
12258 }
12259
12260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12261         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12262         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12263         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12264         return (uint64_t)ret_conv;
12265 }
12266
12267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12268         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12269         *ret_conv = CResult_NetAddressu8Z_err(e);
12270         return (uint64_t)ret_conv;
12271 }
12272
12273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12274         if ((_res & 1) != 0) return;
12275         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12276         FREE((void*)_res);
12277         CResult_NetAddressu8Z_free(_res_conv);
12278 }
12279
12280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12281         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12282         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12283         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12284         return (uint64_t)ret_conv;
12285 }
12286
12287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12288         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12289         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12290         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12291         return (uint64_t)ret_conv;
12292 }
12293
12294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12295         LDKDecodeError e_conv;
12296         e_conv.inner = (void*)(e & (~1));
12297         e_conv.is_owned = (e & 1) || (e == 0);
12298         e_conv = DecodeError_clone(&e_conv);
12299         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12300         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12301         return (uint64_t)ret_conv;
12302 }
12303
12304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12305         if ((_res & 1) != 0) return;
12306         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12307         FREE((void*)_res);
12308         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12309 }
12310
12311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12312         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12313         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12314         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12315         return (uint64_t)ret_conv;
12316 }
12317
12318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12319         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12320         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12321         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12322         return (uint64_t)ret_conv;
12323 }
12324
12325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12326         LDKDecodeError e_conv;
12327         e_conv.inner = (void*)(e & (~1));
12328         e_conv.is_owned = (e & 1) || (e == 0);
12329         e_conv = DecodeError_clone(&e_conv);
12330         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12331         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12332         return (uint64_t)ret_conv;
12333 }
12334
12335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12336         if ((_res & 1) != 0) return;
12337         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12338         FREE((void*)_res);
12339         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12340 }
12341
12342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12343         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12344         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12345         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12346         return (uint64_t)ret_conv;
12347 }
12348
12349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12350         LDKCVec_UpdateAddHTLCZ _res_constr;
12351         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12352         if (_res_constr.datalen > 0)
12353                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12354         else
12355                 _res_constr.data = NULL;
12356         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12357         for (size_t p = 0; p < _res_constr.datalen; p++) {
12358                 int64_t _res_conv_15 = _res_vals[p];
12359                 LDKUpdateAddHTLC _res_conv_15_conv;
12360                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12361                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12362                 _res_constr.data[p] = _res_conv_15_conv;
12363         }
12364         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12365         CVec_UpdateAddHTLCZ_free(_res_constr);
12366 }
12367
12368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12369         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12370         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12371         if (_res_constr.datalen > 0)
12372                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12373         else
12374                 _res_constr.data = NULL;
12375         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12376         for (size_t t = 0; t < _res_constr.datalen; t++) {
12377                 int64_t _res_conv_19 = _res_vals[t];
12378                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12379                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12380                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12381                 _res_constr.data[t] = _res_conv_19_conv;
12382         }
12383         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12384         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12385 }
12386
12387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12388         LDKCVec_UpdateFailHTLCZ _res_constr;
12389         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12390         if (_res_constr.datalen > 0)
12391                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12392         else
12393                 _res_constr.data = NULL;
12394         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12395         for (size_t q = 0; q < _res_constr.datalen; q++) {
12396                 int64_t _res_conv_16 = _res_vals[q];
12397                 LDKUpdateFailHTLC _res_conv_16_conv;
12398                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12399                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12400                 _res_constr.data[q] = _res_conv_16_conv;
12401         }
12402         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12403         CVec_UpdateFailHTLCZ_free(_res_constr);
12404 }
12405
12406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12407         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12408         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12409         if (_res_constr.datalen > 0)
12410                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12411         else
12412                 _res_constr.data = NULL;
12413         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12414         for (size_t z = 0; z < _res_constr.datalen; z++) {
12415                 int64_t _res_conv_25 = _res_vals[z];
12416                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12417                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12418                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12419                 _res_constr.data[z] = _res_conv_25_conv;
12420         }
12421         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12422         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12423 }
12424
12425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12426         LDKAcceptChannel o_conv;
12427         o_conv.inner = (void*)(o & (~1));
12428         o_conv.is_owned = (o & 1) || (o == 0);
12429         o_conv = AcceptChannel_clone(&o_conv);
12430         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12431         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12432         return (uint64_t)ret_conv;
12433 }
12434
12435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12436         LDKDecodeError e_conv;
12437         e_conv.inner = (void*)(e & (~1));
12438         e_conv.is_owned = (e & 1) || (e == 0);
12439         e_conv = DecodeError_clone(&e_conv);
12440         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12441         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12442         return (uint64_t)ret_conv;
12443 }
12444
12445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12446         if ((_res & 1) != 0) return;
12447         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12448         FREE((void*)_res);
12449         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12450 }
12451
12452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12453         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12454         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12455         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12456         return (uint64_t)ret_conv;
12457 }
12458
12459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12460         LDKAnnouncementSignatures o_conv;
12461         o_conv.inner = (void*)(o & (~1));
12462         o_conv.is_owned = (o & 1) || (o == 0);
12463         o_conv = AnnouncementSignatures_clone(&o_conv);
12464         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12465         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12466         return (uint64_t)ret_conv;
12467 }
12468
12469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12470         LDKDecodeError e_conv;
12471         e_conv.inner = (void*)(e & (~1));
12472         e_conv.is_owned = (e & 1) || (e == 0);
12473         e_conv = DecodeError_clone(&e_conv);
12474         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12475         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12476         return (uint64_t)ret_conv;
12477 }
12478
12479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12480         if ((_res & 1) != 0) return;
12481         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12482         FREE((void*)_res);
12483         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12484 }
12485
12486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12487         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12488         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12489         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12490         return (uint64_t)ret_conv;
12491 }
12492
12493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12494         LDKChannelReestablish o_conv;
12495         o_conv.inner = (void*)(o & (~1));
12496         o_conv.is_owned = (o & 1) || (o == 0);
12497         o_conv = ChannelReestablish_clone(&o_conv);
12498         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12499         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12500         return (uint64_t)ret_conv;
12501 }
12502
12503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12504         LDKDecodeError e_conv;
12505         e_conv.inner = (void*)(e & (~1));
12506         e_conv.is_owned = (e & 1) || (e == 0);
12507         e_conv = DecodeError_clone(&e_conv);
12508         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12509         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12510         return (uint64_t)ret_conv;
12511 }
12512
12513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12514         if ((_res & 1) != 0) return;
12515         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12516         FREE((void*)_res);
12517         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12518 }
12519
12520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12521         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12522         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12523         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12524         return (uint64_t)ret_conv;
12525 }
12526
12527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12528         LDKClosingSigned o_conv;
12529         o_conv.inner = (void*)(o & (~1));
12530         o_conv.is_owned = (o & 1) || (o == 0);
12531         o_conv = ClosingSigned_clone(&o_conv);
12532         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12533         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12534         return (uint64_t)ret_conv;
12535 }
12536
12537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12538         LDKDecodeError e_conv;
12539         e_conv.inner = (void*)(e & (~1));
12540         e_conv.is_owned = (e & 1) || (e == 0);
12541         e_conv = DecodeError_clone(&e_conv);
12542         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12543         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12544         return (uint64_t)ret_conv;
12545 }
12546
12547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12548         if ((_res & 1) != 0) return;
12549         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12550         FREE((void*)_res);
12551         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12552 }
12553
12554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12555         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12556         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12557         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12558         return (uint64_t)ret_conv;
12559 }
12560
12561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12562         LDKClosingSignedFeeRange o_conv;
12563         o_conv.inner = (void*)(o & (~1));
12564         o_conv.is_owned = (o & 1) || (o == 0);
12565         o_conv = ClosingSignedFeeRange_clone(&o_conv);
12566         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12567         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
12568         return (uint64_t)ret_conv;
12569 }
12570
12571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12572         LDKDecodeError e_conv;
12573         e_conv.inner = (void*)(e & (~1));
12574         e_conv.is_owned = (e & 1) || (e == 0);
12575         e_conv = DecodeError_clone(&e_conv);
12576         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12577         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
12578         return (uint64_t)ret_conv;
12579 }
12580
12581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12582         if ((_res & 1) != 0) return;
12583         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12584         FREE((void*)_res);
12585         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
12586 }
12587
12588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12589         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
12590         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12591         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
12592         return (uint64_t)ret_conv;
12593 }
12594
12595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12596         LDKCommitmentSigned o_conv;
12597         o_conv.inner = (void*)(o & (~1));
12598         o_conv.is_owned = (o & 1) || (o == 0);
12599         o_conv = CommitmentSigned_clone(&o_conv);
12600         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12601         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12602         return (uint64_t)ret_conv;
12603 }
12604
12605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12606         LDKDecodeError e_conv;
12607         e_conv.inner = (void*)(e & (~1));
12608         e_conv.is_owned = (e & 1) || (e == 0);
12609         e_conv = DecodeError_clone(&e_conv);
12610         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12611         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12612         return (uint64_t)ret_conv;
12613 }
12614
12615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12616         if ((_res & 1) != 0) return;
12617         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12618         FREE((void*)_res);
12619         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12620 }
12621
12622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12623         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12624         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12625         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12626         return (uint64_t)ret_conv;
12627 }
12628
12629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12630         LDKFundingCreated o_conv;
12631         o_conv.inner = (void*)(o & (~1));
12632         o_conv.is_owned = (o & 1) || (o == 0);
12633         o_conv = FundingCreated_clone(&o_conv);
12634         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12635         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12636         return (uint64_t)ret_conv;
12637 }
12638
12639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12640         LDKDecodeError e_conv;
12641         e_conv.inner = (void*)(e & (~1));
12642         e_conv.is_owned = (e & 1) || (e == 0);
12643         e_conv = DecodeError_clone(&e_conv);
12644         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12645         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12646         return (uint64_t)ret_conv;
12647 }
12648
12649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12650         if ((_res & 1) != 0) return;
12651         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12652         FREE((void*)_res);
12653         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12654 }
12655
12656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12657         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12658         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12659         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12660         return (uint64_t)ret_conv;
12661 }
12662
12663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12664         LDKFundingSigned o_conv;
12665         o_conv.inner = (void*)(o & (~1));
12666         o_conv.is_owned = (o & 1) || (o == 0);
12667         o_conv = FundingSigned_clone(&o_conv);
12668         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12669         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12670         return (uint64_t)ret_conv;
12671 }
12672
12673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12674         LDKDecodeError e_conv;
12675         e_conv.inner = (void*)(e & (~1));
12676         e_conv.is_owned = (e & 1) || (e == 0);
12677         e_conv = DecodeError_clone(&e_conv);
12678         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12679         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12680         return (uint64_t)ret_conv;
12681 }
12682
12683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12684         if ((_res & 1) != 0) return;
12685         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12686         FREE((void*)_res);
12687         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12688 }
12689
12690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12691         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12692         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12693         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12694         return (uint64_t)ret_conv;
12695 }
12696
12697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12698         LDKFundingLocked o_conv;
12699         o_conv.inner = (void*)(o & (~1));
12700         o_conv.is_owned = (o & 1) || (o == 0);
12701         o_conv = FundingLocked_clone(&o_conv);
12702         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12703         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12704         return (uint64_t)ret_conv;
12705 }
12706
12707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12708         LDKDecodeError e_conv;
12709         e_conv.inner = (void*)(e & (~1));
12710         e_conv.is_owned = (e & 1) || (e == 0);
12711         e_conv = DecodeError_clone(&e_conv);
12712         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12713         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12714         return (uint64_t)ret_conv;
12715 }
12716
12717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12718         if ((_res & 1) != 0) return;
12719         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12720         FREE((void*)_res);
12721         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12722 }
12723
12724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12725         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12726         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12727         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12728         return (uint64_t)ret_conv;
12729 }
12730
12731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12732         LDKInit o_conv;
12733         o_conv.inner = (void*)(o & (~1));
12734         o_conv.is_owned = (o & 1) || (o == 0);
12735         o_conv = Init_clone(&o_conv);
12736         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12737         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12738         return (uint64_t)ret_conv;
12739 }
12740
12741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12742         LDKDecodeError e_conv;
12743         e_conv.inner = (void*)(e & (~1));
12744         e_conv.is_owned = (e & 1) || (e == 0);
12745         e_conv = DecodeError_clone(&e_conv);
12746         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12747         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12748         return (uint64_t)ret_conv;
12749 }
12750
12751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12752         if ((_res & 1) != 0) return;
12753         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12754         FREE((void*)_res);
12755         CResult_InitDecodeErrorZ_free(_res_conv);
12756 }
12757
12758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12759         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12760         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12761         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12762         return (uint64_t)ret_conv;
12763 }
12764
12765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12766         LDKOpenChannel o_conv;
12767         o_conv.inner = (void*)(o & (~1));
12768         o_conv.is_owned = (o & 1) || (o == 0);
12769         o_conv = OpenChannel_clone(&o_conv);
12770         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12771         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12772         return (uint64_t)ret_conv;
12773 }
12774
12775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12776         LDKDecodeError e_conv;
12777         e_conv.inner = (void*)(e & (~1));
12778         e_conv.is_owned = (e & 1) || (e == 0);
12779         e_conv = DecodeError_clone(&e_conv);
12780         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12781         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12782         return (uint64_t)ret_conv;
12783 }
12784
12785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12786         if ((_res & 1) != 0) return;
12787         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12788         FREE((void*)_res);
12789         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12790 }
12791
12792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12793         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12794         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12795         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12796         return (uint64_t)ret_conv;
12797 }
12798
12799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12800         LDKRevokeAndACK o_conv;
12801         o_conv.inner = (void*)(o & (~1));
12802         o_conv.is_owned = (o & 1) || (o == 0);
12803         o_conv = RevokeAndACK_clone(&o_conv);
12804         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12805         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12806         return (uint64_t)ret_conv;
12807 }
12808
12809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12810         LDKDecodeError e_conv;
12811         e_conv.inner = (void*)(e & (~1));
12812         e_conv.is_owned = (e & 1) || (e == 0);
12813         e_conv = DecodeError_clone(&e_conv);
12814         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12815         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12816         return (uint64_t)ret_conv;
12817 }
12818
12819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12820         if ((_res & 1) != 0) return;
12821         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12822         FREE((void*)_res);
12823         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12824 }
12825
12826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12827         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12828         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12829         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12830         return (uint64_t)ret_conv;
12831 }
12832
12833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12834         LDKShutdown o_conv;
12835         o_conv.inner = (void*)(o & (~1));
12836         o_conv.is_owned = (o & 1) || (o == 0);
12837         o_conv = Shutdown_clone(&o_conv);
12838         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12839         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12840         return (uint64_t)ret_conv;
12841 }
12842
12843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12844         LDKDecodeError e_conv;
12845         e_conv.inner = (void*)(e & (~1));
12846         e_conv.is_owned = (e & 1) || (e == 0);
12847         e_conv = DecodeError_clone(&e_conv);
12848         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12849         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12850         return (uint64_t)ret_conv;
12851 }
12852
12853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12854         if ((_res & 1) != 0) return;
12855         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12856         FREE((void*)_res);
12857         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12858 }
12859
12860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12861         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12862         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12863         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12864         return (uint64_t)ret_conv;
12865 }
12866
12867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12868         LDKUpdateFailHTLC o_conv;
12869         o_conv.inner = (void*)(o & (~1));
12870         o_conv.is_owned = (o & 1) || (o == 0);
12871         o_conv = UpdateFailHTLC_clone(&o_conv);
12872         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12873         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12874         return (uint64_t)ret_conv;
12875 }
12876
12877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12878         LDKDecodeError e_conv;
12879         e_conv.inner = (void*)(e & (~1));
12880         e_conv.is_owned = (e & 1) || (e == 0);
12881         e_conv = DecodeError_clone(&e_conv);
12882         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12883         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12884         return (uint64_t)ret_conv;
12885 }
12886
12887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12888         if ((_res & 1) != 0) return;
12889         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12890         FREE((void*)_res);
12891         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12892 }
12893
12894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12895         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12896         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12897         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12898         return (uint64_t)ret_conv;
12899 }
12900
12901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12902         LDKUpdateFailMalformedHTLC o_conv;
12903         o_conv.inner = (void*)(o & (~1));
12904         o_conv.is_owned = (o & 1) || (o == 0);
12905         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12906         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12907         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12908         return (uint64_t)ret_conv;
12909 }
12910
12911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12912         LDKDecodeError e_conv;
12913         e_conv.inner = (void*)(e & (~1));
12914         e_conv.is_owned = (e & 1) || (e == 0);
12915         e_conv = DecodeError_clone(&e_conv);
12916         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12917         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12918         return (uint64_t)ret_conv;
12919 }
12920
12921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12922         if ((_res & 1) != 0) return;
12923         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12924         FREE((void*)_res);
12925         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12926 }
12927
12928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12929         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12930         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12931         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12932         return (uint64_t)ret_conv;
12933 }
12934
12935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12936         LDKUpdateFee o_conv;
12937         o_conv.inner = (void*)(o & (~1));
12938         o_conv.is_owned = (o & 1) || (o == 0);
12939         o_conv = UpdateFee_clone(&o_conv);
12940         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12941         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12942         return (uint64_t)ret_conv;
12943 }
12944
12945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12946         LDKDecodeError e_conv;
12947         e_conv.inner = (void*)(e & (~1));
12948         e_conv.is_owned = (e & 1) || (e == 0);
12949         e_conv = DecodeError_clone(&e_conv);
12950         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12951         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12952         return (uint64_t)ret_conv;
12953 }
12954
12955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12956         if ((_res & 1) != 0) return;
12957         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12958         FREE((void*)_res);
12959         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12960 }
12961
12962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12963         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12964         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12965         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12966         return (uint64_t)ret_conv;
12967 }
12968
12969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12970         LDKUpdateFulfillHTLC o_conv;
12971         o_conv.inner = (void*)(o & (~1));
12972         o_conv.is_owned = (o & 1) || (o == 0);
12973         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12974         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12975         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12976         return (uint64_t)ret_conv;
12977 }
12978
12979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12980         LDKDecodeError e_conv;
12981         e_conv.inner = (void*)(e & (~1));
12982         e_conv.is_owned = (e & 1) || (e == 0);
12983         e_conv = DecodeError_clone(&e_conv);
12984         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12985         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12986         return (uint64_t)ret_conv;
12987 }
12988
12989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12990         if ((_res & 1) != 0) return;
12991         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12992         FREE((void*)_res);
12993         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12994 }
12995
12996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12997         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12998         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12999         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
13000         return (uint64_t)ret_conv;
13001 }
13002
13003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13004         LDKUpdateAddHTLC o_conv;
13005         o_conv.inner = (void*)(o & (~1));
13006         o_conv.is_owned = (o & 1) || (o == 0);
13007         o_conv = UpdateAddHTLC_clone(&o_conv);
13008         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13009         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
13010         return (uint64_t)ret_conv;
13011 }
13012
13013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13014         LDKDecodeError e_conv;
13015         e_conv.inner = (void*)(e & (~1));
13016         e_conv.is_owned = (e & 1) || (e == 0);
13017         e_conv = DecodeError_clone(&e_conv);
13018         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13019         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
13020         return (uint64_t)ret_conv;
13021 }
13022
13023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13024         if ((_res & 1) != 0) return;
13025         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
13026         FREE((void*)_res);
13027         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
13028 }
13029
13030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13031         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
13032         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13033         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
13034         return (uint64_t)ret_conv;
13035 }
13036
13037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13038         LDKPing o_conv;
13039         o_conv.inner = (void*)(o & (~1));
13040         o_conv.is_owned = (o & 1) || (o == 0);
13041         o_conv = Ping_clone(&o_conv);
13042         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13043         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
13044         return (uint64_t)ret_conv;
13045 }
13046
13047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13048         LDKDecodeError e_conv;
13049         e_conv.inner = (void*)(e & (~1));
13050         e_conv.is_owned = (e & 1) || (e == 0);
13051         e_conv = DecodeError_clone(&e_conv);
13052         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13053         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
13054         return (uint64_t)ret_conv;
13055 }
13056
13057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13058         if ((_res & 1) != 0) return;
13059         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
13060         FREE((void*)_res);
13061         CResult_PingDecodeErrorZ_free(_res_conv);
13062 }
13063
13064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13065         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
13066         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13067         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
13068         return (uint64_t)ret_conv;
13069 }
13070
13071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13072         LDKPong o_conv;
13073         o_conv.inner = (void*)(o & (~1));
13074         o_conv.is_owned = (o & 1) || (o == 0);
13075         o_conv = Pong_clone(&o_conv);
13076         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13077         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
13078         return (uint64_t)ret_conv;
13079 }
13080
13081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13082         LDKDecodeError e_conv;
13083         e_conv.inner = (void*)(e & (~1));
13084         e_conv.is_owned = (e & 1) || (e == 0);
13085         e_conv = DecodeError_clone(&e_conv);
13086         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13087         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
13088         return (uint64_t)ret_conv;
13089 }
13090
13091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13092         if ((_res & 1) != 0) return;
13093         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
13094         FREE((void*)_res);
13095         CResult_PongDecodeErrorZ_free(_res_conv);
13096 }
13097
13098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13099         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
13100         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13101         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
13102         return (uint64_t)ret_conv;
13103 }
13104
13105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13106         LDKUnsignedChannelAnnouncement o_conv;
13107         o_conv.inner = (void*)(o & (~1));
13108         o_conv.is_owned = (o & 1) || (o == 0);
13109         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
13110         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13111         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
13112         return (uint64_t)ret_conv;
13113 }
13114
13115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13116         LDKDecodeError e_conv;
13117         e_conv.inner = (void*)(e & (~1));
13118         e_conv.is_owned = (e & 1) || (e == 0);
13119         e_conv = DecodeError_clone(&e_conv);
13120         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13121         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
13122         return (uint64_t)ret_conv;
13123 }
13124
13125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13126         if ((_res & 1) != 0) return;
13127         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13128         FREE((void*)_res);
13129         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
13130 }
13131
13132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13133         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13134         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13135         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13136         return (uint64_t)ret_conv;
13137 }
13138
13139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13140         LDKChannelAnnouncement o_conv;
13141         o_conv.inner = (void*)(o & (~1));
13142         o_conv.is_owned = (o & 1) || (o == 0);
13143         o_conv = ChannelAnnouncement_clone(&o_conv);
13144         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13145         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
13146         return (uint64_t)ret_conv;
13147 }
13148
13149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13150         LDKDecodeError e_conv;
13151         e_conv.inner = (void*)(e & (~1));
13152         e_conv.is_owned = (e & 1) || (e == 0);
13153         e_conv = DecodeError_clone(&e_conv);
13154         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13155         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
13156         return (uint64_t)ret_conv;
13157 }
13158
13159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13160         if ((_res & 1) != 0) return;
13161         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13162         FREE((void*)_res);
13163         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
13164 }
13165
13166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13167         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13168         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13169         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13170         return (uint64_t)ret_conv;
13171 }
13172
13173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13174         LDKUnsignedChannelUpdate o_conv;
13175         o_conv.inner = (void*)(o & (~1));
13176         o_conv.is_owned = (o & 1) || (o == 0);
13177         o_conv = UnsignedChannelUpdate_clone(&o_conv);
13178         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13179         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
13180         return (uint64_t)ret_conv;
13181 }
13182
13183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13184         LDKDecodeError e_conv;
13185         e_conv.inner = (void*)(e & (~1));
13186         e_conv.is_owned = (e & 1) || (e == 0);
13187         e_conv = DecodeError_clone(&e_conv);
13188         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13189         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
13190         return (uint64_t)ret_conv;
13191 }
13192
13193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13194         if ((_res & 1) != 0) return;
13195         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13196         FREE((void*)_res);
13197         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
13198 }
13199
13200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13201         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
13202         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13203         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
13204         return (uint64_t)ret_conv;
13205 }
13206
13207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13208         LDKChannelUpdate o_conv;
13209         o_conv.inner = (void*)(o & (~1));
13210         o_conv.is_owned = (o & 1) || (o == 0);
13211         o_conv = ChannelUpdate_clone(&o_conv);
13212         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13213         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
13214         return (uint64_t)ret_conv;
13215 }
13216
13217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13218         LDKDecodeError e_conv;
13219         e_conv.inner = (void*)(e & (~1));
13220         e_conv.is_owned = (e & 1) || (e == 0);
13221         e_conv = DecodeError_clone(&e_conv);
13222         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13223         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
13224         return (uint64_t)ret_conv;
13225 }
13226
13227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13228         if ((_res & 1) != 0) return;
13229         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13230         FREE((void*)_res);
13231         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
13232 }
13233
13234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13235         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
13236         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13237         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
13238         return (uint64_t)ret_conv;
13239 }
13240
13241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13242         LDKErrorMessage o_conv;
13243         o_conv.inner = (void*)(o & (~1));
13244         o_conv.is_owned = (o & 1) || (o == 0);
13245         o_conv = ErrorMessage_clone(&o_conv);
13246         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13247         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
13248         return (uint64_t)ret_conv;
13249 }
13250
13251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13252         LDKDecodeError e_conv;
13253         e_conv.inner = (void*)(e & (~1));
13254         e_conv.is_owned = (e & 1) || (e == 0);
13255         e_conv = DecodeError_clone(&e_conv);
13256         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13257         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
13258         return (uint64_t)ret_conv;
13259 }
13260
13261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13262         if ((_res & 1) != 0) return;
13263         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
13264         FREE((void*)_res);
13265         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
13266 }
13267
13268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13269         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13270         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13271         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13272         return (uint64_t)ret_conv;
13273 }
13274
13275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13276         LDKUnsignedNodeAnnouncement o_conv;
13277         o_conv.inner = (void*)(o & (~1));
13278         o_conv.is_owned = (o & 1) || (o == 0);
13279         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13280         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13281         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13282         return (uint64_t)ret_conv;
13283 }
13284
13285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13286         LDKDecodeError e_conv;
13287         e_conv.inner = (void*)(e & (~1));
13288         e_conv.is_owned = (e & 1) || (e == 0);
13289         e_conv = DecodeError_clone(&e_conv);
13290         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13291         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13292         return (uint64_t)ret_conv;
13293 }
13294
13295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13296         if ((_res & 1) != 0) return;
13297         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13298         FREE((void*)_res);
13299         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13300 }
13301
13302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13303         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13304         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13305         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13306         return (uint64_t)ret_conv;
13307 }
13308
13309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13310         LDKNodeAnnouncement o_conv;
13311         o_conv.inner = (void*)(o & (~1));
13312         o_conv.is_owned = (o & 1) || (o == 0);
13313         o_conv = NodeAnnouncement_clone(&o_conv);
13314         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13315         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13316         return (uint64_t)ret_conv;
13317 }
13318
13319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13320         LDKDecodeError e_conv;
13321         e_conv.inner = (void*)(e & (~1));
13322         e_conv.is_owned = (e & 1) || (e == 0);
13323         e_conv = DecodeError_clone(&e_conv);
13324         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13325         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13326         return (uint64_t)ret_conv;
13327 }
13328
13329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13330         if ((_res & 1) != 0) return;
13331         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13332         FREE((void*)_res);
13333         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13334 }
13335
13336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13337         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13338         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13339         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13340         return (uint64_t)ret_conv;
13341 }
13342
13343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13344         LDKQueryShortChannelIds o_conv;
13345         o_conv.inner = (void*)(o & (~1));
13346         o_conv.is_owned = (o & 1) || (o == 0);
13347         o_conv = QueryShortChannelIds_clone(&o_conv);
13348         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13349         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13350         return (uint64_t)ret_conv;
13351 }
13352
13353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13354         LDKDecodeError e_conv;
13355         e_conv.inner = (void*)(e & (~1));
13356         e_conv.is_owned = (e & 1) || (e == 0);
13357         e_conv = DecodeError_clone(&e_conv);
13358         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13359         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13360         return (uint64_t)ret_conv;
13361 }
13362
13363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13364         if ((_res & 1) != 0) return;
13365         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13366         FREE((void*)_res);
13367         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13368 }
13369
13370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13371         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13372         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13373         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13374         return (uint64_t)ret_conv;
13375 }
13376
13377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13378         LDKReplyShortChannelIdsEnd o_conv;
13379         o_conv.inner = (void*)(o & (~1));
13380         o_conv.is_owned = (o & 1) || (o == 0);
13381         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13382         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13383         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13384         return (uint64_t)ret_conv;
13385 }
13386
13387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13388         LDKDecodeError e_conv;
13389         e_conv.inner = (void*)(e & (~1));
13390         e_conv.is_owned = (e & 1) || (e == 0);
13391         e_conv = DecodeError_clone(&e_conv);
13392         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13393         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13394         return (uint64_t)ret_conv;
13395 }
13396
13397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13398         if ((_res & 1) != 0) return;
13399         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13400         FREE((void*)_res);
13401         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13402 }
13403
13404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13405         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13406         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13407         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13408         return (uint64_t)ret_conv;
13409 }
13410
13411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13412         LDKQueryChannelRange o_conv;
13413         o_conv.inner = (void*)(o & (~1));
13414         o_conv.is_owned = (o & 1) || (o == 0);
13415         o_conv = QueryChannelRange_clone(&o_conv);
13416         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13417         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13418         return (uint64_t)ret_conv;
13419 }
13420
13421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13422         LDKDecodeError e_conv;
13423         e_conv.inner = (void*)(e & (~1));
13424         e_conv.is_owned = (e & 1) || (e == 0);
13425         e_conv = DecodeError_clone(&e_conv);
13426         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13427         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13428         return (uint64_t)ret_conv;
13429 }
13430
13431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13432         if ((_res & 1) != 0) return;
13433         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13434         FREE((void*)_res);
13435         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13436 }
13437
13438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13439         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13440         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13441         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13442         return (uint64_t)ret_conv;
13443 }
13444
13445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13446         LDKReplyChannelRange o_conv;
13447         o_conv.inner = (void*)(o & (~1));
13448         o_conv.is_owned = (o & 1) || (o == 0);
13449         o_conv = ReplyChannelRange_clone(&o_conv);
13450         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13451         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13452         return (uint64_t)ret_conv;
13453 }
13454
13455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13456         LDKDecodeError e_conv;
13457         e_conv.inner = (void*)(e & (~1));
13458         e_conv.is_owned = (e & 1) || (e == 0);
13459         e_conv = DecodeError_clone(&e_conv);
13460         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13461         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13462         return (uint64_t)ret_conv;
13463 }
13464
13465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13466         if ((_res & 1) != 0) return;
13467         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13468         FREE((void*)_res);
13469         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13470 }
13471
13472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13473         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13474         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13475         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13476         return (uint64_t)ret_conv;
13477 }
13478
13479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13480         LDKGossipTimestampFilter o_conv;
13481         o_conv.inner = (void*)(o & (~1));
13482         o_conv.is_owned = (o & 1) || (o == 0);
13483         o_conv = GossipTimestampFilter_clone(&o_conv);
13484         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13485         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13486         return (uint64_t)ret_conv;
13487 }
13488
13489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13490         LDKDecodeError e_conv;
13491         e_conv.inner = (void*)(e & (~1));
13492         e_conv.is_owned = (e & 1) || (e == 0);
13493         e_conv = DecodeError_clone(&e_conv);
13494         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13495         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13496         return (uint64_t)ret_conv;
13497 }
13498
13499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13500         if ((_res & 1) != 0) return;
13501         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13502         FREE((void*)_res);
13503         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13504 }
13505
13506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13507         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13508         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13509         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13510         return (uint64_t)ret_conv;
13511 }
13512
13513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13514         LDKInvoice o_conv;
13515         o_conv.inner = (void*)(o & (~1));
13516         o_conv.is_owned = (o & 1) || (o == 0);
13517         o_conv = Invoice_clone(&o_conv);
13518         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13519         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13520         return (uint64_t)ret_conv;
13521 }
13522
13523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13524         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13525         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13526         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13527         return (uint64_t)ret_conv;
13528 }
13529
13530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13531         if ((_res & 1) != 0) return;
13532         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13533         FREE((void*)_res);
13534         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13535 }
13536
13537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13538         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13539         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13540         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13541         return (uint64_t)ret_conv;
13542 }
13543
13544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13545         if ((this_ptr & 1) != 0) return;
13546         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
13547         FREE((void*)this_ptr);
13548         PaymentPurpose_free(this_ptr_conv);
13549 }
13550
13551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13552         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
13553         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13554         *ret_copy = PaymentPurpose_clone(orig_conv);
13555         uint64_t ret_ref = (uint64_t)ret_copy;
13556         return ret_ref;
13557 }
13558
13559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
13560         LDKThirtyTwoBytes payment_preimage_ref;
13561         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13562         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13563         LDKThirtyTwoBytes payment_secret_ref;
13564         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13565         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13566         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13567         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
13568         uint64_t ret_ref = (uint64_t)ret_copy;
13569         return ret_ref;
13570 }
13571
13572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
13573         LDKThirtyTwoBytes a_ref;
13574         CHECK((*env)->GetArrayLength(env, a) == 32);
13575         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13576         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13577         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
13578         uint64_t ret_ref = (uint64_t)ret_copy;
13579         return ret_ref;
13580 }
13581
13582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13583         if ((this_ptr & 1) != 0) return;
13584         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13585         FREE((void*)this_ptr);
13586         Event_free(this_ptr_conv);
13587 }
13588
13589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13590         LDKEvent* orig_conv = (LDKEvent*)orig;
13591         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13592         *ret_copy = Event_clone(orig_conv);
13593         uint64_t ret_ref = (uint64_t)ret_copy;
13594         return ret_ref;
13595 }
13596
13597 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) {
13598         LDKThirtyTwoBytes temporary_channel_id_ref;
13599         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
13600         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
13601         LDKCVec_u8Z output_script_ref;
13602         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
13603         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
13604         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
13605         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13606         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
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_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
13612         LDKThirtyTwoBytes payment_hash_ref;
13613         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13614         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13615         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
13616         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13617         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
13618         uint64_t ret_ref = (uint64_t)ret_copy;
13619         return ret_ref;
13620 }
13621
13622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage) {
13623         LDKThirtyTwoBytes payment_preimage_ref;
13624         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13625         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13626         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13627         *ret_copy = Event_payment_sent(payment_preimage_ref);
13628         uint64_t ret_ref = (uint64_t)ret_copy;
13629         return ret_ref;
13630 }
13631
13632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest) {
13633         LDKThirtyTwoBytes payment_hash_ref;
13634         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13635         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13636         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13637         *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest);
13638         uint64_t ret_ref = (uint64_t)ret_copy;
13639         return ret_ref;
13640 }
13641
13642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
13643         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13644         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
13645         uint64_t ret_ref = (uint64_t)ret_copy;
13646         return ret_ref;
13647 }
13648
13649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
13650         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
13651         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
13652         if (outputs_constr.datalen > 0)
13653                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13654         else
13655                 outputs_constr.data = NULL;
13656         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
13657         for (size_t b = 0; b < outputs_constr.datalen; b++) {
13658                 int64_t outputs_conv_27 = outputs_vals[b];
13659                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
13660                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
13661                 outputs_constr.data[b] = outputs_conv_27_conv;
13662         }
13663         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
13664         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13665         *ret_copy = Event_spendable_outputs(outputs_constr);
13666         uint64_t ret_ref = (uint64_t)ret_copy;
13667         return ret_ref;
13668 }
13669
13670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
13671         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
13672         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13673         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
13674         uint64_t ret_ref = (uint64_t)ret_copy;
13675         return ret_ref;
13676 }
13677
13678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13679         LDKEvent* obj_conv = (LDKEvent*)obj;
13680         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13681         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13682         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13683         CVec_u8Z_free(ret_var);
13684         return ret_arr;
13685 }
13686
13687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13688         if ((this_ptr & 1) != 0) return;
13689         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13690         FREE((void*)this_ptr);
13691         MessageSendEvent_free(this_ptr_conv);
13692 }
13693
13694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13695         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13696         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13697         *ret_copy = MessageSendEvent_clone(orig_conv);
13698         uint64_t ret_ref = (uint64_t)ret_copy;
13699         return ret_ref;
13700 }
13701
13702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13703         LDKPublicKey node_id_ref;
13704         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13705         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13706         LDKAcceptChannel msg_conv;
13707         msg_conv.inner = (void*)(msg & (~1));
13708         msg_conv.is_owned = (msg & 1) || (msg == 0);
13709         msg_conv = AcceptChannel_clone(&msg_conv);
13710         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13711         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
13712         uint64_t ret_ref = (uint64_t)ret_copy;
13713         return ret_ref;
13714 }
13715
13716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13717         LDKPublicKey node_id_ref;
13718         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13719         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13720         LDKOpenChannel msg_conv;
13721         msg_conv.inner = (void*)(msg & (~1));
13722         msg_conv.is_owned = (msg & 1) || (msg == 0);
13723         msg_conv = OpenChannel_clone(&msg_conv);
13724         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13725         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
13726         uint64_t ret_ref = (uint64_t)ret_copy;
13727         return ret_ref;
13728 }
13729
13730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13731         LDKPublicKey node_id_ref;
13732         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13733         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13734         LDKFundingCreated msg_conv;
13735         msg_conv.inner = (void*)(msg & (~1));
13736         msg_conv.is_owned = (msg & 1) || (msg == 0);
13737         msg_conv = FundingCreated_clone(&msg_conv);
13738         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13739         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
13740         uint64_t ret_ref = (uint64_t)ret_copy;
13741         return ret_ref;
13742 }
13743
13744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13745         LDKPublicKey node_id_ref;
13746         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13747         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13748         LDKFundingSigned msg_conv;
13749         msg_conv.inner = (void*)(msg & (~1));
13750         msg_conv.is_owned = (msg & 1) || (msg == 0);
13751         msg_conv = FundingSigned_clone(&msg_conv);
13752         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13753         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
13754         uint64_t ret_ref = (uint64_t)ret_copy;
13755         return ret_ref;
13756 }
13757
13758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13759         LDKPublicKey node_id_ref;
13760         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13761         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13762         LDKFundingLocked msg_conv;
13763         msg_conv.inner = (void*)(msg & (~1));
13764         msg_conv.is_owned = (msg & 1) || (msg == 0);
13765         msg_conv = FundingLocked_clone(&msg_conv);
13766         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13767         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
13768         uint64_t ret_ref = (uint64_t)ret_copy;
13769         return ret_ref;
13770 }
13771
13772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13773         LDKPublicKey node_id_ref;
13774         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13775         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13776         LDKAnnouncementSignatures msg_conv;
13777         msg_conv.inner = (void*)(msg & (~1));
13778         msg_conv.is_owned = (msg & 1) || (msg == 0);
13779         msg_conv = AnnouncementSignatures_clone(&msg_conv);
13780         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13781         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
13782         uint64_t ret_ref = (uint64_t)ret_copy;
13783         return ret_ref;
13784 }
13785
13786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
13787         LDKPublicKey node_id_ref;
13788         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13789         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13790         LDKCommitmentUpdate updates_conv;
13791         updates_conv.inner = (void*)(updates & (~1));
13792         updates_conv.is_owned = (updates & 1) || (updates == 0);
13793         updates_conv = CommitmentUpdate_clone(&updates_conv);
13794         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13795         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
13796         uint64_t ret_ref = (uint64_t)ret_copy;
13797         return ret_ref;
13798 }
13799
13800 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) {
13801         LDKPublicKey node_id_ref;
13802         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13803         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13804         LDKRevokeAndACK msg_conv;
13805         msg_conv.inner = (void*)(msg & (~1));
13806         msg_conv.is_owned = (msg & 1) || (msg == 0);
13807         msg_conv = RevokeAndACK_clone(&msg_conv);
13808         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13809         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
13810         uint64_t ret_ref = (uint64_t)ret_copy;
13811         return ret_ref;
13812 }
13813
13814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13815         LDKPublicKey node_id_ref;
13816         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13817         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13818         LDKClosingSigned msg_conv;
13819         msg_conv.inner = (void*)(msg & (~1));
13820         msg_conv.is_owned = (msg & 1) || (msg == 0);
13821         msg_conv = ClosingSigned_clone(&msg_conv);
13822         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13823         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
13824         uint64_t ret_ref = (uint64_t)ret_copy;
13825         return ret_ref;
13826 }
13827
13828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13829         LDKPublicKey node_id_ref;
13830         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13831         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13832         LDKShutdown msg_conv;
13833         msg_conv.inner = (void*)(msg & (~1));
13834         msg_conv.is_owned = (msg & 1) || (msg == 0);
13835         msg_conv = Shutdown_clone(&msg_conv);
13836         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13837         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
13838         uint64_t ret_ref = (uint64_t)ret_copy;
13839         return ret_ref;
13840 }
13841
13842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13843         LDKPublicKey node_id_ref;
13844         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13845         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13846         LDKChannelReestablish msg_conv;
13847         msg_conv.inner = (void*)(msg & (~1));
13848         msg_conv.is_owned = (msg & 1) || (msg == 0);
13849         msg_conv = ChannelReestablish_clone(&msg_conv);
13850         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13851         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
13852         uint64_t ret_ref = (uint64_t)ret_copy;
13853         return ret_ref;
13854 }
13855
13856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
13857         LDKChannelAnnouncement msg_conv;
13858         msg_conv.inner = (void*)(msg & (~1));
13859         msg_conv.is_owned = (msg & 1) || (msg == 0);
13860         msg_conv = ChannelAnnouncement_clone(&msg_conv);
13861         LDKChannelUpdate update_msg_conv;
13862         update_msg_conv.inner = (void*)(update_msg & (~1));
13863         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
13864         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
13865         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13866         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
13867         uint64_t ret_ref = (uint64_t)ret_copy;
13868         return ret_ref;
13869 }
13870
13871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
13872         LDKNodeAnnouncement msg_conv;
13873         msg_conv.inner = (void*)(msg & (~1));
13874         msg_conv.is_owned = (msg & 1) || (msg == 0);
13875         msg_conv = NodeAnnouncement_clone(&msg_conv);
13876         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13877         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
13878         uint64_t ret_ref = (uint64_t)ret_copy;
13879         return ret_ref;
13880 }
13881
13882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
13883         LDKChannelUpdate msg_conv;
13884         msg_conv.inner = (void*)(msg & (~1));
13885         msg_conv.is_owned = (msg & 1) || (msg == 0);
13886         msg_conv = ChannelUpdate_clone(&msg_conv);
13887         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13888         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
13889         uint64_t ret_ref = (uint64_t)ret_copy;
13890         return ret_ref;
13891 }
13892
13893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13894         LDKPublicKey node_id_ref;
13895         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13896         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13897         LDKChannelUpdate msg_conv;
13898         msg_conv.inner = (void*)(msg & (~1));
13899         msg_conv.is_owned = (msg & 1) || (msg == 0);
13900         msg_conv = ChannelUpdate_clone(&msg_conv);
13901         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13902         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
13903         uint64_t ret_ref = (uint64_t)ret_copy;
13904         return ret_ref;
13905 }
13906
13907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
13908         LDKPublicKey node_id_ref;
13909         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13910         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13911         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
13912         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13913         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
13914         uint64_t ret_ref = (uint64_t)ret_copy;
13915         return ret_ref;
13916 }
13917
13918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1payment_1failure_1network_1update(JNIEnv *env, jclass clz, int64_t update) {
13919         LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1);
13920         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13921         *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv);
13922         uint64_t ret_ref = (uint64_t)ret_copy;
13923         return ret_ref;
13924 }
13925
13926 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) {
13927         LDKPublicKey node_id_ref;
13928         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13929         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13930         LDKQueryChannelRange msg_conv;
13931         msg_conv.inner = (void*)(msg & (~1));
13932         msg_conv.is_owned = (msg & 1) || (msg == 0);
13933         msg_conv = QueryChannelRange_clone(&msg_conv);
13934         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13935         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
13936         uint64_t ret_ref = (uint64_t)ret_copy;
13937         return ret_ref;
13938 }
13939
13940 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) {
13941         LDKPublicKey node_id_ref;
13942         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13943         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13944         LDKQueryShortChannelIds msg_conv;
13945         msg_conv.inner = (void*)(msg & (~1));
13946         msg_conv.is_owned = (msg & 1) || (msg == 0);
13947         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13948         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13949         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
13950         uint64_t ret_ref = (uint64_t)ret_copy;
13951         return ret_ref;
13952 }
13953
13954 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) {
13955         LDKPublicKey node_id_ref;
13956         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13957         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13958         LDKReplyChannelRange msg_conv;
13959         msg_conv.inner = (void*)(msg & (~1));
13960         msg_conv.is_owned = (msg & 1) || (msg == 0);
13961         msg_conv = ReplyChannelRange_clone(&msg_conv);
13962         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13963         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
13964         uint64_t ret_ref = (uint64_t)ret_copy;
13965         return ret_ref;
13966 }
13967
13968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13969         if ((this_ptr & 1) != 0) return;
13970         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13971         FREE((void*)this_ptr);
13972         MessageSendEventsProvider_free(this_ptr_conv);
13973 }
13974
13975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13976         if ((this_ptr & 1) != 0) return;
13977         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13978         FREE((void*)this_ptr);
13979         EventsProvider_free(this_ptr_conv);
13980 }
13981
13982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13983         if ((this_ptr & 1) != 0) return;
13984         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13985         FREE((void*)this_ptr);
13986         EventHandler_free(this_ptr_conv);
13987 }
13988
13989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13990         if ((this_ptr & 1) != 0) return;
13991         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13992         FREE((void*)this_ptr);
13993         APIError_free(this_ptr_conv);
13994 }
13995
13996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13997         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13998         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13999         *ret_copy = APIError_clone(orig_conv);
14000         uint64_t ret_ref = (uint64_t)ret_copy;
14001         return ret_ref;
14002 }
14003
14004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
14005         LDKStr err_conv = java_to_owned_str(env, err);
14006         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14007         *ret_copy = APIError_apimisuse_error(err_conv);
14008         uint64_t ret_ref = (uint64_t)ret_copy;
14009         return ret_ref;
14010 }
14011
14012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
14013         LDKStr err_conv = java_to_owned_str(env, err);
14014         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14015         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
14016         uint64_t ret_ref = (uint64_t)ret_copy;
14017         return ret_ref;
14018 }
14019
14020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
14021         LDKStr err_conv = java_to_owned_str(env, err);
14022         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14023         *ret_copy = APIError_route_error(err_conv);
14024         uint64_t ret_ref = (uint64_t)ret_copy;
14025         return ret_ref;
14026 }
14027
14028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
14029         LDKStr err_conv = java_to_owned_str(env, err);
14030         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14031         *ret_copy = APIError_channel_unavailable(err_conv);
14032         uint64_t ret_ref = (uint64_t)ret_copy;
14033         return ret_ref;
14034 }
14035
14036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
14037         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14038         *ret_copy = APIError_monitor_update_failed();
14039         uint64_t ret_ref = (uint64_t)ret_copy;
14040         return ret_ref;
14041 }
14042
14043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
14044         LDKShutdownScript script_conv;
14045         script_conv.inner = (void*)(script & (~1));
14046         script_conv.is_owned = (script & 1) || (script == 0);
14047         script_conv = ShutdownScript_clone(&script_conv);
14048         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14049         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
14050         uint64_t ret_ref = (uint64_t)ret_copy;
14051         return ret_ref;
14052 }
14053
14054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
14055         LDKu8slice msg_ref;
14056         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
14057         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
14058         unsigned char sk_arr[32];
14059         CHECK((*env)->GetArrayLength(env, sk) == 32);
14060         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
14061         unsigned char (*sk_ref)[32] = &sk_arr;
14062         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
14063         *ret_conv = sign(msg_ref, sk_ref);
14064         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
14065         return (uint64_t)ret_conv;
14066 }
14067
14068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
14069         LDKu8slice msg_ref;
14070         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
14071         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
14072         LDKStr sig_conv = java_to_owned_str(env, sig);
14073         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14074         *ret_conv = recover_pk(msg_ref, sig_conv);
14075         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
14076         return (uint64_t)ret_conv;
14077 }
14078
14079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
14080         LDKu8slice msg_ref;
14081         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
14082         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
14083         LDKStr sig_conv = java_to_owned_str(env, sig);
14084         LDKPublicKey pk_ref;
14085         CHECK((*env)->GetArrayLength(env, pk) == 33);
14086         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
14087         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
14088         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
14089         return ret_val;
14090 }
14091
14092 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14093         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
14094         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
14095         return ret_conv;
14096 }
14097
14098 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
14099         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
14100         return ret_conv;
14101 }
14102
14103 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
14104         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
14105         return ret_conv;
14106 }
14107
14108 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
14109         jclass ret_conv = LDKLevel_to_java(env, Level_info());
14110         return ret_conv;
14111 }
14112
14113 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
14114         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
14115         return ret_conv;
14116 }
14117
14118 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
14119         jclass ret_conv = LDKLevel_to_java(env, Level_error());
14120         return ret_conv;
14121 }
14122
14123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14124         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
14125         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
14126         jboolean ret_val = Level_eq(a_conv, b_conv);
14127         return ret_val;
14128 }
14129
14130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
14131         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
14132         int64_t ret_val = Level_hash(o_conv);
14133         return ret_val;
14134 }
14135
14136 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
14137         jclass ret_conv = LDKLevel_to_java(env, Level_max());
14138         return ret_conv;
14139 }
14140
14141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14142         if ((this_ptr & 1) != 0) return;
14143         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
14144         FREE((void*)this_ptr);
14145         Logger_free(this_ptr_conv);
14146 }
14147
14148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14149         LDKChannelHandshakeConfig this_obj_conv;
14150         this_obj_conv.inner = (void*)(this_obj & (~1));
14151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14152         ChannelHandshakeConfig_free(this_obj_conv);
14153 }
14154
14155 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14156         LDKChannelHandshakeConfig this_ptr_conv;
14157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14158         this_ptr_conv.is_owned = false;
14159         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
14160         return ret_val;
14161 }
14162
14163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14164         LDKChannelHandshakeConfig this_ptr_conv;
14165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14166         this_ptr_conv.is_owned = false;
14167         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
14168 }
14169
14170 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14171         LDKChannelHandshakeConfig this_ptr_conv;
14172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14173         this_ptr_conv.is_owned = false;
14174         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
14175         return ret_val;
14176 }
14177
14178 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) {
14179         LDKChannelHandshakeConfig this_ptr_conv;
14180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14181         this_ptr_conv.is_owned = false;
14182         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
14183 }
14184
14185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14186         LDKChannelHandshakeConfig this_ptr_conv;
14187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14188         this_ptr_conv.is_owned = false;
14189         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
14190         return ret_val;
14191 }
14192
14193 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) {
14194         LDKChannelHandshakeConfig this_ptr_conv;
14195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14196         this_ptr_conv.is_owned = false;
14197         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
14198 }
14199
14200 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) {
14201         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
14202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14204         uint64_t ret_ref = (uint64_t)ret_var.inner;
14205         if (ret_var.is_owned) {
14206                 ret_ref |= 1;
14207         }
14208         return ret_ref;
14209 }
14210
14211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14212         LDKChannelHandshakeConfig orig_conv;
14213         orig_conv.inner = (void*)(orig & (~1));
14214         orig_conv.is_owned = false;
14215         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
14216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14218         uint64_t ret_ref = (uint64_t)ret_var.inner;
14219         if (ret_var.is_owned) {
14220                 ret_ref |= 1;
14221         }
14222         return ret_ref;
14223 }
14224
14225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
14226         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
14227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14229         uint64_t ret_ref = (uint64_t)ret_var.inner;
14230         if (ret_var.is_owned) {
14231                 ret_ref |= 1;
14232         }
14233         return ret_ref;
14234 }
14235
14236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14237         LDKChannelHandshakeLimits this_obj_conv;
14238         this_obj_conv.inner = (void*)(this_obj & (~1));
14239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14240         ChannelHandshakeLimits_free(this_obj_conv);
14241 }
14242
14243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14244         LDKChannelHandshakeLimits this_ptr_conv;
14245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14246         this_ptr_conv.is_owned = false;
14247         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
14248         return ret_val;
14249 }
14250
14251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14252         LDKChannelHandshakeLimits this_ptr_conv;
14253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14254         this_ptr_conv.is_owned = false;
14255         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
14256 }
14257
14258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14259         LDKChannelHandshakeLimits this_ptr_conv;
14260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14261         this_ptr_conv.is_owned = false;
14262         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
14263         return ret_val;
14264 }
14265
14266 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) {
14267         LDKChannelHandshakeLimits this_ptr_conv;
14268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14269         this_ptr_conv.is_owned = false;
14270         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
14271 }
14272
14273 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) {
14274         LDKChannelHandshakeLimits this_ptr_conv;
14275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14276         this_ptr_conv.is_owned = false;
14277         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
14278         return ret_val;
14279 }
14280
14281 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) {
14282         LDKChannelHandshakeLimits this_ptr_conv;
14283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14284         this_ptr_conv.is_owned = false;
14285         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14286 }
14287
14288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14289         LDKChannelHandshakeLimits this_ptr_conv;
14290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14291         this_ptr_conv.is_owned = false;
14292         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
14293         return ret_val;
14294 }
14295
14296 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) {
14297         LDKChannelHandshakeLimits this_ptr_conv;
14298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14299         this_ptr_conv.is_owned = false;
14300         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
14301 }
14302
14303 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
14304         LDKChannelHandshakeLimits this_ptr_conv;
14305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14306         this_ptr_conv.is_owned = false;
14307         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
14308         return ret_val;
14309 }
14310
14311 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) {
14312         LDKChannelHandshakeLimits this_ptr_conv;
14313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14314         this_ptr_conv.is_owned = false;
14315         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
14316 }
14317
14318 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14319         LDKChannelHandshakeLimits this_ptr_conv;
14320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14321         this_ptr_conv.is_owned = false;
14322         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
14323         return ret_val;
14324 }
14325
14326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14327         LDKChannelHandshakeLimits this_ptr_conv;
14328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14329         this_ptr_conv.is_owned = false;
14330         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
14331 }
14332
14333 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
14334         LDKChannelHandshakeLimits this_ptr_conv;
14335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14336         this_ptr_conv.is_owned = false;
14337         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
14338         return ret_val;
14339 }
14340
14341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14342         LDKChannelHandshakeLimits this_ptr_conv;
14343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14344         this_ptr_conv.is_owned = false;
14345         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
14346 }
14347
14348 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14349         LDKChannelHandshakeLimits this_ptr_conv;
14350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14351         this_ptr_conv.is_owned = false;
14352         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
14353         return ret_val;
14354 }
14355
14356 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) {
14357         LDKChannelHandshakeLimits this_ptr_conv;
14358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14359         this_ptr_conv.is_owned = false;
14360         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
14361 }
14362
14363 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) {
14364         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);
14365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14367         uint64_t ret_ref = (uint64_t)ret_var.inner;
14368         if (ret_var.is_owned) {
14369                 ret_ref |= 1;
14370         }
14371         return ret_ref;
14372 }
14373
14374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14375         LDKChannelHandshakeLimits orig_conv;
14376         orig_conv.inner = (void*)(orig & (~1));
14377         orig_conv.is_owned = false;
14378         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
14379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14381         uint64_t ret_ref = (uint64_t)ret_var.inner;
14382         if (ret_var.is_owned) {
14383                 ret_ref |= 1;
14384         }
14385         return ret_ref;
14386 }
14387
14388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
14389         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
14390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14392         uint64_t ret_ref = (uint64_t)ret_var.inner;
14393         if (ret_var.is_owned) {
14394                 ret_ref |= 1;
14395         }
14396         return ret_ref;
14397 }
14398
14399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14400         LDKChannelConfig this_obj_conv;
14401         this_obj_conv.inner = (void*)(this_obj & (~1));
14402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14403         ChannelConfig_free(this_obj_conv);
14404 }
14405
14406 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
14407         LDKChannelConfig this_ptr_conv;
14408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14409         this_ptr_conv.is_owned = false;
14410         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
14411         return ret_val;
14412 }
14413
14414 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) {
14415         LDKChannelConfig this_ptr_conv;
14416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14417         this_ptr_conv.is_owned = false;
14418         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
14419 }
14420
14421 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14422         LDKChannelConfig this_ptr_conv;
14423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14424         this_ptr_conv.is_owned = false;
14425         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
14426         return ret_val;
14427 }
14428
14429 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) {
14430         LDKChannelConfig this_ptr_conv;
14431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14432         this_ptr_conv.is_owned = false;
14433         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
14434 }
14435
14436 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
14437         LDKChannelConfig this_ptr_conv;
14438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14439         this_ptr_conv.is_owned = false;
14440         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
14441         return ret_val;
14442 }
14443
14444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14445         LDKChannelConfig this_ptr_conv;
14446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14447         this_ptr_conv.is_owned = false;
14448         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
14449 }
14450
14451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
14452         LDKChannelConfig this_ptr_conv;
14453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14454         this_ptr_conv.is_owned = false;
14455         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
14456         return ret_val;
14457 }
14458
14459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14460         LDKChannelConfig this_ptr_conv;
14461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14462         this_ptr_conv.is_owned = false;
14463         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
14464 }
14465
14466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14467         LDKChannelConfig this_ptr_conv;
14468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14469         this_ptr_conv.is_owned = false;
14470         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
14471         return ret_val;
14472 }
14473
14474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14475         LDKChannelConfig this_ptr_conv;
14476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14477         this_ptr_conv.is_owned = false;
14478         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
14479 }
14480
14481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14482         LDKChannelConfig this_ptr_conv;
14483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14484         this_ptr_conv.is_owned = false;
14485         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
14486         return ret_val;
14487 }
14488
14489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14490         LDKChannelConfig this_ptr_conv;
14491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14492         this_ptr_conv.is_owned = false;
14493         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
14494 }
14495
14496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14497         LDKChannelConfig this_ptr_conv;
14498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14499         this_ptr_conv.is_owned = false;
14500         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
14501         return ret_val;
14502 }
14503
14504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14505         LDKChannelConfig this_ptr_conv;
14506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14507         this_ptr_conv.is_owned = false;
14508         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
14509 }
14510
14511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
14512         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
14513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14515         uint64_t ret_ref = (uint64_t)ret_var.inner;
14516         if (ret_var.is_owned) {
14517                 ret_ref |= 1;
14518         }
14519         return ret_ref;
14520 }
14521
14522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14523         LDKChannelConfig orig_conv;
14524         orig_conv.inner = (void*)(orig & (~1));
14525         orig_conv.is_owned = false;
14526         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
14527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14529         uint64_t ret_ref = (uint64_t)ret_var.inner;
14530         if (ret_var.is_owned) {
14531                 ret_ref |= 1;
14532         }
14533         return ret_ref;
14534 }
14535
14536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
14537         LDKChannelConfig ret_var = ChannelConfig_default();
14538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14540         uint64_t ret_ref = (uint64_t)ret_var.inner;
14541         if (ret_var.is_owned) {
14542                 ret_ref |= 1;
14543         }
14544         return ret_ref;
14545 }
14546
14547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
14548         LDKChannelConfig obj_conv;
14549         obj_conv.inner = (void*)(obj & (~1));
14550         obj_conv.is_owned = false;
14551         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
14552         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14553         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14554         CVec_u8Z_free(ret_var);
14555         return ret_arr;
14556 }
14557
14558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14559         LDKu8slice ser_ref;
14560         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14561         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14562         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14563         *ret_conv = ChannelConfig_read(ser_ref);
14564         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14565         return (uint64_t)ret_conv;
14566 }
14567
14568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14569         LDKUserConfig this_obj_conv;
14570         this_obj_conv.inner = (void*)(this_obj & (~1));
14571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14572         UserConfig_free(this_obj_conv);
14573 }
14574
14575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
14576         LDKUserConfig this_ptr_conv;
14577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14578         this_ptr_conv.is_owned = false;
14579         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
14580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14582         uint64_t ret_ref = (uint64_t)ret_var.inner;
14583         if (ret_var.is_owned) {
14584                 ret_ref |= 1;
14585         }
14586         return ret_ref;
14587 }
14588
14589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14590         LDKUserConfig this_ptr_conv;
14591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14592         this_ptr_conv.is_owned = false;
14593         LDKChannelHandshakeConfig val_conv;
14594         val_conv.inner = (void*)(val & (~1));
14595         val_conv.is_owned = (val & 1) || (val == 0);
14596         val_conv = ChannelHandshakeConfig_clone(&val_conv);
14597         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
14598 }
14599
14600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
14601         LDKUserConfig this_ptr_conv;
14602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14603         this_ptr_conv.is_owned = false;
14604         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
14605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14607         uint64_t ret_ref = (uint64_t)ret_var.inner;
14608         if (ret_var.is_owned) {
14609                 ret_ref |= 1;
14610         }
14611         return ret_ref;
14612 }
14613
14614 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) {
14615         LDKUserConfig this_ptr_conv;
14616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14617         this_ptr_conv.is_owned = false;
14618         LDKChannelHandshakeLimits val_conv;
14619         val_conv.inner = (void*)(val & (~1));
14620         val_conv.is_owned = (val & 1) || (val == 0);
14621         val_conv = ChannelHandshakeLimits_clone(&val_conv);
14622         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
14623 }
14624
14625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
14626         LDKUserConfig this_ptr_conv;
14627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14628         this_ptr_conv.is_owned = false;
14629         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
14630         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14631         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14632         uint64_t ret_ref = (uint64_t)ret_var.inner;
14633         if (ret_var.is_owned) {
14634                 ret_ref |= 1;
14635         }
14636         return ret_ref;
14637 }
14638
14639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14640         LDKUserConfig this_ptr_conv;
14641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14642         this_ptr_conv.is_owned = false;
14643         LDKChannelConfig val_conv;
14644         val_conv.inner = (void*)(val & (~1));
14645         val_conv.is_owned = (val & 1) || (val == 0);
14646         val_conv = ChannelConfig_clone(&val_conv);
14647         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
14648 }
14649
14650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
14651         LDKUserConfig this_ptr_conv;
14652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14653         this_ptr_conv.is_owned = false;
14654         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
14655         return ret_val;
14656 }
14657
14658 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) {
14659         LDKUserConfig this_ptr_conv;
14660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14661         this_ptr_conv.is_owned = false;
14662         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
14663 }
14664
14665 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) {
14666         LDKChannelHandshakeConfig own_channel_config_arg_conv;
14667         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
14668         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
14669         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
14670         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
14671         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
14672         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
14673         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
14674         LDKChannelConfig channel_options_arg_conv;
14675         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
14676         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
14677         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
14678         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);
14679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14681         uint64_t ret_ref = (uint64_t)ret_var.inner;
14682         if (ret_var.is_owned) {
14683                 ret_ref |= 1;
14684         }
14685         return ret_ref;
14686 }
14687
14688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14689         LDKUserConfig orig_conv;
14690         orig_conv.inner = (void*)(orig & (~1));
14691         orig_conv.is_owned = false;
14692         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
14693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14695         uint64_t ret_ref = (uint64_t)ret_var.inner;
14696         if (ret_var.is_owned) {
14697                 ret_ref |= 1;
14698         }
14699         return ret_ref;
14700 }
14701
14702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
14703         LDKUserConfig ret_var = UserConfig_default();
14704         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14705         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14706         uint64_t ret_ref = (uint64_t)ret_var.inner;
14707         if (ret_var.is_owned) {
14708                 ret_ref |= 1;
14709         }
14710         return ret_ref;
14711 }
14712
14713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14714         LDKBestBlock this_obj_conv;
14715         this_obj_conv.inner = (void*)(this_obj & (~1));
14716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14717         BestBlock_free(this_obj_conv);
14718 }
14719
14720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14721         LDKBestBlock orig_conv;
14722         orig_conv.inner = (void*)(orig & (~1));
14723         orig_conv.is_owned = false;
14724         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
14725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14727         uint64_t ret_ref = (uint64_t)ret_var.inner;
14728         if (ret_var.is_owned) {
14729                 ret_ref |= 1;
14730         }
14731         return ret_ref;
14732 }
14733
14734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
14735         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
14736         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
14737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14739         uint64_t ret_ref = (uint64_t)ret_var.inner;
14740         if (ret_var.is_owned) {
14741                 ret_ref |= 1;
14742         }
14743         return ret_ref;
14744 }
14745
14746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
14747         LDKThirtyTwoBytes block_hash_ref;
14748         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
14749         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
14750         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
14751         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14752         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14753         uint64_t ret_ref = (uint64_t)ret_var.inner;
14754         if (ret_var.is_owned) {
14755                 ret_ref |= 1;
14756         }
14757         return ret_ref;
14758 }
14759
14760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14761         LDKBestBlock this_arg_conv;
14762         this_arg_conv.inner = (void*)(this_arg & (~1));
14763         this_arg_conv.is_owned = false;
14764         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
14766         return ret_arr;
14767 }
14768
14769 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
14770         LDKBestBlock this_arg_conv;
14771         this_arg_conv.inner = (void*)(this_arg & (~1));
14772         this_arg_conv.is_owned = false;
14773         int32_t ret_val = BestBlock_height(&this_arg_conv);
14774         return ret_val;
14775 }
14776
14777 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14778         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14779         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14780         return ret_conv;
14781 }
14782
14783 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
14784         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
14785         return ret_conv;
14786 }
14787
14788 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
14789         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
14790         return ret_conv;
14791 }
14792
14793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14794         if ((this_ptr & 1) != 0) return;
14795         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14796         FREE((void*)this_ptr);
14797         Access_free(this_ptr_conv);
14798 }
14799
14800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14801         if ((this_ptr & 1) != 0) return;
14802         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14803         FREE((void*)this_ptr);
14804         Listen_free(this_ptr_conv);
14805 }
14806
14807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14808         if ((this_ptr & 1) != 0) return;
14809         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14810         FREE((void*)this_ptr);
14811         Confirm_free(this_ptr_conv);
14812 }
14813
14814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14815         if ((this_ptr & 1) != 0) return;
14816         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14817         FREE((void*)this_ptr);
14818         Watch_free(this_ptr_conv);
14819 }
14820
14821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14822         if ((this_ptr & 1) != 0) return;
14823         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14824         FREE((void*)this_ptr);
14825         Filter_free(this_ptr_conv);
14826 }
14827
14828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14829         LDKWatchedOutput this_obj_conv;
14830         this_obj_conv.inner = (void*)(this_obj & (~1));
14831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14832         WatchedOutput_free(this_obj_conv);
14833 }
14834
14835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14836         LDKWatchedOutput this_ptr_conv;
14837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14838         this_ptr_conv.is_owned = false;
14839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14841         return ret_arr;
14842 }
14843
14844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14845         LDKWatchedOutput this_ptr_conv;
14846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14847         this_ptr_conv.is_owned = false;
14848         LDKThirtyTwoBytes val_ref;
14849         CHECK((*env)->GetArrayLength(env, val) == 32);
14850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14851         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14852 }
14853
14854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14855         LDKWatchedOutput this_ptr_conv;
14856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14857         this_ptr_conv.is_owned = false;
14858         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14869         LDKWatchedOutput this_ptr_conv;
14870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14871         this_ptr_conv.is_owned = false;
14872         LDKOutPoint val_conv;
14873         val_conv.inner = (void*)(val & (~1));
14874         val_conv.is_owned = (val & 1) || (val == 0);
14875         val_conv = OutPoint_clone(&val_conv);
14876         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14877 }
14878
14879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14880         LDKWatchedOutput this_ptr_conv;
14881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14882         this_ptr_conv.is_owned = false;
14883         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14884         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14885         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14886         return ret_arr;
14887 }
14888
14889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14890         LDKWatchedOutput this_ptr_conv;
14891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14892         this_ptr_conv.is_owned = false;
14893         LDKCVec_u8Z val_ref;
14894         val_ref.datalen = (*env)->GetArrayLength(env, val);
14895         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14896         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14897         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14898 }
14899
14900 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) {
14901         LDKThirtyTwoBytes block_hash_arg_ref;
14902         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14903         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14904         LDKOutPoint outpoint_arg_conv;
14905         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14906         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14907         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14908         LDKCVec_u8Z script_pubkey_arg_ref;
14909         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14910         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14911         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14912         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14915         uint64_t ret_ref = (uint64_t)ret_var.inner;
14916         if (ret_var.is_owned) {
14917                 ret_ref |= 1;
14918         }
14919         return ret_ref;
14920 }
14921
14922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14923         LDKWatchedOutput orig_conv;
14924         orig_conv.inner = (void*)(orig & (~1));
14925         orig_conv.is_owned = false;
14926         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14927         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14928         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14929         uint64_t ret_ref = (uint64_t)ret_var.inner;
14930         if (ret_var.is_owned) {
14931                 ret_ref |= 1;
14932         }
14933         return ret_ref;
14934 }
14935
14936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14937         LDKWatchedOutput o_conv;
14938         o_conv.inner = (void*)(o & (~1));
14939         o_conv.is_owned = false;
14940         int64_t ret_val = WatchedOutput_hash(&o_conv);
14941         return ret_val;
14942 }
14943
14944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14945         if ((this_ptr & 1) != 0) return;
14946         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14947         FREE((void*)this_ptr);
14948         BroadcasterInterface_free(this_ptr_conv);
14949 }
14950
14951 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14952         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14953         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14954         return ret_conv;
14955 }
14956
14957 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
14958         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
14959         return ret_conv;
14960 }
14961
14962 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
14963         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
14964         return ret_conv;
14965 }
14966
14967 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
14968         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
14969         return ret_conv;
14970 }
14971
14972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14973         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
14974         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
14975         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
14976         return ret_val;
14977 }
14978
14979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14980         if ((this_ptr & 1) != 0) return;
14981         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14982         FREE((void*)this_ptr);
14983         FeeEstimator_free(this_ptr_conv);
14984 }
14985
14986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14987         LDKChainMonitor this_obj_conv;
14988         this_obj_conv.inner = (void*)(this_obj & (~1));
14989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14990         ChainMonitor_free(this_obj_conv);
14991 }
14992
14993 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) {
14994         LDKFilter *chain_source_conv_ptr = NULL;
14995         if (chain_source != 0) {
14996                 LDKFilter chain_source_conv;
14997                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14998                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14999                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15000                         LDKFilter_JCalls_cloned(&chain_source_conv);
15001                 }
15002                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
15003                 *chain_source_conv_ptr = chain_source_conv;
15004         }
15005         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15006         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15007                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15008                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15009         }
15010         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15011         if (logger_conv.free == LDKLogger_JCalls_free) {
15012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15013                 LDKLogger_JCalls_cloned(&logger_conv);
15014         }
15015         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
15016         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
15017                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15018                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
15019         }
15020         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
15021         if (persister_conv.free == LDKPersist_JCalls_free) {
15022                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15023                 LDKPersist_JCalls_cloned(&persister_conv);
15024         }
15025         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
15026         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15027         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15028         uint64_t ret_ref = (uint64_t)ret_var.inner;
15029         if (ret_var.is_owned) {
15030                 ret_ref |= 1;
15031         }
15032         return ret_ref;
15033 }
15034
15035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
15036         LDKChainMonitor this_arg_conv;
15037         this_arg_conv.inner = (void*)(this_arg & (~1));
15038         this_arg_conv.is_owned = false;
15039         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
15040         *ret = ChainMonitor_as_Listen(&this_arg_conv);
15041         return (uint64_t)ret;
15042 }
15043
15044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
15045         LDKChainMonitor this_arg_conv;
15046         this_arg_conv.inner = (void*)(this_arg & (~1));
15047         this_arg_conv.is_owned = false;
15048         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15049         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
15050         return (uint64_t)ret;
15051 }
15052
15053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
15054         LDKChainMonitor this_arg_conv;
15055         this_arg_conv.inner = (void*)(this_arg & (~1));
15056         this_arg_conv.is_owned = false;
15057         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
15058         *ret = ChainMonitor_as_Watch(&this_arg_conv);
15059         return (uint64_t)ret;
15060 }
15061
15062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15063         LDKChainMonitor this_arg_conv;
15064         this_arg_conv.inner = (void*)(this_arg & (~1));
15065         this_arg_conv.is_owned = false;
15066         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15067         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
15068         return (uint64_t)ret;
15069 }
15070
15071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15072         LDKChannelMonitorUpdate this_obj_conv;
15073         this_obj_conv.inner = (void*)(this_obj & (~1));
15074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15075         ChannelMonitorUpdate_free(this_obj_conv);
15076 }
15077
15078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15079         LDKChannelMonitorUpdate this_ptr_conv;
15080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15081         this_ptr_conv.is_owned = false;
15082         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
15083         return ret_val;
15084 }
15085
15086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15087         LDKChannelMonitorUpdate this_ptr_conv;
15088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15089         this_ptr_conv.is_owned = false;
15090         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
15091 }
15092
15093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15094         LDKChannelMonitorUpdate orig_conv;
15095         orig_conv.inner = (void*)(orig & (~1));
15096         orig_conv.is_owned = false;
15097         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
15098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15100         uint64_t ret_ref = (uint64_t)ret_var.inner;
15101         if (ret_var.is_owned) {
15102                 ret_ref |= 1;
15103         }
15104         return ret_ref;
15105 }
15106
15107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
15108         LDKChannelMonitorUpdate obj_conv;
15109         obj_conv.inner = (void*)(obj & (~1));
15110         obj_conv.is_owned = false;
15111         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
15112         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15113         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15114         CVec_u8Z_free(ret_var);
15115         return ret_arr;
15116 }
15117
15118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15119         LDKu8slice ser_ref;
15120         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15121         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15122         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15123         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
15124         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15125         return (uint64_t)ret_conv;
15126 }
15127
15128 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15129         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
15130         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
15131         return ret_conv;
15132 }
15133
15134 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
15135         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
15136         return ret_conv;
15137 }
15138
15139 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
15140         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
15141         return ret_conv;
15142 }
15143
15144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15145         LDKMonitorUpdateError this_obj_conv;
15146         this_obj_conv.inner = (void*)(this_obj & (~1));
15147         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15148         MonitorUpdateError_free(this_obj_conv);
15149 }
15150
15151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15152         LDKMonitorUpdateError orig_conv;
15153         orig_conv.inner = (void*)(orig & (~1));
15154         orig_conv.is_owned = false;
15155         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
15156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15158         uint64_t ret_ref = (uint64_t)ret_var.inner;
15159         if (ret_var.is_owned) {
15160                 ret_ref |= 1;
15161         }
15162         return ret_ref;
15163 }
15164
15165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15166         if ((this_ptr & 1) != 0) return;
15167         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
15168         FREE((void*)this_ptr);
15169         MonitorEvent_free(this_ptr_conv);
15170 }
15171
15172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15173         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
15174         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15175         *ret_copy = MonitorEvent_clone(orig_conv);
15176         uint64_t ret_ref = (uint64_t)ret_copy;
15177         return ret_ref;
15178 }
15179
15180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
15181         LDKHTLCUpdate a_conv;
15182         a_conv.inner = (void*)(a & (~1));
15183         a_conv.is_owned = (a & 1) || (a == 0);
15184         a_conv = HTLCUpdate_clone(&a_conv);
15185         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15186         *ret_copy = MonitorEvent_htlcevent(a_conv);
15187         uint64_t ret_ref = (uint64_t)ret_copy;
15188         return ret_ref;
15189 }
15190
15191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted(JNIEnv *env, jclass clz, int64_t a) {
15192         LDKOutPoint a_conv;
15193         a_conv.inner = (void*)(a & (~1));
15194         a_conv.is_owned = (a & 1) || (a == 0);
15195         a_conv = OutPoint_clone(&a_conv);
15196         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15197         *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv);
15198         uint64_t ret_ref = (uint64_t)ret_copy;
15199         return ret_ref;
15200 }
15201
15202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15203         LDKHTLCUpdate this_obj_conv;
15204         this_obj_conv.inner = (void*)(this_obj & (~1));
15205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15206         HTLCUpdate_free(this_obj_conv);
15207 }
15208
15209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15210         LDKHTLCUpdate orig_conv;
15211         orig_conv.inner = (void*)(orig & (~1));
15212         orig_conv.is_owned = false;
15213         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
15214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15216         uint64_t ret_ref = (uint64_t)ret_var.inner;
15217         if (ret_var.is_owned) {
15218                 ret_ref |= 1;
15219         }
15220         return ret_ref;
15221 }
15222
15223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
15224         LDKHTLCUpdate obj_conv;
15225         obj_conv.inner = (void*)(obj & (~1));
15226         obj_conv.is_owned = false;
15227         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
15228         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15229         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15230         CVec_u8Z_free(ret_var);
15231         return ret_arr;
15232 }
15233
15234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15235         LDKu8slice ser_ref;
15236         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15237         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15238         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15239         *ret_conv = HTLCUpdate_read(ser_ref);
15240         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15241         return (uint64_t)ret_conv;
15242 }
15243
15244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15245         LDKChannelMonitor this_obj_conv;
15246         this_obj_conv.inner = (void*)(this_obj & (~1));
15247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15248         ChannelMonitor_free(this_obj_conv);
15249 }
15250
15251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15252         LDKChannelMonitor orig_conv;
15253         orig_conv.inner = (void*)(orig & (~1));
15254         orig_conv.is_owned = false;
15255         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
15256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15258         uint64_t ret_ref = (uint64_t)ret_var.inner;
15259         if (ret_var.is_owned) {
15260                 ret_ref |= 1;
15261         }
15262         return ret_ref;
15263 }
15264
15265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15266         LDKChannelMonitor obj_conv;
15267         obj_conv.inner = (void*)(obj & (~1));
15268         obj_conv.is_owned = false;
15269         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
15270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15272         CVec_u8Z_free(ret_var);
15273         return ret_arr;
15274 }
15275
15276 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) {
15277         LDKChannelMonitor this_arg_conv;
15278         this_arg_conv.inner = (void*)(this_arg & (~1));
15279         this_arg_conv.is_owned = false;
15280         LDKChannelMonitorUpdate updates_conv;
15281         updates_conv.inner = (void*)(updates & (~1));
15282         updates_conv.is_owned = false;
15283         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15284         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15285         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
15286         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15287         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
15288         return (uint64_t)ret_conv;
15289 }
15290
15291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15292         LDKChannelMonitor this_arg_conv;
15293         this_arg_conv.inner = (void*)(this_arg & (~1));
15294         this_arg_conv.is_owned = false;
15295         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
15296         return ret_val;
15297 }
15298
15299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
15300         LDKChannelMonitor this_arg_conv;
15301         this_arg_conv.inner = (void*)(this_arg & (~1));
15302         this_arg_conv.is_owned = false;
15303         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15304         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
15305         return (uint64_t)ret_ref;
15306 }
15307
15308 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
15309         LDKChannelMonitor this_arg_conv;
15310         this_arg_conv.inner = (void*)(this_arg & (~1));
15311         this_arg_conv.is_owned = false;
15312         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
15313         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15314         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15315         for (size_t v = 0; v < ret_var.datalen; v++) {
15316                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15317                 *ret_conv_47_ref = ret_var.data[v];
15318                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
15319         }
15320         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15321         FREE(ret_var.data);
15322         return ret_arr;
15323 }
15324
15325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
15326         LDKChannelMonitor this_arg_conv;
15327         this_arg_conv.inner = (void*)(this_arg & (~1));
15328         this_arg_conv.is_owned = false;
15329         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
15330         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
15331 }
15332
15333 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
15334         LDKChannelMonitor this_arg_conv;
15335         this_arg_conv.inner = (void*)(this_arg & (~1));
15336         this_arg_conv.is_owned = false;
15337         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
15338         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15339         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15340         for (size_t o = 0; o < ret_var.datalen; o++) {
15341                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15342                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
15343                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
15344                 ret_arr_ptr[o] = ret_conv_14_ref;
15345         }
15346         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15347         FREE(ret_var.data);
15348         return ret_arr;
15349 }
15350
15351 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
15352         LDKChannelMonitor this_arg_conv;
15353         this_arg_conv.inner = (void*)(this_arg & (~1));
15354         this_arg_conv.is_owned = false;
15355         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
15356         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15357         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15358         for (size_t h = 0; h < ret_var.datalen; h++) {
15359                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15360                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
15361                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
15362                 ret_arr_ptr[h] = ret_conv_7_ref;
15363         }
15364         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15365         FREE(ret_var.data);
15366         return ret_arr;
15367 }
15368
15369 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) {
15370         LDKChannelMonitor this_arg_conv;
15371         this_arg_conv.inner = (void*)(this_arg & (~1));
15372         this_arg_conv.is_owned = false;
15373         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
15374         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
15375         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15376         ;
15377         for (size_t i = 0; i < ret_var.datalen; i++) {
15378                 LDKTransaction ret_conv_8_var = ret_var.data[i];
15379                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
15380                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
15381                 Transaction_free(ret_conv_8_var);
15382                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15383         }
15384         FREE(ret_var.data);
15385         return ret_arr;
15386 }
15387
15388 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) {
15389         LDKChannelMonitor this_arg_conv;
15390         this_arg_conv.inner = (void*)(this_arg & (~1));
15391         this_arg_conv.is_owned = false;
15392         unsigned char header_arr[80];
15393         CHECK((*env)->GetArrayLength(env, header) == 80);
15394         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15395         unsigned char (*header_ref)[80] = &header_arr;
15396         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15397         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15398         if (txdata_constr.datalen > 0)
15399                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15400         else
15401                 txdata_constr.data = NULL;
15402         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15403         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15404                 int64_t txdata_conv_24 = txdata_vals[y];
15405                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15406                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15407                 txdata_constr.data[y] = txdata_conv_24_conv;
15408         }
15409         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15410         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15411         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15412                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15413                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15414         }
15415         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15416         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15417                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15418                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15419         }
15420         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15421         if (logger_conv.free == LDKLogger_JCalls_free) {
15422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15423                 LDKLogger_JCalls_cloned(&logger_conv);
15424         }
15425         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);
15426         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15427         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15428         for (size_t u = 0; u < ret_var.datalen; u++) {
15429                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15430                 *ret_conv_46_ref = ret_var.data[u];
15431                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15432         }
15433         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15434         FREE(ret_var.data);
15435         return ret_arr;
15436 }
15437
15438 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) {
15439         LDKChannelMonitor this_arg_conv;
15440         this_arg_conv.inner = (void*)(this_arg & (~1));
15441         this_arg_conv.is_owned = false;
15442         unsigned char header_arr[80];
15443         CHECK((*env)->GetArrayLength(env, header) == 80);
15444         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15445         unsigned char (*header_ref)[80] = &header_arr;
15446         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15447         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15448                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15449                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15450         }
15451         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15452         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15453                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15454                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15455         }
15456         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15457         if (logger_conv.free == LDKLogger_JCalls_free) {
15458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15459                 LDKLogger_JCalls_cloned(&logger_conv);
15460         }
15461         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15462 }
15463
15464 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) {
15465         LDKChannelMonitor this_arg_conv;
15466         this_arg_conv.inner = (void*)(this_arg & (~1));
15467         this_arg_conv.is_owned = false;
15468         unsigned char header_arr[80];
15469         CHECK((*env)->GetArrayLength(env, header) == 80);
15470         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15471         unsigned char (*header_ref)[80] = &header_arr;
15472         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15473         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15474         if (txdata_constr.datalen > 0)
15475                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15476         else
15477                 txdata_constr.data = NULL;
15478         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15479         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15480                 int64_t txdata_conv_24 = txdata_vals[y];
15481                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15482                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15483                 txdata_constr.data[y] = txdata_conv_24_conv;
15484         }
15485         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15486         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15487         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15488                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15489                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15490         }
15491         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15492         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15493                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15494                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15495         }
15496         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15497         if (logger_conv.free == LDKLogger_JCalls_free) {
15498                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15499                 LDKLogger_JCalls_cloned(&logger_conv);
15500         }
15501         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);
15502         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15503         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15504         for (size_t u = 0; u < ret_var.datalen; u++) {
15505                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15506                 *ret_conv_46_ref = ret_var.data[u];
15507                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15508         }
15509         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15510         FREE(ret_var.data);
15511         return ret_arr;
15512 }
15513
15514 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) {
15515         LDKChannelMonitor this_arg_conv;
15516         this_arg_conv.inner = (void*)(this_arg & (~1));
15517         this_arg_conv.is_owned = false;
15518         unsigned char txid_arr[32];
15519         CHECK((*env)->GetArrayLength(env, txid) == 32);
15520         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
15521         unsigned char (*txid_ref)[32] = &txid_arr;
15522         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15523         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15525                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15526         }
15527         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15528         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15529                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15530                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15531         }
15532         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15533         if (logger_conv.free == LDKLogger_JCalls_free) {
15534                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15535                 LDKLogger_JCalls_cloned(&logger_conv);
15536         }
15537         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
15538 }
15539
15540 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) {
15541         LDKChannelMonitor this_arg_conv;
15542         this_arg_conv.inner = (void*)(this_arg & (~1));
15543         this_arg_conv.is_owned = false;
15544         unsigned char header_arr[80];
15545         CHECK((*env)->GetArrayLength(env, header) == 80);
15546         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15547         unsigned char (*header_ref)[80] = &header_arr;
15548         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15549         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15550                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15551                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15552         }
15553         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15554         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15556                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15557         }
15558         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15559         if (logger_conv.free == LDKLogger_JCalls_free) {
15560                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15561                 LDKLogger_JCalls_cloned(&logger_conv);
15562         }
15563         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15564         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15565         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15566         for (size_t u = 0; u < ret_var.datalen; u++) {
15567                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15568                 *ret_conv_46_ref = ret_var.data[u];
15569                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15570         }
15571         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15572         FREE(ret_var.data);
15573         return ret_arr;
15574 }
15575
15576 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
15577         LDKChannelMonitor this_arg_conv;
15578         this_arg_conv.inner = (void*)(this_arg & (~1));
15579         this_arg_conv.is_owned = false;
15580         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
15581         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15582         ;
15583         for (size_t i = 0; i < ret_var.datalen; i++) {
15584                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
15585                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
15586                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15587         }
15588         FREE(ret_var.data);
15589         return ret_arr;
15590 }
15591
15592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
15593         LDKChannelMonitor this_arg_conv;
15594         this_arg_conv.inner = (void*)(this_arg & (~1));
15595         this_arg_conv.is_owned = false;
15596         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
15597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15599         uint64_t ret_ref = (uint64_t)ret_var.inner;
15600         if (ret_var.is_owned) {
15601                 ret_ref |= 1;
15602         }
15603         return ret_ref;
15604 }
15605
15606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15607         if ((this_ptr & 1) != 0) return;
15608         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
15609         FREE((void*)this_ptr);
15610         Persist_free(this_ptr_conv);
15611 }
15612
15613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
15614         LDKu8slice ser_ref;
15615         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15616         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15617         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
15618         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
15619         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
15620         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15621         return (uint64_t)ret_conv;
15622 }
15623
15624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15625         LDKOutPoint this_obj_conv;
15626         this_obj_conv.inner = (void*)(this_obj & (~1));
15627         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15628         OutPoint_free(this_obj_conv);
15629 }
15630
15631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
15632         LDKOutPoint this_ptr_conv;
15633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15634         this_ptr_conv.is_owned = false;
15635         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15636         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
15637         return ret_arr;
15638 }
15639
15640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15641         LDKOutPoint this_ptr_conv;
15642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15643         this_ptr_conv.is_owned = false;
15644         LDKThirtyTwoBytes val_ref;
15645         CHECK((*env)->GetArrayLength(env, val) == 32);
15646         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15647         OutPoint_set_txid(&this_ptr_conv, val_ref);
15648 }
15649
15650 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
15651         LDKOutPoint this_ptr_conv;
15652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15653         this_ptr_conv.is_owned = false;
15654         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
15655         return ret_val;
15656 }
15657
15658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15659         LDKOutPoint this_ptr_conv;
15660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15661         this_ptr_conv.is_owned = false;
15662         OutPoint_set_index(&this_ptr_conv, val);
15663 }
15664
15665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
15666         LDKThirtyTwoBytes txid_arg_ref;
15667         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
15668         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
15669         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
15670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15672         uint64_t ret_ref = (uint64_t)ret_var.inner;
15673         if (ret_var.is_owned) {
15674                 ret_ref |= 1;
15675         }
15676         return ret_ref;
15677 }
15678
15679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15680         LDKOutPoint orig_conv;
15681         orig_conv.inner = (void*)(orig & (~1));
15682         orig_conv.is_owned = false;
15683         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
15684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15686         uint64_t ret_ref = (uint64_t)ret_var.inner;
15687         if (ret_var.is_owned) {
15688                 ret_ref |= 1;
15689         }
15690         return ret_ref;
15691 }
15692
15693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15694         LDKOutPoint a_conv;
15695         a_conv.inner = (void*)(a & (~1));
15696         a_conv.is_owned = false;
15697         LDKOutPoint b_conv;
15698         b_conv.inner = (void*)(b & (~1));
15699         b_conv.is_owned = false;
15700         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
15701         return ret_val;
15702 }
15703
15704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
15705         LDKOutPoint o_conv;
15706         o_conv.inner = (void*)(o & (~1));
15707         o_conv.is_owned = false;
15708         int64_t ret_val = OutPoint_hash(&o_conv);
15709         return ret_val;
15710 }
15711
15712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15713         LDKOutPoint this_arg_conv;
15714         this_arg_conv.inner = (void*)(this_arg & (~1));
15715         this_arg_conv.is_owned = false;
15716         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
15718         return ret_arr;
15719 }
15720
15721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
15722         LDKOutPoint obj_conv;
15723         obj_conv.inner = (void*)(obj & (~1));
15724         obj_conv.is_owned = false;
15725         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
15726         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15727         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15728         CVec_u8Z_free(ret_var);
15729         return ret_arr;
15730 }
15731
15732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15733         LDKu8slice ser_ref;
15734         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15735         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15736         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15737         *ret_conv = OutPoint_read(ser_ref);
15738         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15739         return (uint64_t)ret_conv;
15740 }
15741
15742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15743         LDKDelayedPaymentOutputDescriptor this_obj_conv;
15744         this_obj_conv.inner = (void*)(this_obj & (~1));
15745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15746         DelayedPaymentOutputDescriptor_free(this_obj_conv);
15747 }
15748
15749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15750         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15752         this_ptr_conv.is_owned = false;
15753         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15754         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15755         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15756         uint64_t ret_ref = (uint64_t)ret_var.inner;
15757         if (ret_var.is_owned) {
15758                 ret_ref |= 1;
15759         }
15760         return ret_ref;
15761 }
15762
15763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15764         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15766         this_ptr_conv.is_owned = false;
15767         LDKOutPoint val_conv;
15768         val_conv.inner = (void*)(val & (~1));
15769         val_conv.is_owned = (val & 1) || (val == 0);
15770         val_conv = OutPoint_clone(&val_conv);
15771         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15772 }
15773
15774 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15775         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15777         this_ptr_conv.is_owned = false;
15778         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
15780         return ret_arr;
15781 }
15782
15783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15784         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15786         this_ptr_conv.is_owned = false;
15787         LDKPublicKey val_ref;
15788         CHECK((*env)->GetArrayLength(env, val) == 33);
15789         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15790         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
15791 }
15792
15793 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15794         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15796         this_ptr_conv.is_owned = false;
15797         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
15798         return ret_val;
15799 }
15800
15801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15802         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15804         this_ptr_conv.is_owned = false;
15805         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
15806 }
15807
15808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15809         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15811         this_ptr_conv.is_owned = false;
15812         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15813         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15814 }
15815
15816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15817         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15819         this_ptr_conv.is_owned = false;
15820         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
15822         return ret_arr;
15823 }
15824
15825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15826         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15828         this_ptr_conv.is_owned = false;
15829         LDKPublicKey val_ref;
15830         CHECK((*env)->GetArrayLength(env, val) == 33);
15831         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15832         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
15833 }
15834
15835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15836         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15838         this_ptr_conv.is_owned = false;
15839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15841         return ret_arr;
15842 }
15843
15844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15845         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15847         this_ptr_conv.is_owned = false;
15848         LDKThirtyTwoBytes val_ref;
15849         CHECK((*env)->GetArrayLength(env, val) == 32);
15850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15851         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15852 }
15853
15854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15855         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15857         this_ptr_conv.is_owned = false;
15858         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15859         return ret_val;
15860 }
15861
15862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15863         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15865         this_ptr_conv.is_owned = false;
15866         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15867 }
15868
15869 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) {
15870         LDKOutPoint outpoint_arg_conv;
15871         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15872         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15873         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15874         LDKPublicKey per_commitment_point_arg_ref;
15875         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15876         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15877         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15878         LDKPublicKey revocation_pubkey_arg_ref;
15879         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15880         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15881         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15882         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15883         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15884         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);
15885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15887         uint64_t ret_ref = (uint64_t)ret_var.inner;
15888         if (ret_var.is_owned) {
15889                 ret_ref |= 1;
15890         }
15891         return ret_ref;
15892 }
15893
15894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15895         LDKDelayedPaymentOutputDescriptor orig_conv;
15896         orig_conv.inner = (void*)(orig & (~1));
15897         orig_conv.is_owned = false;
15898         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15901         uint64_t ret_ref = (uint64_t)ret_var.inner;
15902         if (ret_var.is_owned) {
15903                 ret_ref |= 1;
15904         }
15905         return ret_ref;
15906 }
15907
15908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15909         LDKDelayedPaymentOutputDescriptor obj_conv;
15910         obj_conv.inner = (void*)(obj & (~1));
15911         obj_conv.is_owned = false;
15912         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15915         CVec_u8Z_free(ret_var);
15916         return ret_arr;
15917 }
15918
15919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15920         LDKu8slice ser_ref;
15921         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15922         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15923         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15924         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15925         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15926         return (uint64_t)ret_conv;
15927 }
15928
15929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15930         LDKStaticPaymentOutputDescriptor this_obj_conv;
15931         this_obj_conv.inner = (void*)(this_obj & (~1));
15932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15933         StaticPaymentOutputDescriptor_free(this_obj_conv);
15934 }
15935
15936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15937         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15939         this_ptr_conv.is_owned = false;
15940         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15943         uint64_t ret_ref = (uint64_t)ret_var.inner;
15944         if (ret_var.is_owned) {
15945                 ret_ref |= 1;
15946         }
15947         return ret_ref;
15948 }
15949
15950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15951         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15953         this_ptr_conv.is_owned = false;
15954         LDKOutPoint val_conv;
15955         val_conv.inner = (void*)(val & (~1));
15956         val_conv.is_owned = (val & 1) || (val == 0);
15957         val_conv = OutPoint_clone(&val_conv);
15958         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15959 }
15960
15961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15962         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15964         this_ptr_conv.is_owned = false;
15965         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15966         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15967 }
15968
15969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15970         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15972         this_ptr_conv.is_owned = false;
15973         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15974         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15975         return ret_arr;
15976 }
15977
15978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15979         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15981         this_ptr_conv.is_owned = false;
15982         LDKThirtyTwoBytes val_ref;
15983         CHECK((*env)->GetArrayLength(env, val) == 32);
15984         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15985         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15986 }
15987
15988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15989         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15991         this_ptr_conv.is_owned = false;
15992         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15993         return ret_val;
15994 }
15995
15996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15997         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15999         this_ptr_conv.is_owned = false;
16000         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
16001 }
16002
16003 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) {
16004         LDKOutPoint outpoint_arg_conv;
16005         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
16006         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
16007         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
16008         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
16009         LDKThirtyTwoBytes channel_keys_id_arg_ref;
16010         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
16011         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
16012         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
16013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16015         uint64_t ret_ref = (uint64_t)ret_var.inner;
16016         if (ret_var.is_owned) {
16017                 ret_ref |= 1;
16018         }
16019         return ret_ref;
16020 }
16021
16022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16023         LDKStaticPaymentOutputDescriptor orig_conv;
16024         orig_conv.inner = (void*)(orig & (~1));
16025         orig_conv.is_owned = false;
16026         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
16027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16029         uint64_t ret_ref = (uint64_t)ret_var.inner;
16030         if (ret_var.is_owned) {
16031                 ret_ref |= 1;
16032         }
16033         return ret_ref;
16034 }
16035
16036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
16037         LDKStaticPaymentOutputDescriptor obj_conv;
16038         obj_conv.inner = (void*)(obj & (~1));
16039         obj_conv.is_owned = false;
16040         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
16041         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16042         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16043         CVec_u8Z_free(ret_var);
16044         return ret_arr;
16045 }
16046
16047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16048         LDKu8slice ser_ref;
16049         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16050         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16051         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16052         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
16053         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16054         return (uint64_t)ret_conv;
16055 }
16056
16057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16058         if ((this_ptr & 1) != 0) return;
16059         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
16060         FREE((void*)this_ptr);
16061         SpendableOutputDescriptor_free(this_ptr_conv);
16062 }
16063
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16065         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
16066         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16067         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
16068         uint64_t ret_ref = (uint64_t)ret_copy;
16069         return ret_ref;
16070 }
16071
16072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
16073         LDKOutPoint outpoint_conv;
16074         outpoint_conv.inner = (void*)(outpoint & (~1));
16075         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
16076         outpoint_conv = OutPoint_clone(&outpoint_conv);
16077         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
16078         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16079         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
16080         uint64_t ret_ref = (uint64_t)ret_copy;
16081         return ret_ref;
16082 }
16083
16084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
16085         LDKDelayedPaymentOutputDescriptor a_conv;
16086         a_conv.inner = (void*)(a & (~1));
16087         a_conv.is_owned = (a & 1) || (a == 0);
16088         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
16089         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16090         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
16091         uint64_t ret_ref = (uint64_t)ret_copy;
16092         return ret_ref;
16093 }
16094
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
16096         LDKStaticPaymentOutputDescriptor a_conv;
16097         a_conv.inner = (void*)(a & (~1));
16098         a_conv.is_owned = (a & 1) || (a == 0);
16099         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
16100         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16101         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
16102         uint64_t ret_ref = (uint64_t)ret_copy;
16103         return ret_ref;
16104 }
16105
16106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
16107         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
16108         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
16109         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16110         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16111         CVec_u8Z_free(ret_var);
16112         return ret_arr;
16113 }
16114
16115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16116         LDKu8slice ser_ref;
16117         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16118         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16119         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16120         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
16121         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16122         return (uint64_t)ret_conv;
16123 }
16124
16125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16126         if ((this_ptr & 1) != 0) return;
16127         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
16128         FREE((void*)this_ptr);
16129         BaseSign_free(this_ptr_conv);
16130 }
16131
16132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16133         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
16134         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
16135         *ret = Sign_clone(orig_conv);
16136         return (uint64_t)ret;
16137 }
16138
16139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16140         if ((this_ptr & 1) != 0) return;
16141         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
16142         FREE((void*)this_ptr);
16143         Sign_free(this_ptr_conv);
16144 }
16145
16146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16147         if ((this_ptr & 1) != 0) return;
16148         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
16149         FREE((void*)this_ptr);
16150         KeysInterface_free(this_ptr_conv);
16151 }
16152
16153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16154         LDKInMemorySigner this_obj_conv;
16155         this_obj_conv.inner = (void*)(this_obj & (~1));
16156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16157         InMemorySigner_free(this_obj_conv);
16158 }
16159
16160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16161         LDKInMemorySigner this_ptr_conv;
16162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16163         this_ptr_conv.is_owned = false;
16164         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16165         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
16166         return ret_arr;
16167 }
16168
16169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16170         LDKInMemorySigner this_ptr_conv;
16171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16172         this_ptr_conv.is_owned = false;
16173         LDKSecretKey val_ref;
16174         CHECK((*env)->GetArrayLength(env, val) == 32);
16175         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16176         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
16177 }
16178
16179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16180         LDKInMemorySigner this_ptr_conv;
16181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16182         this_ptr_conv.is_owned = false;
16183         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16184         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
16185         return ret_arr;
16186 }
16187
16188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16189         LDKInMemorySigner this_ptr_conv;
16190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16191         this_ptr_conv.is_owned = false;
16192         LDKSecretKey val_ref;
16193         CHECK((*env)->GetArrayLength(env, val) == 32);
16194         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16195         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
16196 }
16197
16198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16199         LDKInMemorySigner this_ptr_conv;
16200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16201         this_ptr_conv.is_owned = false;
16202         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
16204         return ret_arr;
16205 }
16206
16207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16208         LDKInMemorySigner this_ptr_conv;
16209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16210         this_ptr_conv.is_owned = false;
16211         LDKSecretKey val_ref;
16212         CHECK((*env)->GetArrayLength(env, val) == 32);
16213         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16214         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
16215 }
16216
16217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16218         LDKInMemorySigner this_ptr_conv;
16219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16220         this_ptr_conv.is_owned = false;
16221         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
16223         return ret_arr;
16224 }
16225
16226 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) {
16227         LDKInMemorySigner this_ptr_conv;
16228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16229         this_ptr_conv.is_owned = false;
16230         LDKSecretKey val_ref;
16231         CHECK((*env)->GetArrayLength(env, val) == 32);
16232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16233         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
16234 }
16235
16236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16237         LDKInMemorySigner this_ptr_conv;
16238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16239         this_ptr_conv.is_owned = false;
16240         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
16242         return ret_arr;
16243 }
16244
16245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16246         LDKInMemorySigner this_ptr_conv;
16247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16248         this_ptr_conv.is_owned = false;
16249         LDKSecretKey val_ref;
16250         CHECK((*env)->GetArrayLength(env, val) == 32);
16251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16252         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
16253 }
16254
16255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
16256         LDKInMemorySigner this_ptr_conv;
16257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16258         this_ptr_conv.is_owned = false;
16259         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
16261         return ret_arr;
16262 }
16263
16264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16265         LDKInMemorySigner this_ptr_conv;
16266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16267         this_ptr_conv.is_owned = false;
16268         LDKThirtyTwoBytes val_ref;
16269         CHECK((*env)->GetArrayLength(env, val) == 32);
16270         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16271         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
16272 }
16273
16274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16275         LDKInMemorySigner orig_conv;
16276         orig_conv.inner = (void*)(orig & (~1));
16277         orig_conv.is_owned = false;
16278         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
16279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16281         uint64_t ret_ref = (uint64_t)ret_var.inner;
16282         if (ret_var.is_owned) {
16283                 ret_ref |= 1;
16284         }
16285         return ret_ref;
16286 }
16287
16288 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) {
16289         LDKSecretKey funding_key_ref;
16290         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
16291         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
16292         LDKSecretKey revocation_base_key_ref;
16293         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
16294         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
16295         LDKSecretKey payment_key_ref;
16296         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
16297         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
16298         LDKSecretKey delayed_payment_base_key_ref;
16299         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
16300         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
16301         LDKSecretKey htlc_base_key_ref;
16302         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
16303         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
16304         LDKThirtyTwoBytes commitment_seed_ref;
16305         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
16306         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
16307         LDKThirtyTwoBytes channel_keys_id_ref;
16308         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
16309         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
16310         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);
16311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16313         uint64_t ret_ref = (uint64_t)ret_var.inner;
16314         if (ret_var.is_owned) {
16315                 ret_ref |= 1;
16316         }
16317         return ret_ref;
16318 }
16319
16320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
16321         LDKInMemorySigner this_arg_conv;
16322         this_arg_conv.inner = (void*)(this_arg & (~1));
16323         this_arg_conv.is_owned = false;
16324         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
16325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16327         uint64_t ret_ref = (uint64_t)ret_var.inner;
16328         if (ret_var.is_owned) {
16329                 ret_ref |= 1;
16330         }
16331         return ret_ref;
16332 }
16333
16334 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
16335         LDKInMemorySigner this_arg_conv;
16336         this_arg_conv.inner = (void*)(this_arg & (~1));
16337         this_arg_conv.is_owned = false;
16338         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
16339         return ret_val;
16340 }
16341
16342 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
16343         LDKInMemorySigner this_arg_conv;
16344         this_arg_conv.inner = (void*)(this_arg & (~1));
16345         this_arg_conv.is_owned = false;
16346         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
16347         return ret_val;
16348 }
16349
16350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
16351         LDKInMemorySigner this_arg_conv;
16352         this_arg_conv.inner = (void*)(this_arg & (~1));
16353         this_arg_conv.is_owned = false;
16354         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
16355         return ret_val;
16356 }
16357
16358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
16359         LDKInMemorySigner this_arg_conv;
16360         this_arg_conv.inner = (void*)(this_arg & (~1));
16361         this_arg_conv.is_owned = false;
16362         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
16363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16365         uint64_t ret_ref = (uint64_t)ret_var.inner;
16366         if (ret_var.is_owned) {
16367                 ret_ref |= 1;
16368         }
16369         return ret_ref;
16370 }
16371
16372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
16373         LDKInMemorySigner this_arg_conv;
16374         this_arg_conv.inner = (void*)(this_arg & (~1));
16375         this_arg_conv.is_owned = false;
16376         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
16377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16379         uint64_t ret_ref = (uint64_t)ret_var.inner;
16380         if (ret_var.is_owned) {
16381                 ret_ref |= 1;
16382         }
16383         return ret_ref;
16384 }
16385
16386 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) {
16387         LDKInMemorySigner this_arg_conv;
16388         this_arg_conv.inner = (void*)(this_arg & (~1));
16389         this_arg_conv.is_owned = false;
16390         LDKTransaction spend_tx_ref;
16391         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16392         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16393         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16394         spend_tx_ref.data_is_owned = true;
16395         LDKStaticPaymentOutputDescriptor descriptor_conv;
16396         descriptor_conv.inner = (void*)(descriptor & (~1));
16397         descriptor_conv.is_owned = false;
16398         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16399         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16400         return (uint64_t)ret_conv;
16401 }
16402
16403 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) {
16404         LDKInMemorySigner this_arg_conv;
16405         this_arg_conv.inner = (void*)(this_arg & (~1));
16406         this_arg_conv.is_owned = false;
16407         LDKTransaction spend_tx_ref;
16408         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16409         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16410         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16411         spend_tx_ref.data_is_owned = true;
16412         LDKDelayedPaymentOutputDescriptor descriptor_conv;
16413         descriptor_conv.inner = (void*)(descriptor & (~1));
16414         descriptor_conv.is_owned = false;
16415         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16416         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16417         return (uint64_t)ret_conv;
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
16421         LDKInMemorySigner this_arg_conv;
16422         this_arg_conv.inner = (void*)(this_arg & (~1));
16423         this_arg_conv.is_owned = false;
16424         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
16425         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
16426         return (uint64_t)ret;
16427 }
16428
16429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
16430         LDKInMemorySigner this_arg_conv;
16431         this_arg_conv.inner = (void*)(this_arg & (~1));
16432         this_arg_conv.is_owned = false;
16433         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
16434         *ret = InMemorySigner_as_Sign(&this_arg_conv);
16435         return (uint64_t)ret;
16436 }
16437
16438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
16439         LDKInMemorySigner obj_conv;
16440         obj_conv.inner = (void*)(obj & (~1));
16441         obj_conv.is_owned = false;
16442         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
16443         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16444         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16445         CVec_u8Z_free(ret_var);
16446         return ret_arr;
16447 }
16448
16449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16450         LDKu8slice ser_ref;
16451         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16452         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16453         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16454         *ret_conv = InMemorySigner_read(ser_ref);
16455         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16456         return (uint64_t)ret_conv;
16457 }
16458
16459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16460         LDKKeysManager this_obj_conv;
16461         this_obj_conv.inner = (void*)(this_obj & (~1));
16462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16463         KeysManager_free(this_obj_conv);
16464 }
16465
16466 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) {
16467         unsigned char seed_arr[32];
16468         CHECK((*env)->GetArrayLength(env, seed) == 32);
16469         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
16470         unsigned char (*seed_ref)[32] = &seed_arr;
16471         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
16472         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16473         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16474         uint64_t ret_ref = (uint64_t)ret_var.inner;
16475         if (ret_var.is_owned) {
16476                 ret_ref |= 1;
16477         }
16478         return ret_ref;
16479 }
16480
16481 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) {
16482         LDKKeysManager this_arg_conv;
16483         this_arg_conv.inner = (void*)(this_arg & (~1));
16484         this_arg_conv.is_owned = false;
16485         unsigned char params_arr[32];
16486         CHECK((*env)->GetArrayLength(env, params) == 32);
16487         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
16488         unsigned char (*params_ref)[32] = &params_arr;
16489         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
16490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16492         uint64_t ret_ref = (uint64_t)ret_var.inner;
16493         if (ret_var.is_owned) {
16494                 ret_ref |= 1;
16495         }
16496         return ret_ref;
16497 }
16498
16499 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) {
16500         LDKKeysManager this_arg_conv;
16501         this_arg_conv.inner = (void*)(this_arg & (~1));
16502         this_arg_conv.is_owned = false;
16503         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
16504         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
16505         if (descriptors_constr.datalen > 0)
16506                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16507         else
16508                 descriptors_constr.data = NULL;
16509         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
16510         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
16511                 int64_t descriptors_conv_27 = descriptors_vals[b];
16512                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
16513                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
16514                 descriptors_constr.data[b] = descriptors_conv_27_conv;
16515         }
16516         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
16517         LDKCVec_TxOutZ outputs_constr;
16518         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
16519         if (outputs_constr.datalen > 0)
16520                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16521         else
16522                 outputs_constr.data = NULL;
16523         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
16524         for (size_t h = 0; h < outputs_constr.datalen; h++) {
16525                 int64_t outputs_conv_7 = outputs_vals[h];
16526                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
16527                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
16528                 outputs_constr.data[h] = outputs_conv_7_conv;
16529         }
16530         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
16531         LDKCVec_u8Z change_destination_script_ref;
16532         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
16533         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
16534         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
16535         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16536         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
16537         return (uint64_t)ret_conv;
16538 }
16539
16540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
16541         LDKKeysManager this_arg_conv;
16542         this_arg_conv.inner = (void*)(this_arg & (~1));
16543         this_arg_conv.is_owned = false;
16544         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
16545         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
16546         return (uint64_t)ret;
16547 }
16548
16549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16550         LDKChannelManager this_obj_conv;
16551         this_obj_conv.inner = (void*)(this_obj & (~1));
16552         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16553         ChannelManager_free(this_obj_conv);
16554 }
16555
16556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16557         LDKChainParameters this_obj_conv;
16558         this_obj_conv.inner = (void*)(this_obj & (~1));
16559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16560         ChainParameters_free(this_obj_conv);
16561 }
16562
16563 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
16564         LDKChainParameters this_ptr_conv;
16565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16566         this_ptr_conv.is_owned = false;
16567         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
16568         return ret_conv;
16569 }
16570
16571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
16572         LDKChainParameters this_ptr_conv;
16573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16574         this_ptr_conv.is_owned = false;
16575         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
16576         ChainParameters_set_network(&this_ptr_conv, val_conv);
16577 }
16578
16579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
16580         LDKChainParameters this_ptr_conv;
16581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16582         this_ptr_conv.is_owned = false;
16583         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
16584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16586         uint64_t ret_ref = (uint64_t)ret_var.inner;
16587         if (ret_var.is_owned) {
16588                 ret_ref |= 1;
16589         }
16590         return ret_ref;
16591 }
16592
16593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16594         LDKChainParameters this_ptr_conv;
16595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16596         this_ptr_conv.is_owned = false;
16597         LDKBestBlock val_conv;
16598         val_conv.inner = (void*)(val & (~1));
16599         val_conv.is_owned = (val & 1) || (val == 0);
16600         val_conv = BestBlock_clone(&val_conv);
16601         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
16602 }
16603
16604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
16605         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
16606         LDKBestBlock best_block_arg_conv;
16607         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
16608         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
16609         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
16610         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
16611         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16612         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16613         uint64_t ret_ref = (uint64_t)ret_var.inner;
16614         if (ret_var.is_owned) {
16615                 ret_ref |= 1;
16616         }
16617         return ret_ref;
16618 }
16619
16620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16621         LDKChainParameters orig_conv;
16622         orig_conv.inner = (void*)(orig & (~1));
16623         orig_conv.is_owned = false;
16624         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
16625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16627         uint64_t ret_ref = (uint64_t)ret_var.inner;
16628         if (ret_var.is_owned) {
16629                 ret_ref |= 1;
16630         }
16631         return ret_ref;
16632 }
16633
16634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16635         LDKChannelCounterparty this_obj_conv;
16636         this_obj_conv.inner = (void*)(this_obj & (~1));
16637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16638         ChannelCounterparty_free(this_obj_conv);
16639 }
16640
16641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16642         LDKChannelCounterparty this_ptr_conv;
16643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16644         this_ptr_conv.is_owned = false;
16645         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
16647         return ret_arr;
16648 }
16649
16650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16651         LDKChannelCounterparty this_ptr_conv;
16652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16653         this_ptr_conv.is_owned = false;
16654         LDKPublicKey val_ref;
16655         CHECK((*env)->GetArrayLength(env, val) == 33);
16656         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16657         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
16658 }
16659
16660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16661         LDKChannelCounterparty this_ptr_conv;
16662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16663         this_ptr_conv.is_owned = false;
16664         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
16665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16667         uint64_t ret_ref = (uint64_t)ret_var.inner;
16668         if (ret_var.is_owned) {
16669                 ret_ref |= 1;
16670         }
16671         return ret_ref;
16672 }
16673
16674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16675         LDKChannelCounterparty this_ptr_conv;
16676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16677         this_ptr_conv.is_owned = false;
16678         LDKInitFeatures val_conv;
16679         val_conv.inner = (void*)(val & (~1));
16680         val_conv.is_owned = (val & 1) || (val == 0);
16681         val_conv = InitFeatures_clone(&val_conv);
16682         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
16683 }
16684
16685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16686         LDKChannelCounterparty this_ptr_conv;
16687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16688         this_ptr_conv.is_owned = false;
16689         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
16690         return ret_val;
16691 }
16692
16693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16694         LDKChannelCounterparty this_ptr_conv;
16695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16696         this_ptr_conv.is_owned = false;
16697         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
16698 }
16699
16700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16701         LDKChannelCounterparty orig_conv;
16702         orig_conv.inner = (void*)(orig & (~1));
16703         orig_conv.is_owned = false;
16704         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
16705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16707         uint64_t ret_ref = (uint64_t)ret_var.inner;
16708         if (ret_var.is_owned) {
16709                 ret_ref |= 1;
16710         }
16711         return ret_ref;
16712 }
16713
16714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16715         LDKChannelDetails this_obj_conv;
16716         this_obj_conv.inner = (void*)(this_obj & (~1));
16717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16718         ChannelDetails_free(this_obj_conv);
16719 }
16720
16721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16722         LDKChannelDetails this_ptr_conv;
16723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16724         this_ptr_conv.is_owned = false;
16725         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
16727         return ret_arr;
16728 }
16729
16730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16731         LDKChannelDetails this_ptr_conv;
16732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16733         this_ptr_conv.is_owned = false;
16734         LDKThirtyTwoBytes val_ref;
16735         CHECK((*env)->GetArrayLength(env, val) == 32);
16736         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16737         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
16738 }
16739
16740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
16741         LDKChannelDetails this_ptr_conv;
16742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16743         this_ptr_conv.is_owned = false;
16744         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
16745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16747         uint64_t ret_ref = (uint64_t)ret_var.inner;
16748         if (ret_var.is_owned) {
16749                 ret_ref |= 1;
16750         }
16751         return ret_ref;
16752 }
16753
16754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16755         LDKChannelDetails this_ptr_conv;
16756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16757         this_ptr_conv.is_owned = false;
16758         LDKChannelCounterparty val_conv;
16759         val_conv.inner = (void*)(val & (~1));
16760         val_conv.is_owned = (val & 1) || (val == 0);
16761         val_conv = ChannelCounterparty_clone(&val_conv);
16762         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
16763 }
16764
16765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
16766         LDKChannelDetails this_ptr_conv;
16767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16768         this_ptr_conv.is_owned = false;
16769         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
16770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16772         uint64_t ret_ref = (uint64_t)ret_var.inner;
16773         if (ret_var.is_owned) {
16774                 ret_ref |= 1;
16775         }
16776         return ret_ref;
16777 }
16778
16779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16780         LDKChannelDetails this_ptr_conv;
16781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16782         this_ptr_conv.is_owned = false;
16783         LDKOutPoint val_conv;
16784         val_conv.inner = (void*)(val & (~1));
16785         val_conv.is_owned = (val & 1) || (val == 0);
16786         val_conv = OutPoint_clone(&val_conv);
16787         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
16788 }
16789
16790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16791         LDKChannelDetails this_ptr_conv;
16792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16793         this_ptr_conv.is_owned = false;
16794         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16795         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
16796         uint64_t ret_ref = (uint64_t)ret_copy;
16797         return ret_ref;
16798 }
16799
16800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16801         LDKChannelDetails this_ptr_conv;
16802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16803         this_ptr_conv.is_owned = false;
16804         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16805         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
16806 }
16807
16808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16809         LDKChannelDetails this_ptr_conv;
16810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16811         this_ptr_conv.is_owned = false;
16812         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
16813         return ret_val;
16814 }
16815
16816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16817         LDKChannelDetails this_ptr_conv;
16818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16819         this_ptr_conv.is_owned = false;
16820         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
16821 }
16822
16823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16824         LDKChannelDetails this_ptr_conv;
16825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16826         this_ptr_conv.is_owned = false;
16827         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16828         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16829         uint64_t ret_ref = (uint64_t)ret_copy;
16830         return ret_ref;
16831 }
16832
16833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16834         LDKChannelDetails this_ptr_conv;
16835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16836         this_ptr_conv.is_owned = false;
16837         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16838         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16839 }
16840
16841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16842         LDKChannelDetails this_ptr_conv;
16843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16844         this_ptr_conv.is_owned = false;
16845         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
16846         return ret_val;
16847 }
16848
16849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16850         LDKChannelDetails this_ptr_conv;
16851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16852         this_ptr_conv.is_owned = false;
16853         ChannelDetails_set_user_id(&this_ptr_conv, val);
16854 }
16855
16856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16857         LDKChannelDetails this_ptr_conv;
16858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16859         this_ptr_conv.is_owned = false;
16860         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16861         return ret_val;
16862 }
16863
16864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16865         LDKChannelDetails this_ptr_conv;
16866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16867         this_ptr_conv.is_owned = false;
16868         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16869 }
16870
16871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16872         LDKChannelDetails this_ptr_conv;
16873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16874         this_ptr_conv.is_owned = false;
16875         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16876         return ret_val;
16877 }
16878
16879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16880         LDKChannelDetails this_ptr_conv;
16881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16882         this_ptr_conv.is_owned = false;
16883         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16884 }
16885
16886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16887         LDKChannelDetails this_ptr_conv;
16888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16889         this_ptr_conv.is_owned = false;
16890         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16891         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16892         uint64_t ret_ref = (uint64_t)ret_copy;
16893         return ret_ref;
16894 }
16895
16896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16897         LDKChannelDetails this_ptr_conv;
16898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16899         this_ptr_conv.is_owned = false;
16900         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16901         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16902 }
16903
16904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16905         LDKChannelDetails this_ptr_conv;
16906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16907         this_ptr_conv.is_owned = false;
16908         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16909         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16910         uint64_t ret_ref = (uint64_t)ret_copy;
16911         return ret_ref;
16912 }
16913
16914 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) {
16915         LDKChannelDetails this_ptr_conv;
16916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16917         this_ptr_conv.is_owned = false;
16918         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16919         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16920 }
16921
16922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16923         LDKChannelDetails this_ptr_conv;
16924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16925         this_ptr_conv.is_owned = false;
16926         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16927         return ret_val;
16928 }
16929
16930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16931         LDKChannelDetails this_ptr_conv;
16932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16933         this_ptr_conv.is_owned = false;
16934         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16935 }
16936
16937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16938         LDKChannelDetails this_ptr_conv;
16939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16940         this_ptr_conv.is_owned = false;
16941         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16942         return ret_val;
16943 }
16944
16945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16946         LDKChannelDetails this_ptr_conv;
16947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16948         this_ptr_conv.is_owned = false;
16949         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16950 }
16951
16952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16953         LDKChannelDetails this_ptr_conv;
16954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16955         this_ptr_conv.is_owned = false;
16956         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16957         return ret_val;
16958 }
16959
16960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16961         LDKChannelDetails this_ptr_conv;
16962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16963         this_ptr_conv.is_owned = false;
16964         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16965 }
16966
16967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16968         LDKChannelDetails this_ptr_conv;
16969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16970         this_ptr_conv.is_owned = false;
16971         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16972         return ret_val;
16973 }
16974
16975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16976         LDKChannelDetails this_ptr_conv;
16977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16978         this_ptr_conv.is_owned = false;
16979         ChannelDetails_set_is_public(&this_ptr_conv, val);
16980 }
16981
16982 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) {
16983         LDKThirtyTwoBytes channel_id_arg_ref;
16984         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16985         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16986         LDKChannelCounterparty counterparty_arg_conv;
16987         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16988         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16989         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16990         LDKOutPoint funding_txo_arg_conv;
16991         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16992         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16993         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16994         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16995         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16996         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16997         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16998         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);
16999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17001         uint64_t ret_ref = (uint64_t)ret_var.inner;
17002         if (ret_var.is_owned) {
17003                 ret_ref |= 1;
17004         }
17005         return ret_ref;
17006 }
17007
17008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17009         LDKChannelDetails orig_conv;
17010         orig_conv.inner = (void*)(orig & (~1));
17011         orig_conv.is_owned = false;
17012         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
17013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17015         uint64_t ret_ref = (uint64_t)ret_var.inner;
17016         if (ret_var.is_owned) {
17017                 ret_ref |= 1;
17018         }
17019         return ret_ref;
17020 }
17021
17022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17023         if ((this_ptr & 1) != 0) return;
17024         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
17025         FREE((void*)this_ptr);
17026         PaymentSendFailure_free(this_ptr_conv);
17027 }
17028
17029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17030         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
17031         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17032         *ret_copy = PaymentSendFailure_clone(orig_conv);
17033         uint64_t ret_ref = (uint64_t)ret_copy;
17034         return ret_ref;
17035 }
17036
17037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
17038         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
17039         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17040         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
17041         uint64_t ret_ref = (uint64_t)ret_copy;
17042         return ret_ref;
17043 }
17044
17045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
17046         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
17047         a_constr.datalen = (*env)->GetArrayLength(env, a);
17048         if (a_constr.datalen > 0)
17049                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17050         else
17051                 a_constr.data = NULL;
17052         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
17053         for (size_t w = 0; w < a_constr.datalen; w++) {
17054                 int64_t a_conv_22 = a_vals[w];
17055                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
17056                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
17057                 a_constr.data[w] = a_conv_22_conv;
17058         }
17059         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
17060         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17061         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
17062         uint64_t ret_ref = (uint64_t)ret_copy;
17063         return ret_ref;
17064 }
17065
17066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
17067         LDKCVec_APIErrorZ a_constr;
17068         a_constr.datalen = (*env)->GetArrayLength(env, a);
17069         if (a_constr.datalen > 0)
17070                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17071         else
17072                 a_constr.data = NULL;
17073         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
17074         for (size_t k = 0; k < a_constr.datalen; k++) {
17075                 int64_t a_conv_10 = a_vals[k];
17076                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
17077                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
17078                 a_constr.data[k] = a_conv_10_conv;
17079         }
17080         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
17081         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17082         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
17083         uint64_t ret_ref = (uint64_t)ret_copy;
17084         return ret_ref;
17085 }
17086
17087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
17088         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
17089         a_constr.datalen = (*env)->GetArrayLength(env, a);
17090         if (a_constr.datalen > 0)
17091                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17092         else
17093                 a_constr.data = NULL;
17094         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
17095         for (size_t w = 0; w < a_constr.datalen; w++) {
17096                 int64_t a_conv_22 = a_vals[w];
17097                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
17098                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
17099                 a_constr.data[w] = a_conv_22_conv;
17100         }
17101         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
17102         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17103         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
17104         uint64_t ret_ref = (uint64_t)ret_copy;
17105         return ret_ref;
17106 }
17107
17108 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) {
17109         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
17110         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
17111                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17112                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
17113         }
17114         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
17115         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
17116                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17117                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
17118         }
17119         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
17120         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17121                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17122                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
17123         }
17124         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17125         if (logger_conv.free == LDKLogger_JCalls_free) {
17126                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17127                 LDKLogger_JCalls_cloned(&logger_conv);
17128         }
17129         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
17130         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
17131                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17132                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
17133         }
17134         LDKUserConfig config_conv;
17135         config_conv.inner = (void*)(config & (~1));
17136         config_conv.is_owned = (config & 1) || (config == 0);
17137         config_conv = UserConfig_clone(&config_conv);
17138         LDKChainParameters params_conv;
17139         params_conv.inner = (void*)(params & (~1));
17140         params_conv.is_owned = (params & 1) || (params == 0);
17141         params_conv = ChainParameters_clone(&params_conv);
17142         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
17143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17145         uint64_t ret_ref = (uint64_t)ret_var.inner;
17146         if (ret_var.is_owned) {
17147                 ret_ref |= 1;
17148         }
17149         return ret_ref;
17150 }
17151
17152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
17153         LDKChannelManager this_arg_conv;
17154         this_arg_conv.inner = (void*)(this_arg & (~1));
17155         this_arg_conv.is_owned = false;
17156         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
17157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17159         uint64_t ret_ref = (uint64_t)ret_var.inner;
17160         if (ret_var.is_owned) {
17161                 ret_ref |= 1;
17162         }
17163         return ret_ref;
17164 }
17165
17166 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) {
17167         LDKChannelManager this_arg_conv;
17168         this_arg_conv.inner = (void*)(this_arg & (~1));
17169         this_arg_conv.is_owned = false;
17170         LDKPublicKey their_network_key_ref;
17171         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
17172         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
17173         LDKUserConfig override_config_conv;
17174         override_config_conv.inner = (void*)(override_config & (~1));
17175         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
17176         override_config_conv = UserConfig_clone(&override_config_conv);
17177         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17178         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
17179         return (uint64_t)ret_conv;
17180 }
17181
17182 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
17183         LDKChannelManager this_arg_conv;
17184         this_arg_conv.inner = (void*)(this_arg & (~1));
17185         this_arg_conv.is_owned = false;
17186         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
17187         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17188         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17189         for (size_t q = 0; q < ret_var.datalen; q++) {
17190                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
17191                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17192                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17193                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
17194                 if (ret_conv_16_var.is_owned) {
17195                         ret_conv_16_ref |= 1;
17196                 }
17197                 ret_arr_ptr[q] = ret_conv_16_ref;
17198         }
17199         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17200         FREE(ret_var.data);
17201         return ret_arr;
17202 }
17203
17204 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
17205         LDKChannelManager this_arg_conv;
17206         this_arg_conv.inner = (void*)(this_arg & (~1));
17207         this_arg_conv.is_owned = false;
17208         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
17209         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17211         for (size_t q = 0; q < ret_var.datalen; q++) {
17212                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
17213                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17214                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17215                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
17216                 if (ret_conv_16_var.is_owned) {
17217                         ret_conv_16_ref |= 1;
17218                 }
17219                 ret_arr_ptr[q] = ret_conv_16_ref;
17220         }
17221         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17222         FREE(ret_var.data);
17223         return ret_arr;
17224 }
17225
17226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
17227         LDKChannelManager this_arg_conv;
17228         this_arg_conv.inner = (void*)(this_arg & (~1));
17229         this_arg_conv.is_owned = false;
17230         unsigned char channel_id_arr[32];
17231         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17232         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
17233         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
17234         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17235         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
17236         return (uint64_t)ret_conv;
17237 }
17238
17239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
17240         LDKChannelManager this_arg_conv;
17241         this_arg_conv.inner = (void*)(this_arg & (~1));
17242         this_arg_conv.is_owned = false;
17243         unsigned char channel_id_arr[32];
17244         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17245         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
17246         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
17247         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17248         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
17249         return (uint64_t)ret_conv;
17250 }
17251
17252 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) {
17253         LDKChannelManager this_arg_conv;
17254         this_arg_conv.inner = (void*)(this_arg & (~1));
17255         this_arg_conv.is_owned = false;
17256         unsigned char channel_id_arr[32];
17257         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17258         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
17259         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
17260         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17261         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
17262         return (uint64_t)ret_conv;
17263 }
17264
17265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
17266         LDKChannelManager this_arg_conv;
17267         this_arg_conv.inner = (void*)(this_arg & (~1));
17268         this_arg_conv.is_owned = false;
17269         ChannelManager_force_close_all_channels(&this_arg_conv);
17270 }
17271
17272 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) {
17273         LDKChannelManager this_arg_conv;
17274         this_arg_conv.inner = (void*)(this_arg & (~1));
17275         this_arg_conv.is_owned = false;
17276         LDKRoute route_conv;
17277         route_conv.inner = (void*)(route & (~1));
17278         route_conv.is_owned = false;
17279         LDKThirtyTwoBytes payment_hash_ref;
17280         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17281         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17282         LDKThirtyTwoBytes payment_secret_ref;
17283         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
17284         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
17285         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17286         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
17287         return (uint64_t)ret_conv;
17288 }
17289
17290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
17291         LDKChannelManager this_arg_conv;
17292         this_arg_conv.inner = (void*)(this_arg & (~1));
17293         this_arg_conv.is_owned = false;
17294         LDKRoute route_conv;
17295         route_conv.inner = (void*)(route & (~1));
17296         route_conv.is_owned = false;
17297         LDKThirtyTwoBytes payment_preimage_ref;
17298         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
17299         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
17300         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
17301         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
17302         return (uint64_t)ret_conv;
17303 }
17304
17305 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) {
17306         LDKChannelManager this_arg_conv;
17307         this_arg_conv.inner = (void*)(this_arg & (~1));
17308         this_arg_conv.is_owned = false;
17309         unsigned char temporary_channel_id_arr[32];
17310         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
17311         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
17312         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
17313         LDKTransaction funding_transaction_ref;
17314         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
17315         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
17316         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
17317         funding_transaction_ref.data_is_owned = true;
17318         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17319         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
17320         return (uint64_t)ret_conv;
17321 }
17322
17323 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) {
17324         LDKChannelManager this_arg_conv;
17325         this_arg_conv.inner = (void*)(this_arg & (~1));
17326         this_arg_conv.is_owned = false;
17327         LDKThreeBytes rgb_ref;
17328         CHECK((*env)->GetArrayLength(env, rgb) == 3);
17329         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
17330         LDKThirtyTwoBytes alias_ref;
17331         CHECK((*env)->GetArrayLength(env, alias) == 32);
17332         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
17333         LDKCVec_NetAddressZ addresses_constr;
17334         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
17335         if (addresses_constr.datalen > 0)
17336                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17337         else
17338                 addresses_constr.data = NULL;
17339         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
17340         for (size_t m = 0; m < addresses_constr.datalen; m++) {
17341                 int64_t addresses_conv_12 = addresses_vals[m];
17342                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
17343                 addresses_constr.data[m] = addresses_conv_12_conv;
17344         }
17345         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
17346         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
17347 }
17348
17349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
17350         LDKChannelManager this_arg_conv;
17351         this_arg_conv.inner = (void*)(this_arg & (~1));
17352         this_arg_conv.is_owned = false;
17353         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
17354 }
17355
17356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
17357         LDKChannelManager this_arg_conv;
17358         this_arg_conv.inner = (void*)(this_arg & (~1));
17359         this_arg_conv.is_owned = false;
17360         ChannelManager_timer_tick_occurred(&this_arg_conv);
17361 }
17362
17363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
17364         LDKChannelManager this_arg_conv;
17365         this_arg_conv.inner = (void*)(this_arg & (~1));
17366         this_arg_conv.is_owned = false;
17367         unsigned char payment_hash_arr[32];
17368         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17369         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
17370         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
17371         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
17372         return ret_val;
17373 }
17374
17375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
17376         LDKChannelManager this_arg_conv;
17377         this_arg_conv.inner = (void*)(this_arg & (~1));
17378         this_arg_conv.is_owned = false;
17379         LDKThirtyTwoBytes payment_preimage_ref;
17380         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
17381         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
17382         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
17383         return ret_val;
17384 }
17385
17386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17387         LDKChannelManager this_arg_conv;
17388         this_arg_conv.inner = (void*)(this_arg & (~1));
17389         this_arg_conv.is_owned = false;
17390         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17391         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
17392         return ret_arr;
17393 }
17394
17395 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) {
17396         LDKChannelManager this_arg_conv;
17397         this_arg_conv.inner = (void*)(this_arg & (~1));
17398         this_arg_conv.is_owned = false;
17399         LDKOutPoint funding_txo_conv;
17400         funding_txo_conv.inner = (void*)(funding_txo & (~1));
17401         funding_txo_conv.is_owned = false;
17402         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
17403 }
17404
17405 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) {
17406         LDKChannelManager this_arg_conv;
17407         this_arg_conv.inner = (void*)(this_arg & (~1));
17408         this_arg_conv.is_owned = false;
17409         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17410         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17411         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
17412         return (uint64_t)ret_ref;
17413 }
17414
17415 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) {
17416         LDKChannelManager this_arg_conv;
17417         this_arg_conv.inner = (void*)(this_arg & (~1));
17418         this_arg_conv.is_owned = false;
17419         LDKThirtyTwoBytes payment_hash_ref;
17420         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17421         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17422         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17423         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17424         *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);
17425         return (uint64_t)ret_conv;
17426 }
17427
17428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17429         LDKChannelManager this_arg_conv;
17430         this_arg_conv.inner = (void*)(this_arg & (~1));
17431         this_arg_conv.is_owned = false;
17432         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17433         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
17434         return (uint64_t)ret;
17435 }
17436
17437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17438         LDKChannelManager this_arg_conv;
17439         this_arg_conv.inner = (void*)(this_arg & (~1));
17440         this_arg_conv.is_owned = false;
17441         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
17442         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
17443         return (uint64_t)ret;
17444 }
17445
17446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
17447         LDKChannelManager this_arg_conv;
17448         this_arg_conv.inner = (void*)(this_arg & (~1));
17449         this_arg_conv.is_owned = false;
17450         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
17451         *ret = ChannelManager_as_Listen(&this_arg_conv);
17452         return (uint64_t)ret;
17453 }
17454
17455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
17456         LDKChannelManager this_arg_conv;
17457         this_arg_conv.inner = (void*)(this_arg & (~1));
17458         this_arg_conv.is_owned = false;
17459         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
17460         *ret = ChannelManager_as_Confirm(&this_arg_conv);
17461         return (uint64_t)ret;
17462 }
17463
17464 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) {
17465         LDKChannelManager this_arg_conv;
17466         this_arg_conv.inner = (void*)(this_arg & (~1));
17467         this_arg_conv.is_owned = false;
17468         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
17469         return ret_val;
17470 }
17471
17472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
17473         LDKChannelManager this_arg_conv;
17474         this_arg_conv.inner = (void*)(this_arg & (~1));
17475         this_arg_conv.is_owned = false;
17476         ChannelManager_await_persistable_update(&this_arg_conv);
17477 }
17478
17479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
17480         LDKChannelManager this_arg_conv;
17481         this_arg_conv.inner = (void*)(this_arg & (~1));
17482         this_arg_conv.is_owned = false;
17483         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
17484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17486         uint64_t ret_ref = (uint64_t)ret_var.inner;
17487         if (ret_var.is_owned) {
17488                 ret_ref |= 1;
17489         }
17490         return ret_ref;
17491 }
17492
17493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17494         LDKChannelManager this_arg_conv;
17495         this_arg_conv.inner = (void*)(this_arg & (~1));
17496         this_arg_conv.is_owned = false;
17497         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
17498         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
17499         return (uint64_t)ret;
17500 }
17501
17502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
17503         LDKChannelManager obj_conv;
17504         obj_conv.inner = (void*)(obj & (~1));
17505         obj_conv.is_owned = false;
17506         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
17507         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17508         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17509         CVec_u8Z_free(ret_var);
17510         return ret_arr;
17511 }
17512
17513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17514         LDKChannelManagerReadArgs this_obj_conv;
17515         this_obj_conv.inner = (void*)(this_obj & (~1));
17516         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17517         ChannelManagerReadArgs_free(this_obj_conv);
17518 }
17519
17520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
17521         LDKChannelManagerReadArgs this_ptr_conv;
17522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17523         this_ptr_conv.is_owned = false;
17524         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
17525         return ret_ret;
17526 }
17527
17528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17529         LDKChannelManagerReadArgs this_ptr_conv;
17530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17531         this_ptr_conv.is_owned = false;
17532         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
17533         if (val_conv.free == LDKKeysInterface_JCalls_free) {
17534                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17535                 LDKKeysInterface_JCalls_cloned(&val_conv);
17536         }
17537         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
17538 }
17539
17540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
17541         LDKChannelManagerReadArgs this_ptr_conv;
17542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17543         this_ptr_conv.is_owned = false;
17544         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
17545         return ret_ret;
17546 }
17547
17548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17549         LDKChannelManagerReadArgs this_ptr_conv;
17550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17551         this_ptr_conv.is_owned = false;
17552         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
17553         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
17554                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17555                 LDKFeeEstimator_JCalls_cloned(&val_conv);
17556         }
17557         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
17558 }
17559
17560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
17561         LDKChannelManagerReadArgs this_ptr_conv;
17562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17563         this_ptr_conv.is_owned = false;
17564         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
17565         return ret_ret;
17566 }
17567
17568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17569         LDKChannelManagerReadArgs this_ptr_conv;
17570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17571         this_ptr_conv.is_owned = false;
17572         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
17573         if (val_conv.free == LDKWatch_JCalls_free) {
17574                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17575                 LDKWatch_JCalls_cloned(&val_conv);
17576         }
17577         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
17578 }
17579
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
17581         LDKChannelManagerReadArgs this_ptr_conv;
17582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17583         this_ptr_conv.is_owned = false;
17584         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
17585         return ret_ret;
17586 }
17587
17588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17589         LDKChannelManagerReadArgs this_ptr_conv;
17590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17591         this_ptr_conv.is_owned = false;
17592         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
17593         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
17594                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17595                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
17596         }
17597         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
17598 }
17599
17600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
17601         LDKChannelManagerReadArgs this_ptr_conv;
17602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17603         this_ptr_conv.is_owned = false;
17604         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
17605         return ret_ret;
17606 }
17607
17608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17609         LDKChannelManagerReadArgs this_ptr_conv;
17610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17611         this_ptr_conv.is_owned = false;
17612         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
17613         if (val_conv.free == LDKLogger_JCalls_free) {
17614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17615                 LDKLogger_JCalls_cloned(&val_conv);
17616         }
17617         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
17618 }
17619
17620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
17621         LDKChannelManagerReadArgs this_ptr_conv;
17622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17623         this_ptr_conv.is_owned = false;
17624         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
17625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17627         uint64_t ret_ref = (uint64_t)ret_var.inner;
17628         if (ret_var.is_owned) {
17629                 ret_ref |= 1;
17630         }
17631         return ret_ref;
17632 }
17633
17634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17635         LDKChannelManagerReadArgs this_ptr_conv;
17636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17637         this_ptr_conv.is_owned = false;
17638         LDKUserConfig val_conv;
17639         val_conv.inner = (void*)(val & (~1));
17640         val_conv.is_owned = (val & 1) || (val == 0);
17641         val_conv = UserConfig_clone(&val_conv);
17642         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
17643 }
17644
17645 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) {
17646         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
17647         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
17648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17649                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
17650         }
17651         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17652         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17653                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17654                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17655         }
17656         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
17657         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
17658                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17659                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
17660         }
17661         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
17662         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17663                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17664                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
17665         }
17666         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17667         if (logger_conv.free == LDKLogger_JCalls_free) {
17668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17669                 LDKLogger_JCalls_cloned(&logger_conv);
17670         }
17671         LDKUserConfig default_config_conv;
17672         default_config_conv.inner = (void*)(default_config & (~1));
17673         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
17674         default_config_conv = UserConfig_clone(&default_config_conv);
17675         LDKCVec_ChannelMonitorZ channel_monitors_constr;
17676         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
17677         if (channel_monitors_constr.datalen > 0)
17678                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
17679         else
17680                 channel_monitors_constr.data = NULL;
17681         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
17682         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
17683                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
17684                 LDKChannelMonitor channel_monitors_conv_16_conv;
17685                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
17686                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
17687                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
17688         }
17689         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
17690         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);
17691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17693         uint64_t ret_ref = (uint64_t)ret_var.inner;
17694         if (ret_var.is_owned) {
17695                 ret_ref |= 1;
17696         }
17697         return ret_ref;
17698 }
17699
17700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
17701         LDKu8slice ser_ref;
17702         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17703         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17704         LDKChannelManagerReadArgs arg_conv;
17705         arg_conv.inner = (void*)(arg & (~1));
17706         arg_conv.is_owned = (arg & 1) || (arg == 0);
17707         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
17708         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
17709         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
17710         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17711         return (uint64_t)ret_conv;
17712 }
17713
17714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17715         LDKDecodeError this_obj_conv;
17716         this_obj_conv.inner = (void*)(this_obj & (~1));
17717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17718         DecodeError_free(this_obj_conv);
17719 }
17720
17721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17722         LDKDecodeError orig_conv;
17723         orig_conv.inner = (void*)(orig & (~1));
17724         orig_conv.is_owned = false;
17725         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
17726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17728         uint64_t ret_ref = (uint64_t)ret_var.inner;
17729         if (ret_var.is_owned) {
17730                 ret_ref |= 1;
17731         }
17732         return ret_ref;
17733 }
17734
17735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17736         LDKInit this_obj_conv;
17737         this_obj_conv.inner = (void*)(this_obj & (~1));
17738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17739         Init_free(this_obj_conv);
17740 }
17741
17742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
17743         LDKInit this_ptr_conv;
17744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17745         this_ptr_conv.is_owned = false;
17746         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
17747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17749         uint64_t ret_ref = (uint64_t)ret_var.inner;
17750         if (ret_var.is_owned) {
17751                 ret_ref |= 1;
17752         }
17753         return ret_ref;
17754 }
17755
17756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17757         LDKInit this_ptr_conv;
17758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17759         this_ptr_conv.is_owned = false;
17760         LDKInitFeatures val_conv;
17761         val_conv.inner = (void*)(val & (~1));
17762         val_conv.is_owned = (val & 1) || (val == 0);
17763         val_conv = InitFeatures_clone(&val_conv);
17764         Init_set_features(&this_ptr_conv, val_conv);
17765 }
17766
17767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
17768         LDKInitFeatures features_arg_conv;
17769         features_arg_conv.inner = (void*)(features_arg & (~1));
17770         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17771         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17772         LDKInit ret_var = Init_new(features_arg_conv);
17773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17775         uint64_t ret_ref = (uint64_t)ret_var.inner;
17776         if (ret_var.is_owned) {
17777                 ret_ref |= 1;
17778         }
17779         return ret_ref;
17780 }
17781
17782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17783         LDKInit orig_conv;
17784         orig_conv.inner = (void*)(orig & (~1));
17785         orig_conv.is_owned = false;
17786         LDKInit ret_var = Init_clone(&orig_conv);
17787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17789         uint64_t ret_ref = (uint64_t)ret_var.inner;
17790         if (ret_var.is_owned) {
17791                 ret_ref |= 1;
17792         }
17793         return ret_ref;
17794 }
17795
17796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17797         LDKErrorMessage this_obj_conv;
17798         this_obj_conv.inner = (void*)(this_obj & (~1));
17799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17800         ErrorMessage_free(this_obj_conv);
17801 }
17802
17803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17804         LDKErrorMessage this_ptr_conv;
17805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17806         this_ptr_conv.is_owned = false;
17807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
17809         return ret_arr;
17810 }
17811
17812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17813         LDKErrorMessage this_ptr_conv;
17814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17815         this_ptr_conv.is_owned = false;
17816         LDKThirtyTwoBytes val_ref;
17817         CHECK((*env)->GetArrayLength(env, val) == 32);
17818         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17819         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
17820 }
17821
17822 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
17823         LDKErrorMessage this_ptr_conv;
17824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17825         this_ptr_conv.is_owned = false;
17826         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
17827         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
17828         Str_free(ret_str);
17829         return ret_conv;
17830 }
17831
17832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
17833         LDKErrorMessage this_ptr_conv;
17834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17835         this_ptr_conv.is_owned = false;
17836         LDKStr val_conv = java_to_owned_str(env, val);
17837         ErrorMessage_set_data(&this_ptr_conv, val_conv);
17838 }
17839
17840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
17841         LDKThirtyTwoBytes channel_id_arg_ref;
17842         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17843         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17844         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
17845         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
17846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17848         uint64_t ret_ref = (uint64_t)ret_var.inner;
17849         if (ret_var.is_owned) {
17850                 ret_ref |= 1;
17851         }
17852         return ret_ref;
17853 }
17854
17855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17856         LDKErrorMessage orig_conv;
17857         orig_conv.inner = (void*)(orig & (~1));
17858         orig_conv.is_owned = false;
17859         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
17860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17862         uint64_t ret_ref = (uint64_t)ret_var.inner;
17863         if (ret_var.is_owned) {
17864                 ret_ref |= 1;
17865         }
17866         return ret_ref;
17867 }
17868
17869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17870         LDKPing this_obj_conv;
17871         this_obj_conv.inner = (void*)(this_obj & (~1));
17872         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17873         Ping_free(this_obj_conv);
17874 }
17875
17876 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17877         LDKPing this_ptr_conv;
17878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17879         this_ptr_conv.is_owned = false;
17880         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17881         return ret_val;
17882 }
17883
17884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17885         LDKPing this_ptr_conv;
17886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17887         this_ptr_conv.is_owned = false;
17888         Ping_set_ponglen(&this_ptr_conv, val);
17889 }
17890
17891 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17892         LDKPing this_ptr_conv;
17893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17894         this_ptr_conv.is_owned = false;
17895         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17896         return ret_val;
17897 }
17898
17899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17900         LDKPing this_ptr_conv;
17901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17902         this_ptr_conv.is_owned = false;
17903         Ping_set_byteslen(&this_ptr_conv, val);
17904 }
17905
17906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
17907         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17910         uint64_t ret_ref = (uint64_t)ret_var.inner;
17911         if (ret_var.is_owned) {
17912                 ret_ref |= 1;
17913         }
17914         return ret_ref;
17915 }
17916
17917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17918         LDKPing orig_conv;
17919         orig_conv.inner = (void*)(orig & (~1));
17920         orig_conv.is_owned = false;
17921         LDKPing ret_var = Ping_clone(&orig_conv);
17922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17924         uint64_t ret_ref = (uint64_t)ret_var.inner;
17925         if (ret_var.is_owned) {
17926                 ret_ref |= 1;
17927         }
17928         return ret_ref;
17929 }
17930
17931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17932         LDKPong this_obj_conv;
17933         this_obj_conv.inner = (void*)(this_obj & (~1));
17934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17935         Pong_free(this_obj_conv);
17936 }
17937
17938 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17939         LDKPong this_ptr_conv;
17940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17941         this_ptr_conv.is_owned = false;
17942         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17943         return ret_val;
17944 }
17945
17946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17947         LDKPong this_ptr_conv;
17948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17949         this_ptr_conv.is_owned = false;
17950         Pong_set_byteslen(&this_ptr_conv, val);
17951 }
17952
17953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
17954         LDKPong ret_var = Pong_new(byteslen_arg);
17955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17957         uint64_t ret_ref = (uint64_t)ret_var.inner;
17958         if (ret_var.is_owned) {
17959                 ret_ref |= 1;
17960         }
17961         return ret_ref;
17962 }
17963
17964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17965         LDKPong orig_conv;
17966         orig_conv.inner = (void*)(orig & (~1));
17967         orig_conv.is_owned = false;
17968         LDKPong ret_var = Pong_clone(&orig_conv);
17969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17971         uint64_t ret_ref = (uint64_t)ret_var.inner;
17972         if (ret_var.is_owned) {
17973                 ret_ref |= 1;
17974         }
17975         return ret_ref;
17976 }
17977
17978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17979         LDKOpenChannel this_obj_conv;
17980         this_obj_conv.inner = (void*)(this_obj & (~1));
17981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17982         OpenChannel_free(this_obj_conv);
17983 }
17984
17985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17986         LDKOpenChannel this_ptr_conv;
17987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17988         this_ptr_conv.is_owned = false;
17989         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17991         return ret_arr;
17992 }
17993
17994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17995         LDKOpenChannel this_ptr_conv;
17996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17997         this_ptr_conv.is_owned = false;
17998         LDKThirtyTwoBytes val_ref;
17999         CHECK((*env)->GetArrayLength(env, val) == 32);
18000         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18001         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
18002 }
18003
18004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18005         LDKOpenChannel this_ptr_conv;
18006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18007         this_ptr_conv.is_owned = false;
18008         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
18010         return ret_arr;
18011 }
18012
18013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18014         LDKOpenChannel this_ptr_conv;
18015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18016         this_ptr_conv.is_owned = false;
18017         LDKThirtyTwoBytes val_ref;
18018         CHECK((*env)->GetArrayLength(env, val) == 32);
18019         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18020         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
18021 }
18022
18023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18024         LDKOpenChannel this_ptr_conv;
18025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18026         this_ptr_conv.is_owned = false;
18027         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
18028         return ret_val;
18029 }
18030
18031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18032         LDKOpenChannel this_ptr_conv;
18033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18034         this_ptr_conv.is_owned = false;
18035         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
18036 }
18037
18038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18039         LDKOpenChannel this_ptr_conv;
18040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18041         this_ptr_conv.is_owned = false;
18042         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
18043         return ret_val;
18044 }
18045
18046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18047         LDKOpenChannel this_ptr_conv;
18048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18049         this_ptr_conv.is_owned = false;
18050         OpenChannel_set_push_msat(&this_ptr_conv, val);
18051 }
18052
18053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18054         LDKOpenChannel this_ptr_conv;
18055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18056         this_ptr_conv.is_owned = false;
18057         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
18058         return ret_val;
18059 }
18060
18061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18062         LDKOpenChannel this_ptr_conv;
18063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18064         this_ptr_conv.is_owned = false;
18065         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
18066 }
18067
18068 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) {
18069         LDKOpenChannel this_ptr_conv;
18070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18071         this_ptr_conv.is_owned = false;
18072         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
18073         return ret_val;
18074 }
18075
18076 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) {
18077         LDKOpenChannel this_ptr_conv;
18078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18079         this_ptr_conv.is_owned = false;
18080         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
18081 }
18082
18083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18084         LDKOpenChannel this_ptr_conv;
18085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18086         this_ptr_conv.is_owned = false;
18087         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
18088         return ret_val;
18089 }
18090
18091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18092         LDKOpenChannel this_ptr_conv;
18093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18094         this_ptr_conv.is_owned = false;
18095         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
18096 }
18097
18098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18099         LDKOpenChannel this_ptr_conv;
18100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18101         this_ptr_conv.is_owned = false;
18102         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
18103         return ret_val;
18104 }
18105
18106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18107         LDKOpenChannel this_ptr_conv;
18108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18109         this_ptr_conv.is_owned = false;
18110         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
18111 }
18112
18113 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
18114         LDKOpenChannel this_ptr_conv;
18115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18116         this_ptr_conv.is_owned = false;
18117         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
18118         return ret_val;
18119 }
18120
18121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18122         LDKOpenChannel this_ptr_conv;
18123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18124         this_ptr_conv.is_owned = false;
18125         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
18126 }
18127
18128 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18129         LDKOpenChannel this_ptr_conv;
18130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18131         this_ptr_conv.is_owned = false;
18132         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
18133         return ret_val;
18134 }
18135
18136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18137         LDKOpenChannel this_ptr_conv;
18138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18139         this_ptr_conv.is_owned = false;
18140         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
18141 }
18142
18143 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
18144         LDKOpenChannel this_ptr_conv;
18145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18146         this_ptr_conv.is_owned = false;
18147         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
18148         return ret_val;
18149 }
18150
18151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18152         LDKOpenChannel this_ptr_conv;
18153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18154         this_ptr_conv.is_owned = false;
18155         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
18156 }
18157
18158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18159         LDKOpenChannel this_ptr_conv;
18160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18161         this_ptr_conv.is_owned = false;
18162         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
18164         return ret_arr;
18165 }
18166
18167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18168         LDKOpenChannel this_ptr_conv;
18169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18170         this_ptr_conv.is_owned = false;
18171         LDKPublicKey val_ref;
18172         CHECK((*env)->GetArrayLength(env, val) == 33);
18173         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18174         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
18175 }
18176
18177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18178         LDKOpenChannel this_ptr_conv;
18179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18180         this_ptr_conv.is_owned = false;
18181         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18183         return ret_arr;
18184 }
18185
18186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18187         LDKOpenChannel this_ptr_conv;
18188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18189         this_ptr_conv.is_owned = false;
18190         LDKPublicKey val_ref;
18191         CHECK((*env)->GetArrayLength(env, val) == 33);
18192         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18193         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
18194 }
18195
18196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18197         LDKOpenChannel this_ptr_conv;
18198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18199         this_ptr_conv.is_owned = false;
18200         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
18202         return ret_arr;
18203 }
18204
18205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18206         LDKOpenChannel this_ptr_conv;
18207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18208         this_ptr_conv.is_owned = false;
18209         LDKPublicKey val_ref;
18210         CHECK((*env)->GetArrayLength(env, val) == 33);
18211         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18212         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
18213 }
18214
18215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18216         LDKOpenChannel this_ptr_conv;
18217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18218         this_ptr_conv.is_owned = false;
18219         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18221         return ret_arr;
18222 }
18223
18224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18225         LDKOpenChannel this_ptr_conv;
18226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18227         this_ptr_conv.is_owned = false;
18228         LDKPublicKey val_ref;
18229         CHECK((*env)->GetArrayLength(env, val) == 33);
18230         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18231         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18232 }
18233
18234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18235         LDKOpenChannel this_ptr_conv;
18236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18237         this_ptr_conv.is_owned = false;
18238         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18240         return ret_arr;
18241 }
18242
18243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18244         LDKOpenChannel this_ptr_conv;
18245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18246         this_ptr_conv.is_owned = false;
18247         LDKPublicKey val_ref;
18248         CHECK((*env)->GetArrayLength(env, val) == 33);
18249         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18250         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
18251 }
18252
18253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18254         LDKOpenChannel this_ptr_conv;
18255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18256         this_ptr_conv.is_owned = false;
18257         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18258         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
18259         return ret_arr;
18260 }
18261
18262 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) {
18263         LDKOpenChannel this_ptr_conv;
18264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18265         this_ptr_conv.is_owned = false;
18266         LDKPublicKey val_ref;
18267         CHECK((*env)->GetArrayLength(env, val) == 33);
18268         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18269         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
18270 }
18271
18272 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
18273         LDKOpenChannel this_ptr_conv;
18274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18275         this_ptr_conv.is_owned = false;
18276         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
18277         return ret_val;
18278 }
18279
18280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
18281         LDKOpenChannel this_ptr_conv;
18282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18283         this_ptr_conv.is_owned = false;
18284         OpenChannel_set_channel_flags(&this_ptr_conv, val);
18285 }
18286
18287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18288         LDKOpenChannel orig_conv;
18289         orig_conv.inner = (void*)(orig & (~1));
18290         orig_conv.is_owned = false;
18291         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
18292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18294         uint64_t ret_ref = (uint64_t)ret_var.inner;
18295         if (ret_var.is_owned) {
18296                 ret_ref |= 1;
18297         }
18298         return ret_ref;
18299 }
18300
18301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18302         LDKAcceptChannel this_obj_conv;
18303         this_obj_conv.inner = (void*)(this_obj & (~1));
18304         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18305         AcceptChannel_free(this_obj_conv);
18306 }
18307
18308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18309         LDKAcceptChannel this_ptr_conv;
18310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18311         this_ptr_conv.is_owned = false;
18312         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
18314         return ret_arr;
18315 }
18316
18317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18318         LDKAcceptChannel this_ptr_conv;
18319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18320         this_ptr_conv.is_owned = false;
18321         LDKThirtyTwoBytes val_ref;
18322         CHECK((*env)->GetArrayLength(env, val) == 32);
18323         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18324         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
18325 }
18326
18327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18328         LDKAcceptChannel this_ptr_conv;
18329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18330         this_ptr_conv.is_owned = false;
18331         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
18332         return ret_val;
18333 }
18334
18335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18336         LDKAcceptChannel this_ptr_conv;
18337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18338         this_ptr_conv.is_owned = false;
18339         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
18340 }
18341
18342 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) {
18343         LDKAcceptChannel this_ptr_conv;
18344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18345         this_ptr_conv.is_owned = false;
18346         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
18347         return ret_val;
18348 }
18349
18350 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) {
18351         LDKAcceptChannel this_ptr_conv;
18352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18353         this_ptr_conv.is_owned = false;
18354         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
18355 }
18356
18357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18358         LDKAcceptChannel this_ptr_conv;
18359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18360         this_ptr_conv.is_owned = false;
18361         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
18362         return ret_val;
18363 }
18364
18365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18366         LDKAcceptChannel this_ptr_conv;
18367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18368         this_ptr_conv.is_owned = false;
18369         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
18370 }
18371
18372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18373         LDKAcceptChannel this_ptr_conv;
18374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18375         this_ptr_conv.is_owned = false;
18376         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
18377         return ret_val;
18378 }
18379
18380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18381         LDKAcceptChannel this_ptr_conv;
18382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18383         this_ptr_conv.is_owned = false;
18384         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
18385 }
18386
18387 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
18388         LDKAcceptChannel this_ptr_conv;
18389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18390         this_ptr_conv.is_owned = false;
18391         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
18392         return ret_val;
18393 }
18394
18395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18396         LDKAcceptChannel this_ptr_conv;
18397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18398         this_ptr_conv.is_owned = false;
18399         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
18400 }
18401
18402 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18403         LDKAcceptChannel this_ptr_conv;
18404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18405         this_ptr_conv.is_owned = false;
18406         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
18407         return ret_val;
18408 }
18409
18410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18411         LDKAcceptChannel this_ptr_conv;
18412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18413         this_ptr_conv.is_owned = false;
18414         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
18415 }
18416
18417 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
18418         LDKAcceptChannel this_ptr_conv;
18419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18420         this_ptr_conv.is_owned = false;
18421         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
18422         return ret_val;
18423 }
18424
18425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18426         LDKAcceptChannel this_ptr_conv;
18427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18428         this_ptr_conv.is_owned = false;
18429         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
18430 }
18431
18432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18433         LDKAcceptChannel this_ptr_conv;
18434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18435         this_ptr_conv.is_owned = false;
18436         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
18438         return ret_arr;
18439 }
18440
18441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18442         LDKAcceptChannel this_ptr_conv;
18443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18444         this_ptr_conv.is_owned = false;
18445         LDKPublicKey val_ref;
18446         CHECK((*env)->GetArrayLength(env, val) == 33);
18447         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18448         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
18449 }
18450
18451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18452         LDKAcceptChannel this_ptr_conv;
18453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18454         this_ptr_conv.is_owned = false;
18455         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18457         return ret_arr;
18458 }
18459
18460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18461         LDKAcceptChannel this_ptr_conv;
18462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18463         this_ptr_conv.is_owned = false;
18464         LDKPublicKey val_ref;
18465         CHECK((*env)->GetArrayLength(env, val) == 33);
18466         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18467         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
18468 }
18469
18470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18471         LDKAcceptChannel this_ptr_conv;
18472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18473         this_ptr_conv.is_owned = false;
18474         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
18476         return ret_arr;
18477 }
18478
18479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18480         LDKAcceptChannel this_ptr_conv;
18481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18482         this_ptr_conv.is_owned = false;
18483         LDKPublicKey val_ref;
18484         CHECK((*env)->GetArrayLength(env, val) == 33);
18485         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18486         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
18487 }
18488
18489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18490         LDKAcceptChannel this_ptr_conv;
18491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18492         this_ptr_conv.is_owned = false;
18493         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18495         return ret_arr;
18496 }
18497
18498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18499         LDKAcceptChannel this_ptr_conv;
18500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18501         this_ptr_conv.is_owned = false;
18502         LDKPublicKey val_ref;
18503         CHECK((*env)->GetArrayLength(env, val) == 33);
18504         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18505         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18506 }
18507
18508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18509         LDKAcceptChannel this_ptr_conv;
18510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18511         this_ptr_conv.is_owned = false;
18512         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18514         return ret_arr;
18515 }
18516
18517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18518         LDKAcceptChannel this_ptr_conv;
18519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18520         this_ptr_conv.is_owned = false;
18521         LDKPublicKey val_ref;
18522         CHECK((*env)->GetArrayLength(env, val) == 33);
18523         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18524         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
18525 }
18526
18527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18528         LDKAcceptChannel this_ptr_conv;
18529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18530         this_ptr_conv.is_owned = false;
18531         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18532         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
18533         return ret_arr;
18534 }
18535
18536 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) {
18537         LDKAcceptChannel this_ptr_conv;
18538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18539         this_ptr_conv.is_owned = false;
18540         LDKPublicKey val_ref;
18541         CHECK((*env)->GetArrayLength(env, val) == 33);
18542         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18543         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
18544 }
18545
18546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18547         LDKAcceptChannel orig_conv;
18548         orig_conv.inner = (void*)(orig & (~1));
18549         orig_conv.is_owned = false;
18550         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
18551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18553         uint64_t ret_ref = (uint64_t)ret_var.inner;
18554         if (ret_var.is_owned) {
18555                 ret_ref |= 1;
18556         }
18557         return ret_ref;
18558 }
18559
18560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18561         LDKFundingCreated this_obj_conv;
18562         this_obj_conv.inner = (void*)(this_obj & (~1));
18563         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18564         FundingCreated_free(this_obj_conv);
18565 }
18566
18567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18568         LDKFundingCreated this_ptr_conv;
18569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18570         this_ptr_conv.is_owned = false;
18571         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18572         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
18573         return ret_arr;
18574 }
18575
18576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18577         LDKFundingCreated this_ptr_conv;
18578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18579         this_ptr_conv.is_owned = false;
18580         LDKThirtyTwoBytes val_ref;
18581         CHECK((*env)->GetArrayLength(env, val) == 32);
18582         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18583         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
18584 }
18585
18586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18587         LDKFundingCreated this_ptr_conv;
18588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18589         this_ptr_conv.is_owned = false;
18590         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
18592         return ret_arr;
18593 }
18594
18595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18596         LDKFundingCreated this_ptr_conv;
18597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18598         this_ptr_conv.is_owned = false;
18599         LDKThirtyTwoBytes val_ref;
18600         CHECK((*env)->GetArrayLength(env, val) == 32);
18601         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18602         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
18603 }
18604
18605 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18606         LDKFundingCreated this_ptr_conv;
18607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18608         this_ptr_conv.is_owned = false;
18609         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
18610         return ret_val;
18611 }
18612
18613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18614         LDKFundingCreated this_ptr_conv;
18615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18616         this_ptr_conv.is_owned = false;
18617         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
18618 }
18619
18620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18621         LDKFundingCreated this_ptr_conv;
18622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18623         this_ptr_conv.is_owned = false;
18624         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
18626         return ret_arr;
18627 }
18628
18629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18630         LDKFundingCreated this_ptr_conv;
18631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18632         this_ptr_conv.is_owned = false;
18633         LDKSignature val_ref;
18634         CHECK((*env)->GetArrayLength(env, val) == 64);
18635         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18636         FundingCreated_set_signature(&this_ptr_conv, val_ref);
18637 }
18638
18639 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) {
18640         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
18641         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
18642         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
18643         LDKThirtyTwoBytes funding_txid_arg_ref;
18644         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
18645         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
18646         LDKSignature signature_arg_ref;
18647         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18648         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18649         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
18650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18652         uint64_t ret_ref = (uint64_t)ret_var.inner;
18653         if (ret_var.is_owned) {
18654                 ret_ref |= 1;
18655         }
18656         return ret_ref;
18657 }
18658
18659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18660         LDKFundingCreated orig_conv;
18661         orig_conv.inner = (void*)(orig & (~1));
18662         orig_conv.is_owned = false;
18663         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
18664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18666         uint64_t ret_ref = (uint64_t)ret_var.inner;
18667         if (ret_var.is_owned) {
18668                 ret_ref |= 1;
18669         }
18670         return ret_ref;
18671 }
18672
18673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18674         LDKFundingSigned this_obj_conv;
18675         this_obj_conv.inner = (void*)(this_obj & (~1));
18676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18677         FundingSigned_free(this_obj_conv);
18678 }
18679
18680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18681         LDKFundingSigned this_ptr_conv;
18682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18683         this_ptr_conv.is_owned = false;
18684         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
18686         return ret_arr;
18687 }
18688
18689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18690         LDKFundingSigned this_ptr_conv;
18691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18692         this_ptr_conv.is_owned = false;
18693         LDKThirtyTwoBytes val_ref;
18694         CHECK((*env)->GetArrayLength(env, val) == 32);
18695         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18696         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
18697 }
18698
18699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18700         LDKFundingSigned this_ptr_conv;
18701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18702         this_ptr_conv.is_owned = false;
18703         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
18705         return ret_arr;
18706 }
18707
18708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18709         LDKFundingSigned this_ptr_conv;
18710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18711         this_ptr_conv.is_owned = false;
18712         LDKSignature val_ref;
18713         CHECK((*env)->GetArrayLength(env, val) == 64);
18714         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18715         FundingSigned_set_signature(&this_ptr_conv, val_ref);
18716 }
18717
18718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
18719         LDKThirtyTwoBytes channel_id_arg_ref;
18720         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18721         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18722         LDKSignature signature_arg_ref;
18723         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18724         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18725         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
18726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18728         uint64_t ret_ref = (uint64_t)ret_var.inner;
18729         if (ret_var.is_owned) {
18730                 ret_ref |= 1;
18731         }
18732         return ret_ref;
18733 }
18734
18735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18736         LDKFundingSigned orig_conv;
18737         orig_conv.inner = (void*)(orig & (~1));
18738         orig_conv.is_owned = false;
18739         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
18740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18742         uint64_t ret_ref = (uint64_t)ret_var.inner;
18743         if (ret_var.is_owned) {
18744                 ret_ref |= 1;
18745         }
18746         return ret_ref;
18747 }
18748
18749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18750         LDKFundingLocked this_obj_conv;
18751         this_obj_conv.inner = (void*)(this_obj & (~1));
18752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18753         FundingLocked_free(this_obj_conv);
18754 }
18755
18756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18757         LDKFundingLocked this_ptr_conv;
18758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18759         this_ptr_conv.is_owned = false;
18760         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18761         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
18762         return ret_arr;
18763 }
18764
18765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18766         LDKFundingLocked this_ptr_conv;
18767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18768         this_ptr_conv.is_owned = false;
18769         LDKThirtyTwoBytes val_ref;
18770         CHECK((*env)->GetArrayLength(env, val) == 32);
18771         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18772         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
18773 }
18774
18775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18776         LDKFundingLocked this_ptr_conv;
18777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18778         this_ptr_conv.is_owned = false;
18779         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18781         return ret_arr;
18782 }
18783
18784 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) {
18785         LDKFundingLocked this_ptr_conv;
18786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18787         this_ptr_conv.is_owned = false;
18788         LDKPublicKey val_ref;
18789         CHECK((*env)->GetArrayLength(env, val) == 33);
18790         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18791         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18792 }
18793
18794 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) {
18795         LDKThirtyTwoBytes channel_id_arg_ref;
18796         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18797         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18798         LDKPublicKey next_per_commitment_point_arg_ref;
18799         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18800         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18801         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
18802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18804         uint64_t ret_ref = (uint64_t)ret_var.inner;
18805         if (ret_var.is_owned) {
18806                 ret_ref |= 1;
18807         }
18808         return ret_ref;
18809 }
18810
18811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18812         LDKFundingLocked orig_conv;
18813         orig_conv.inner = (void*)(orig & (~1));
18814         orig_conv.is_owned = false;
18815         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
18816         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18817         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18818         uint64_t ret_ref = (uint64_t)ret_var.inner;
18819         if (ret_var.is_owned) {
18820                 ret_ref |= 1;
18821         }
18822         return ret_ref;
18823 }
18824
18825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18826         LDKShutdown this_obj_conv;
18827         this_obj_conv.inner = (void*)(this_obj & (~1));
18828         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18829         Shutdown_free(this_obj_conv);
18830 }
18831
18832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18833         LDKShutdown this_ptr_conv;
18834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18835         this_ptr_conv.is_owned = false;
18836         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
18838         return ret_arr;
18839 }
18840
18841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18842         LDKShutdown this_ptr_conv;
18843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18844         this_ptr_conv.is_owned = false;
18845         LDKThirtyTwoBytes val_ref;
18846         CHECK((*env)->GetArrayLength(env, val) == 32);
18847         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18848         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
18849 }
18850
18851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18852         LDKShutdown this_ptr_conv;
18853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18854         this_ptr_conv.is_owned = false;
18855         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
18856         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18857         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18858         return ret_arr;
18859 }
18860
18861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18862         LDKShutdown this_ptr_conv;
18863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18864         this_ptr_conv.is_owned = false;
18865         LDKCVec_u8Z val_ref;
18866         val_ref.datalen = (*env)->GetArrayLength(env, val);
18867         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18868         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18869         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18870 }
18871
18872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18873         LDKThirtyTwoBytes channel_id_arg_ref;
18874         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18875         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18876         LDKCVec_u8Z scriptpubkey_arg_ref;
18877         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
18878         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18879         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
18880         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18881         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18882         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18883         uint64_t ret_ref = (uint64_t)ret_var.inner;
18884         if (ret_var.is_owned) {
18885                 ret_ref |= 1;
18886         }
18887         return ret_ref;
18888 }
18889
18890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18891         LDKShutdown orig_conv;
18892         orig_conv.inner = (void*)(orig & (~1));
18893         orig_conv.is_owned = false;
18894         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18897         uint64_t ret_ref = (uint64_t)ret_var.inner;
18898         if (ret_var.is_owned) {
18899                 ret_ref |= 1;
18900         }
18901         return ret_ref;
18902 }
18903
18904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18905         LDKClosingSignedFeeRange this_obj_conv;
18906         this_obj_conv.inner = (void*)(this_obj & (~1));
18907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18908         ClosingSignedFeeRange_free(this_obj_conv);
18909 }
18910
18911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18912         LDKClosingSignedFeeRange this_ptr_conv;
18913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18914         this_ptr_conv.is_owned = false;
18915         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
18916         return ret_val;
18917 }
18918
18919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18920         LDKClosingSignedFeeRange this_ptr_conv;
18921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18922         this_ptr_conv.is_owned = false;
18923         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
18924 }
18925
18926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18927         LDKClosingSignedFeeRange this_ptr_conv;
18928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18929         this_ptr_conv.is_owned = false;
18930         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
18931         return ret_val;
18932 }
18933
18934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18935         LDKClosingSignedFeeRange this_ptr_conv;
18936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18937         this_ptr_conv.is_owned = false;
18938         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
18939 }
18940
18941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
18942         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
18943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18945         uint64_t ret_ref = (uint64_t)ret_var.inner;
18946         if (ret_var.is_owned) {
18947                 ret_ref |= 1;
18948         }
18949         return ret_ref;
18950 }
18951
18952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18953         LDKClosingSignedFeeRange orig_conv;
18954         orig_conv.inner = (void*)(orig & (~1));
18955         orig_conv.is_owned = false;
18956         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
18957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18959         uint64_t ret_ref = (uint64_t)ret_var.inner;
18960         if (ret_var.is_owned) {
18961                 ret_ref |= 1;
18962         }
18963         return ret_ref;
18964 }
18965
18966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18967         LDKClosingSigned this_obj_conv;
18968         this_obj_conv.inner = (void*)(this_obj & (~1));
18969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18970         ClosingSigned_free(this_obj_conv);
18971 }
18972
18973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18974         LDKClosingSigned this_ptr_conv;
18975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18976         this_ptr_conv.is_owned = false;
18977         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
18979         return ret_arr;
18980 }
18981
18982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18983         LDKClosingSigned this_ptr_conv;
18984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18985         this_ptr_conv.is_owned = false;
18986         LDKThirtyTwoBytes val_ref;
18987         CHECK((*env)->GetArrayLength(env, val) == 32);
18988         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18989         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18990 }
18991
18992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18993         LDKClosingSigned this_ptr_conv;
18994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18995         this_ptr_conv.is_owned = false;
18996         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18997         return ret_val;
18998 }
18999
19000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19001         LDKClosingSigned this_ptr_conv;
19002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19003         this_ptr_conv.is_owned = false;
19004         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
19005 }
19006
19007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19008         LDKClosingSigned this_ptr_conv;
19009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19010         this_ptr_conv.is_owned = false;
19011         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
19013         return ret_arr;
19014 }
19015
19016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19017         LDKClosingSigned this_ptr_conv;
19018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19019         this_ptr_conv.is_owned = false;
19020         LDKSignature val_ref;
19021         CHECK((*env)->GetArrayLength(env, val) == 64);
19022         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19023         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
19024 }
19025
19026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
19027         LDKClosingSigned this_ptr_conv;
19028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19029         this_ptr_conv.is_owned = false;
19030         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
19031         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19032         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19033         uint64_t ret_ref = (uint64_t)ret_var.inner;
19034         if (ret_var.is_owned) {
19035                 ret_ref |= 1;
19036         }
19037         return ret_ref;
19038 }
19039
19040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19041         LDKClosingSigned this_ptr_conv;
19042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19043         this_ptr_conv.is_owned = false;
19044         LDKClosingSignedFeeRange val_conv;
19045         val_conv.inner = (void*)(val & (~1));
19046         val_conv.is_owned = (val & 1) || (val == 0);
19047         val_conv = ClosingSignedFeeRange_clone(&val_conv);
19048         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
19049 }
19050
19051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, int64_t fee_range_arg) {
19052         LDKThirtyTwoBytes channel_id_arg_ref;
19053         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19054         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19055         LDKSignature signature_arg_ref;
19056         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19057         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19058         LDKClosingSignedFeeRange fee_range_arg_conv;
19059         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
19060         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
19061         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
19062         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
19063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19065         uint64_t ret_ref = (uint64_t)ret_var.inner;
19066         if (ret_var.is_owned) {
19067                 ret_ref |= 1;
19068         }
19069         return ret_ref;
19070 }
19071
19072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19073         LDKClosingSigned orig_conv;
19074         orig_conv.inner = (void*)(orig & (~1));
19075         orig_conv.is_owned = false;
19076         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
19077         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19078         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19079         uint64_t ret_ref = (uint64_t)ret_var.inner;
19080         if (ret_var.is_owned) {
19081                 ret_ref |= 1;
19082         }
19083         return ret_ref;
19084 }
19085
19086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19087         LDKUpdateAddHTLC this_obj_conv;
19088         this_obj_conv.inner = (void*)(this_obj & (~1));
19089         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19090         UpdateAddHTLC_free(this_obj_conv);
19091 }
19092
19093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19094         LDKUpdateAddHTLC this_ptr_conv;
19095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19096         this_ptr_conv.is_owned = false;
19097         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19098         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
19099         return ret_arr;
19100 }
19101
19102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19103         LDKUpdateAddHTLC this_ptr_conv;
19104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19105         this_ptr_conv.is_owned = false;
19106         LDKThirtyTwoBytes val_ref;
19107         CHECK((*env)->GetArrayLength(env, val) == 32);
19108         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19109         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
19110 }
19111
19112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19113         LDKUpdateAddHTLC this_ptr_conv;
19114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19115         this_ptr_conv.is_owned = false;
19116         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
19117         return ret_val;
19118 }
19119
19120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19121         LDKUpdateAddHTLC this_ptr_conv;
19122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19123         this_ptr_conv.is_owned = false;
19124         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
19125 }
19126
19127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19128         LDKUpdateAddHTLC this_ptr_conv;
19129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19130         this_ptr_conv.is_owned = false;
19131         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
19132         return ret_val;
19133 }
19134
19135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19136         LDKUpdateAddHTLC this_ptr_conv;
19137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19138         this_ptr_conv.is_owned = false;
19139         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
19140 }
19141
19142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19143         LDKUpdateAddHTLC this_ptr_conv;
19144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19145         this_ptr_conv.is_owned = false;
19146         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
19148         return ret_arr;
19149 }
19150
19151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19152         LDKUpdateAddHTLC this_ptr_conv;
19153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19154         this_ptr_conv.is_owned = false;
19155         LDKThirtyTwoBytes val_ref;
19156         CHECK((*env)->GetArrayLength(env, val) == 32);
19157         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19158         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
19159 }
19160
19161 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
19162         LDKUpdateAddHTLC this_ptr_conv;
19163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19164         this_ptr_conv.is_owned = false;
19165         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
19166         return ret_val;
19167 }
19168
19169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19170         LDKUpdateAddHTLC this_ptr_conv;
19171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19172         this_ptr_conv.is_owned = false;
19173         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
19174 }
19175
19176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19177         LDKUpdateAddHTLC orig_conv;
19178         orig_conv.inner = (void*)(orig & (~1));
19179         orig_conv.is_owned = false;
19180         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
19181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19183         uint64_t ret_ref = (uint64_t)ret_var.inner;
19184         if (ret_var.is_owned) {
19185                 ret_ref |= 1;
19186         }
19187         return ret_ref;
19188 }
19189
19190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19191         LDKUpdateFulfillHTLC this_obj_conv;
19192         this_obj_conv.inner = (void*)(this_obj & (~1));
19193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19194         UpdateFulfillHTLC_free(this_obj_conv);
19195 }
19196
19197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19198         LDKUpdateFulfillHTLC this_ptr_conv;
19199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19200         this_ptr_conv.is_owned = false;
19201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
19203         return ret_arr;
19204 }
19205
19206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19207         LDKUpdateFulfillHTLC this_ptr_conv;
19208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19209         this_ptr_conv.is_owned = false;
19210         LDKThirtyTwoBytes val_ref;
19211         CHECK((*env)->GetArrayLength(env, val) == 32);
19212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19213         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
19214 }
19215
19216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19217         LDKUpdateFulfillHTLC this_ptr_conv;
19218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19219         this_ptr_conv.is_owned = false;
19220         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
19221         return ret_val;
19222 }
19223
19224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19225         LDKUpdateFulfillHTLC this_ptr_conv;
19226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19227         this_ptr_conv.is_owned = false;
19228         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
19229 }
19230
19231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
19232         LDKUpdateFulfillHTLC this_ptr_conv;
19233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19234         this_ptr_conv.is_owned = false;
19235         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
19237         return ret_arr;
19238 }
19239
19240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19241         LDKUpdateFulfillHTLC this_ptr_conv;
19242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19243         this_ptr_conv.is_owned = false;
19244         LDKThirtyTwoBytes val_ref;
19245         CHECK((*env)->GetArrayLength(env, val) == 32);
19246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19247         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
19248 }
19249
19250 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) {
19251         LDKThirtyTwoBytes channel_id_arg_ref;
19252         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19253         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19254         LDKThirtyTwoBytes payment_preimage_arg_ref;
19255         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
19256         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
19257         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
19258         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19259         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19260         uint64_t ret_ref = (uint64_t)ret_var.inner;
19261         if (ret_var.is_owned) {
19262                 ret_ref |= 1;
19263         }
19264         return ret_ref;
19265 }
19266
19267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19268         LDKUpdateFulfillHTLC orig_conv;
19269         orig_conv.inner = (void*)(orig & (~1));
19270         orig_conv.is_owned = false;
19271         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
19272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19274         uint64_t ret_ref = (uint64_t)ret_var.inner;
19275         if (ret_var.is_owned) {
19276                 ret_ref |= 1;
19277         }
19278         return ret_ref;
19279 }
19280
19281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19282         LDKUpdateFailHTLC this_obj_conv;
19283         this_obj_conv.inner = (void*)(this_obj & (~1));
19284         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19285         UpdateFailHTLC_free(this_obj_conv);
19286 }
19287
19288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19289         LDKUpdateFailHTLC this_ptr_conv;
19290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19291         this_ptr_conv.is_owned = false;
19292         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
19294         return ret_arr;
19295 }
19296
19297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19298         LDKUpdateFailHTLC this_ptr_conv;
19299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19300         this_ptr_conv.is_owned = false;
19301         LDKThirtyTwoBytes val_ref;
19302         CHECK((*env)->GetArrayLength(env, val) == 32);
19303         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19304         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
19305 }
19306
19307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19308         LDKUpdateFailHTLC this_ptr_conv;
19309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19310         this_ptr_conv.is_owned = false;
19311         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
19312         return ret_val;
19313 }
19314
19315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19316         LDKUpdateFailHTLC this_ptr_conv;
19317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19318         this_ptr_conv.is_owned = false;
19319         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
19320 }
19321
19322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19323         LDKUpdateFailHTLC orig_conv;
19324         orig_conv.inner = (void*)(orig & (~1));
19325         orig_conv.is_owned = false;
19326         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
19327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19329         uint64_t ret_ref = (uint64_t)ret_var.inner;
19330         if (ret_var.is_owned) {
19331                 ret_ref |= 1;
19332         }
19333         return ret_ref;
19334 }
19335
19336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19337         LDKUpdateFailMalformedHTLC this_obj_conv;
19338         this_obj_conv.inner = (void*)(this_obj & (~1));
19339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19340         UpdateFailMalformedHTLC_free(this_obj_conv);
19341 }
19342
19343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19344         LDKUpdateFailMalformedHTLC this_ptr_conv;
19345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19346         this_ptr_conv.is_owned = false;
19347         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19348         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
19349         return ret_arr;
19350 }
19351
19352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19353         LDKUpdateFailMalformedHTLC this_ptr_conv;
19354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19355         this_ptr_conv.is_owned = false;
19356         LDKThirtyTwoBytes val_ref;
19357         CHECK((*env)->GetArrayLength(env, val) == 32);
19358         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19359         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
19360 }
19361
19362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19363         LDKUpdateFailMalformedHTLC this_ptr_conv;
19364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19365         this_ptr_conv.is_owned = false;
19366         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
19367         return ret_val;
19368 }
19369
19370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19371         LDKUpdateFailMalformedHTLC this_ptr_conv;
19372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19373         this_ptr_conv.is_owned = false;
19374         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
19375 }
19376
19377 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
19378         LDKUpdateFailMalformedHTLC this_ptr_conv;
19379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19380         this_ptr_conv.is_owned = false;
19381         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
19382         return ret_val;
19383 }
19384
19385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19386         LDKUpdateFailMalformedHTLC this_ptr_conv;
19387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19388         this_ptr_conv.is_owned = false;
19389         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
19390 }
19391
19392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19393         LDKUpdateFailMalformedHTLC orig_conv;
19394         orig_conv.inner = (void*)(orig & (~1));
19395         orig_conv.is_owned = false;
19396         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
19397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19399         uint64_t ret_ref = (uint64_t)ret_var.inner;
19400         if (ret_var.is_owned) {
19401                 ret_ref |= 1;
19402         }
19403         return ret_ref;
19404 }
19405
19406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19407         LDKCommitmentSigned this_obj_conv;
19408         this_obj_conv.inner = (void*)(this_obj & (~1));
19409         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19410         CommitmentSigned_free(this_obj_conv);
19411 }
19412
19413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19414         LDKCommitmentSigned this_ptr_conv;
19415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19416         this_ptr_conv.is_owned = false;
19417         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
19419         return ret_arr;
19420 }
19421
19422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19423         LDKCommitmentSigned this_ptr_conv;
19424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19425         this_ptr_conv.is_owned = false;
19426         LDKThirtyTwoBytes val_ref;
19427         CHECK((*env)->GetArrayLength(env, val) == 32);
19428         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19429         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
19430 }
19431
19432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19433         LDKCommitmentSigned this_ptr_conv;
19434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19435         this_ptr_conv.is_owned = false;
19436         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
19438         return ret_arr;
19439 }
19440
19441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19442         LDKCommitmentSigned this_ptr_conv;
19443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19444         this_ptr_conv.is_owned = false;
19445         LDKSignature val_ref;
19446         CHECK((*env)->GetArrayLength(env, val) == 64);
19447         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19448         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
19449 }
19450
19451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19452         LDKCommitmentSigned this_ptr_conv;
19453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19454         this_ptr_conv.is_owned = false;
19455         LDKCVec_SignatureZ val_constr;
19456         val_constr.datalen = (*env)->GetArrayLength(env, val);
19457         if (val_constr.datalen > 0)
19458                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19459         else
19460                 val_constr.data = NULL;
19461         for (size_t i = 0; i < val_constr.datalen; i++) {
19462                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
19463                 LDKSignature val_conv_8_ref;
19464                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
19465                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
19466                 val_constr.data[i] = val_conv_8_ref;
19467         }
19468         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
19469 }
19470
19471 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) {
19472         LDKThirtyTwoBytes channel_id_arg_ref;
19473         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19474         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19475         LDKSignature signature_arg_ref;
19476         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19477         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19478         LDKCVec_SignatureZ htlc_signatures_arg_constr;
19479         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
19480         if (htlc_signatures_arg_constr.datalen > 0)
19481                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19482         else
19483                 htlc_signatures_arg_constr.data = NULL;
19484         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
19485                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
19486                 LDKSignature htlc_signatures_arg_conv_8_ref;
19487                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
19488                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
19489                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
19490         }
19491         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
19492         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19493         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19494         uint64_t ret_ref = (uint64_t)ret_var.inner;
19495         if (ret_var.is_owned) {
19496                 ret_ref |= 1;
19497         }
19498         return ret_ref;
19499 }
19500
19501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19502         LDKCommitmentSigned orig_conv;
19503         orig_conv.inner = (void*)(orig & (~1));
19504         orig_conv.is_owned = false;
19505         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
19506         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19507         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19508         uint64_t ret_ref = (uint64_t)ret_var.inner;
19509         if (ret_var.is_owned) {
19510                 ret_ref |= 1;
19511         }
19512         return ret_ref;
19513 }
19514
19515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19516         LDKRevokeAndACK this_obj_conv;
19517         this_obj_conv.inner = (void*)(this_obj & (~1));
19518         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19519         RevokeAndACK_free(this_obj_conv);
19520 }
19521
19522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19523         LDKRevokeAndACK this_ptr_conv;
19524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19525         this_ptr_conv.is_owned = false;
19526         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19527         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
19528         return ret_arr;
19529 }
19530
19531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19532         LDKRevokeAndACK this_ptr_conv;
19533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19534         this_ptr_conv.is_owned = false;
19535         LDKThirtyTwoBytes val_ref;
19536         CHECK((*env)->GetArrayLength(env, val) == 32);
19537         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19538         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
19539 }
19540
19541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19542         LDKRevokeAndACK this_ptr_conv;
19543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19544         this_ptr_conv.is_owned = false;
19545         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
19547         return ret_arr;
19548 }
19549
19550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19551         LDKRevokeAndACK this_ptr_conv;
19552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19553         this_ptr_conv.is_owned = false;
19554         LDKThirtyTwoBytes val_ref;
19555         CHECK((*env)->GetArrayLength(env, val) == 32);
19556         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19557         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
19558 }
19559
19560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19561         LDKRevokeAndACK this_ptr_conv;
19562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19563         this_ptr_conv.is_owned = false;
19564         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19565         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
19566         return ret_arr;
19567 }
19568
19569 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) {
19570         LDKRevokeAndACK this_ptr_conv;
19571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19572         this_ptr_conv.is_owned = false;
19573         LDKPublicKey val_ref;
19574         CHECK((*env)->GetArrayLength(env, val) == 33);
19575         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19576         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
19577 }
19578
19579 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) {
19580         LDKThirtyTwoBytes channel_id_arg_ref;
19581         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19582         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19583         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
19584         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
19585         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
19586         LDKPublicKey next_per_commitment_point_arg_ref;
19587         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
19588         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
19589         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
19590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19592         uint64_t ret_ref = (uint64_t)ret_var.inner;
19593         if (ret_var.is_owned) {
19594                 ret_ref |= 1;
19595         }
19596         return ret_ref;
19597 }
19598
19599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19600         LDKRevokeAndACK orig_conv;
19601         orig_conv.inner = (void*)(orig & (~1));
19602         orig_conv.is_owned = false;
19603         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
19604         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19605         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19606         uint64_t ret_ref = (uint64_t)ret_var.inner;
19607         if (ret_var.is_owned) {
19608                 ret_ref |= 1;
19609         }
19610         return ret_ref;
19611 }
19612
19613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19614         LDKUpdateFee this_obj_conv;
19615         this_obj_conv.inner = (void*)(this_obj & (~1));
19616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19617         UpdateFee_free(this_obj_conv);
19618 }
19619
19620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19621         LDKUpdateFee this_ptr_conv;
19622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19623         this_ptr_conv.is_owned = false;
19624         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
19626         return ret_arr;
19627 }
19628
19629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19630         LDKUpdateFee this_ptr_conv;
19631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19632         this_ptr_conv.is_owned = false;
19633         LDKThirtyTwoBytes val_ref;
19634         CHECK((*env)->GetArrayLength(env, val) == 32);
19635         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19636         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
19637 }
19638
19639 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
19640         LDKUpdateFee this_ptr_conv;
19641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19642         this_ptr_conv.is_owned = false;
19643         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
19644         return ret_val;
19645 }
19646
19647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19648         LDKUpdateFee this_ptr_conv;
19649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19650         this_ptr_conv.is_owned = false;
19651         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
19652 }
19653
19654 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) {
19655         LDKThirtyTwoBytes channel_id_arg_ref;
19656         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19657         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19658         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
19659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19661         uint64_t ret_ref = (uint64_t)ret_var.inner;
19662         if (ret_var.is_owned) {
19663                 ret_ref |= 1;
19664         }
19665         return ret_ref;
19666 }
19667
19668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19669         LDKUpdateFee orig_conv;
19670         orig_conv.inner = (void*)(orig & (~1));
19671         orig_conv.is_owned = false;
19672         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
19673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19675         uint64_t ret_ref = (uint64_t)ret_var.inner;
19676         if (ret_var.is_owned) {
19677                 ret_ref |= 1;
19678         }
19679         return ret_ref;
19680 }
19681
19682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19683         LDKDataLossProtect this_obj_conv;
19684         this_obj_conv.inner = (void*)(this_obj & (~1));
19685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19686         DataLossProtect_free(this_obj_conv);
19687 }
19688
19689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19690         LDKDataLossProtect this_ptr_conv;
19691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19692         this_ptr_conv.is_owned = false;
19693         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19694         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
19695         return ret_arr;
19696 }
19697
19698 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) {
19699         LDKDataLossProtect this_ptr_conv;
19700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19701         this_ptr_conv.is_owned = false;
19702         LDKThirtyTwoBytes val_ref;
19703         CHECK((*env)->GetArrayLength(env, val) == 32);
19704         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19705         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
19706 }
19707
19708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19709         LDKDataLossProtect this_ptr_conv;
19710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19711         this_ptr_conv.is_owned = false;
19712         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
19714         return ret_arr;
19715 }
19716
19717 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) {
19718         LDKDataLossProtect this_ptr_conv;
19719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19720         this_ptr_conv.is_owned = false;
19721         LDKPublicKey val_ref;
19722         CHECK((*env)->GetArrayLength(env, val) == 33);
19723         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19724         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
19725 }
19726
19727 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) {
19728         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
19729         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
19730         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
19731         LDKPublicKey my_current_per_commitment_point_arg_ref;
19732         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
19733         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
19734         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
19735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19737         uint64_t ret_ref = (uint64_t)ret_var.inner;
19738         if (ret_var.is_owned) {
19739                 ret_ref |= 1;
19740         }
19741         return ret_ref;
19742 }
19743
19744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19745         LDKDataLossProtect orig_conv;
19746         orig_conv.inner = (void*)(orig & (~1));
19747         orig_conv.is_owned = false;
19748         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
19749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19751         uint64_t ret_ref = (uint64_t)ret_var.inner;
19752         if (ret_var.is_owned) {
19753                 ret_ref |= 1;
19754         }
19755         return ret_ref;
19756 }
19757
19758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19759         LDKChannelReestablish this_obj_conv;
19760         this_obj_conv.inner = (void*)(this_obj & (~1));
19761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19762         ChannelReestablish_free(this_obj_conv);
19763 }
19764
19765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19766         LDKChannelReestablish this_ptr_conv;
19767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19768         this_ptr_conv.is_owned = false;
19769         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19770         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
19771         return ret_arr;
19772 }
19773
19774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19775         LDKChannelReestablish this_ptr_conv;
19776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19777         this_ptr_conv.is_owned = false;
19778         LDKThirtyTwoBytes val_ref;
19779         CHECK((*env)->GetArrayLength(env, val) == 32);
19780         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19781         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
19782 }
19783
19784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19785         LDKChannelReestablish this_ptr_conv;
19786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19787         this_ptr_conv.is_owned = false;
19788         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
19789         return ret_val;
19790 }
19791
19792 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) {
19793         LDKChannelReestablish this_ptr_conv;
19794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19795         this_ptr_conv.is_owned = false;
19796         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
19797 }
19798
19799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19800         LDKChannelReestablish this_ptr_conv;
19801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19802         this_ptr_conv.is_owned = false;
19803         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
19804         return ret_val;
19805 }
19806
19807 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) {
19808         LDKChannelReestablish this_ptr_conv;
19809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19810         this_ptr_conv.is_owned = false;
19811         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
19812 }
19813
19814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19815         LDKChannelReestablish orig_conv;
19816         orig_conv.inner = (void*)(orig & (~1));
19817         orig_conv.is_owned = false;
19818         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
19819         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19820         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19821         uint64_t ret_ref = (uint64_t)ret_var.inner;
19822         if (ret_var.is_owned) {
19823                 ret_ref |= 1;
19824         }
19825         return ret_ref;
19826 }
19827
19828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19829         LDKAnnouncementSignatures this_obj_conv;
19830         this_obj_conv.inner = (void*)(this_obj & (~1));
19831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19832         AnnouncementSignatures_free(this_obj_conv);
19833 }
19834
19835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19836         LDKAnnouncementSignatures this_ptr_conv;
19837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19838         this_ptr_conv.is_owned = false;
19839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
19841         return ret_arr;
19842 }
19843
19844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19845         LDKAnnouncementSignatures this_ptr_conv;
19846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19847         this_ptr_conv.is_owned = false;
19848         LDKThirtyTwoBytes val_ref;
19849         CHECK((*env)->GetArrayLength(env, val) == 32);
19850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19851         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
19852 }
19853
19854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19855         LDKAnnouncementSignatures this_ptr_conv;
19856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19857         this_ptr_conv.is_owned = false;
19858         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
19859         return ret_val;
19860 }
19861
19862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19863         LDKAnnouncementSignatures this_ptr_conv;
19864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19865         this_ptr_conv.is_owned = false;
19866         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19867 }
19868
19869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19870         LDKAnnouncementSignatures this_ptr_conv;
19871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19872         this_ptr_conv.is_owned = false;
19873         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
19875         return ret_arr;
19876 }
19877
19878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19879         LDKAnnouncementSignatures this_ptr_conv;
19880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19881         this_ptr_conv.is_owned = false;
19882         LDKSignature val_ref;
19883         CHECK((*env)->GetArrayLength(env, val) == 64);
19884         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19885         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19886 }
19887
19888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19889         LDKAnnouncementSignatures this_ptr_conv;
19890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19891         this_ptr_conv.is_owned = false;
19892         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19893         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
19894         return ret_arr;
19895 }
19896
19897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19898         LDKAnnouncementSignatures this_ptr_conv;
19899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19900         this_ptr_conv.is_owned = false;
19901         LDKSignature val_ref;
19902         CHECK((*env)->GetArrayLength(env, val) == 64);
19903         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19904         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19905 }
19906
19907 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) {
19908         LDKThirtyTwoBytes channel_id_arg_ref;
19909         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19910         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19911         LDKSignature node_signature_arg_ref;
19912         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
19913         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
19914         LDKSignature bitcoin_signature_arg_ref;
19915         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
19916         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
19917         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19920         uint64_t ret_ref = (uint64_t)ret_var.inner;
19921         if (ret_var.is_owned) {
19922                 ret_ref |= 1;
19923         }
19924         return ret_ref;
19925 }
19926
19927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19928         LDKAnnouncementSignatures orig_conv;
19929         orig_conv.inner = (void*)(orig & (~1));
19930         orig_conv.is_owned = false;
19931         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19934         uint64_t ret_ref = (uint64_t)ret_var.inner;
19935         if (ret_var.is_owned) {
19936                 ret_ref |= 1;
19937         }
19938         return ret_ref;
19939 }
19940
19941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19942         if ((this_ptr & 1) != 0) return;
19943         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19944         FREE((void*)this_ptr);
19945         NetAddress_free(this_ptr_conv);
19946 }
19947
19948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19949         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19950         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19951         *ret_copy = NetAddress_clone(orig_conv);
19952         uint64_t ret_ref = (uint64_t)ret_copy;
19953         return ret_ref;
19954 }
19955
19956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19957         LDKFourBytes addr_ref;
19958         CHECK((*env)->GetArrayLength(env, addr) == 4);
19959         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
19960         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19961         *ret_copy = NetAddress_ipv4(addr_ref, port);
19962         uint64_t ret_ref = (uint64_t)ret_copy;
19963         return ret_ref;
19964 }
19965
19966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19967         LDKSixteenBytes addr_ref;
19968         CHECK((*env)->GetArrayLength(env, addr) == 16);
19969         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
19970         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19971         *ret_copy = NetAddress_ipv6(addr_ref, port);
19972         uint64_t ret_ref = (uint64_t)ret_copy;
19973         return ret_ref;
19974 }
19975
19976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19977         LDKTenBytes addr_ref;
19978         CHECK((*env)->GetArrayLength(env, addr) == 10);
19979         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
19980         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19981         *ret_copy = NetAddress_onion_v2(addr_ref, port);
19982         uint64_t ret_ref = (uint64_t)ret_copy;
19983         return ret_ref;
19984 }
19985
19986 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) {
19987         LDKThirtyTwoBytes ed25519_pubkey_ref;
19988         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
19989         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
19990         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19991         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
19992         uint64_t ret_ref = (uint64_t)ret_copy;
19993         return ret_ref;
19994 }
19995
19996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
19997         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19998         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20001         CVec_u8Z_free(ret_var);
20002         return ret_arr;
20003 }
20004
20005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20006         LDKu8slice ser_ref;
20007         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20008         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20009         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
20010         *ret_conv = Result_read(ser_ref);
20011         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20012         return (uint64_t)ret_conv;
20013 }
20014
20015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20016         LDKu8slice ser_ref;
20017         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20018         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20019         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20020         *ret_conv = NetAddress_read(ser_ref);
20021         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20022         return (uint64_t)ret_conv;
20023 }
20024
20025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20026         LDKUnsignedNodeAnnouncement this_obj_conv;
20027         this_obj_conv.inner = (void*)(this_obj & (~1));
20028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20029         UnsignedNodeAnnouncement_free(this_obj_conv);
20030 }
20031
20032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20033         LDKUnsignedNodeAnnouncement this_ptr_conv;
20034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20035         this_ptr_conv.is_owned = false;
20036         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
20037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20039         uint64_t ret_ref = (uint64_t)ret_var.inner;
20040         if (ret_var.is_owned) {
20041                 ret_ref |= 1;
20042         }
20043         return ret_ref;
20044 }
20045
20046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20047         LDKUnsignedNodeAnnouncement this_ptr_conv;
20048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20049         this_ptr_conv.is_owned = false;
20050         LDKNodeFeatures val_conv;
20051         val_conv.inner = (void*)(val & (~1));
20052         val_conv.is_owned = (val & 1) || (val == 0);
20053         val_conv = NodeFeatures_clone(&val_conv);
20054         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
20055 }
20056
20057 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20058         LDKUnsignedNodeAnnouncement this_ptr_conv;
20059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20060         this_ptr_conv.is_owned = false;
20061         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
20062         return ret_val;
20063 }
20064
20065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20066         LDKUnsignedNodeAnnouncement this_ptr_conv;
20067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20068         this_ptr_conv.is_owned = false;
20069         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
20070 }
20071
20072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20073         LDKUnsignedNodeAnnouncement this_ptr_conv;
20074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20075         this_ptr_conv.is_owned = false;
20076         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20077         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
20078         return ret_arr;
20079 }
20080
20081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20082         LDKUnsignedNodeAnnouncement this_ptr_conv;
20083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20084         this_ptr_conv.is_owned = false;
20085         LDKPublicKey val_ref;
20086         CHECK((*env)->GetArrayLength(env, val) == 33);
20087         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20088         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
20089 }
20090
20091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
20092         LDKUnsignedNodeAnnouncement this_ptr_conv;
20093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20094         this_ptr_conv.is_owned = false;
20095         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
20096         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
20097         return ret_arr;
20098 }
20099
20100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20101         LDKUnsignedNodeAnnouncement this_ptr_conv;
20102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20103         this_ptr_conv.is_owned = false;
20104         LDKThreeBytes val_ref;
20105         CHECK((*env)->GetArrayLength(env, val) == 3);
20106         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
20107         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
20108 }
20109
20110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
20111         LDKUnsignedNodeAnnouncement this_ptr_conv;
20112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20113         this_ptr_conv.is_owned = false;
20114         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
20116         return ret_arr;
20117 }
20118
20119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20120         LDKUnsignedNodeAnnouncement this_ptr_conv;
20121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20122         this_ptr_conv.is_owned = false;
20123         LDKThirtyTwoBytes val_ref;
20124         CHECK((*env)->GetArrayLength(env, val) == 32);
20125         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20126         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
20127 }
20128
20129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20130         LDKUnsignedNodeAnnouncement this_ptr_conv;
20131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20132         this_ptr_conv.is_owned = false;
20133         LDKCVec_NetAddressZ val_constr;
20134         val_constr.datalen = (*env)->GetArrayLength(env, val);
20135         if (val_constr.datalen > 0)
20136                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20137         else
20138                 val_constr.data = NULL;
20139         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20140         for (size_t m = 0; m < val_constr.datalen; m++) {
20141                 int64_t val_conv_12 = val_vals[m];
20142                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
20143                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
20144                 val_constr.data[m] = val_conv_12_conv;
20145         }
20146         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20147         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
20148 }
20149
20150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20151         LDKUnsignedNodeAnnouncement orig_conv;
20152         orig_conv.inner = (void*)(orig & (~1));
20153         orig_conv.is_owned = false;
20154         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
20155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20157         uint64_t ret_ref = (uint64_t)ret_var.inner;
20158         if (ret_var.is_owned) {
20159                 ret_ref |= 1;
20160         }
20161         return ret_ref;
20162 }
20163
20164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20165         LDKNodeAnnouncement this_obj_conv;
20166         this_obj_conv.inner = (void*)(this_obj & (~1));
20167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20168         NodeAnnouncement_free(this_obj_conv);
20169 }
20170
20171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20172         LDKNodeAnnouncement this_ptr_conv;
20173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20174         this_ptr_conv.is_owned = false;
20175         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
20177         return ret_arr;
20178 }
20179
20180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20181         LDKNodeAnnouncement this_ptr_conv;
20182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20183         this_ptr_conv.is_owned = false;
20184         LDKSignature val_ref;
20185         CHECK((*env)->GetArrayLength(env, val) == 64);
20186         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20187         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
20188 }
20189
20190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20191         LDKNodeAnnouncement this_ptr_conv;
20192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20193         this_ptr_conv.is_owned = false;
20194         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
20195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20197         uint64_t ret_ref = (uint64_t)ret_var.inner;
20198         if (ret_var.is_owned) {
20199                 ret_ref |= 1;
20200         }
20201         return ret_ref;
20202 }
20203
20204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20205         LDKNodeAnnouncement this_ptr_conv;
20206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20207         this_ptr_conv.is_owned = false;
20208         LDKUnsignedNodeAnnouncement val_conv;
20209         val_conv.inner = (void*)(val & (~1));
20210         val_conv.is_owned = (val & 1) || (val == 0);
20211         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
20212         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
20213 }
20214
20215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
20216         LDKSignature signature_arg_ref;
20217         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20218         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20219         LDKUnsignedNodeAnnouncement contents_arg_conv;
20220         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20221         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20222         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
20223         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
20224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20226         uint64_t ret_ref = (uint64_t)ret_var.inner;
20227         if (ret_var.is_owned) {
20228                 ret_ref |= 1;
20229         }
20230         return ret_ref;
20231 }
20232
20233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20234         LDKNodeAnnouncement orig_conv;
20235         orig_conv.inner = (void*)(orig & (~1));
20236         orig_conv.is_owned = false;
20237         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
20238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20240         uint64_t ret_ref = (uint64_t)ret_var.inner;
20241         if (ret_var.is_owned) {
20242                 ret_ref |= 1;
20243         }
20244         return ret_ref;
20245 }
20246
20247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20248         LDKUnsignedChannelAnnouncement this_obj_conv;
20249         this_obj_conv.inner = (void*)(this_obj & (~1));
20250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20251         UnsignedChannelAnnouncement_free(this_obj_conv);
20252 }
20253
20254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20255         LDKUnsignedChannelAnnouncement this_ptr_conv;
20256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20257         this_ptr_conv.is_owned = false;
20258         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
20259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20261         uint64_t ret_ref = (uint64_t)ret_var.inner;
20262         if (ret_var.is_owned) {
20263                 ret_ref |= 1;
20264         }
20265         return ret_ref;
20266 }
20267
20268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20269         LDKUnsignedChannelAnnouncement this_ptr_conv;
20270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20271         this_ptr_conv.is_owned = false;
20272         LDKChannelFeatures val_conv;
20273         val_conv.inner = (void*)(val & (~1));
20274         val_conv.is_owned = (val & 1) || (val == 0);
20275         val_conv = ChannelFeatures_clone(&val_conv);
20276         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
20277 }
20278
20279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20280         LDKUnsignedChannelAnnouncement this_ptr_conv;
20281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20282         this_ptr_conv.is_owned = false;
20283         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
20285         return ret_arr;
20286 }
20287
20288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20289         LDKUnsignedChannelAnnouncement this_ptr_conv;
20290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20291         this_ptr_conv.is_owned = false;
20292         LDKThirtyTwoBytes val_ref;
20293         CHECK((*env)->GetArrayLength(env, val) == 32);
20294         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20295         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
20296 }
20297
20298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20299         LDKUnsignedChannelAnnouncement this_ptr_conv;
20300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20301         this_ptr_conv.is_owned = false;
20302         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
20303         return ret_val;
20304 }
20305
20306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20307         LDKUnsignedChannelAnnouncement this_ptr_conv;
20308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20309         this_ptr_conv.is_owned = false;
20310         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
20311 }
20312
20313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20314         LDKUnsignedChannelAnnouncement 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, 33);
20318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
20319         return ret_arr;
20320 }
20321
20322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20323         LDKUnsignedChannelAnnouncement this_ptr_conv;
20324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20325         this_ptr_conv.is_owned = false;
20326         LDKPublicKey val_ref;
20327         CHECK((*env)->GetArrayLength(env, val) == 33);
20328         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20329         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
20330 }
20331
20332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20333         LDKUnsignedChannelAnnouncement this_ptr_conv;
20334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20335         this_ptr_conv.is_owned = false;
20336         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20337         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
20338         return ret_arr;
20339 }
20340
20341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20342         LDKUnsignedChannelAnnouncement this_ptr_conv;
20343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20344         this_ptr_conv.is_owned = false;
20345         LDKPublicKey val_ref;
20346         CHECK((*env)->GetArrayLength(env, val) == 33);
20347         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20348         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
20349 }
20350
20351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20352         LDKUnsignedChannelAnnouncement this_ptr_conv;
20353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20354         this_ptr_conv.is_owned = false;
20355         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
20357         return ret_arr;
20358 }
20359
20360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20361         LDKUnsignedChannelAnnouncement this_ptr_conv;
20362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20363         this_ptr_conv.is_owned = false;
20364         LDKPublicKey val_ref;
20365         CHECK((*env)->GetArrayLength(env, val) == 33);
20366         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20367         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
20368 }
20369
20370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20371         LDKUnsignedChannelAnnouncement this_ptr_conv;
20372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20373         this_ptr_conv.is_owned = false;
20374         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
20376         return ret_arr;
20377 }
20378
20379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20380         LDKUnsignedChannelAnnouncement this_ptr_conv;
20381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20382         this_ptr_conv.is_owned = false;
20383         LDKPublicKey val_ref;
20384         CHECK((*env)->GetArrayLength(env, val) == 33);
20385         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20386         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
20387 }
20388
20389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20390         LDKUnsignedChannelAnnouncement orig_conv;
20391         orig_conv.inner = (void*)(orig & (~1));
20392         orig_conv.is_owned = false;
20393         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
20394         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20395         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20396         uint64_t ret_ref = (uint64_t)ret_var.inner;
20397         if (ret_var.is_owned) {
20398                 ret_ref |= 1;
20399         }
20400         return ret_ref;
20401 }
20402
20403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20404         LDKChannelAnnouncement this_obj_conv;
20405         this_obj_conv.inner = (void*)(this_obj & (~1));
20406         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20407         ChannelAnnouncement_free(this_obj_conv);
20408 }
20409
20410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20411         LDKChannelAnnouncement this_ptr_conv;
20412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20413         this_ptr_conv.is_owned = false;
20414         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
20416         return ret_arr;
20417 }
20418
20419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20420         LDKChannelAnnouncement this_ptr_conv;
20421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20422         this_ptr_conv.is_owned = false;
20423         LDKSignature val_ref;
20424         CHECK((*env)->GetArrayLength(env, val) == 64);
20425         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20426         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
20427 }
20428
20429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20430         LDKChannelAnnouncement this_ptr_conv;
20431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20432         this_ptr_conv.is_owned = false;
20433         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
20435         return ret_arr;
20436 }
20437
20438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20439         LDKChannelAnnouncement this_ptr_conv;
20440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20441         this_ptr_conv.is_owned = false;
20442         LDKSignature val_ref;
20443         CHECK((*env)->GetArrayLength(env, val) == 64);
20444         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20445         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
20446 }
20447
20448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20449         LDKChannelAnnouncement this_ptr_conv;
20450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20451         this_ptr_conv.is_owned = false;
20452         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20453         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
20454         return ret_arr;
20455 }
20456
20457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20458         LDKChannelAnnouncement this_ptr_conv;
20459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20460         this_ptr_conv.is_owned = false;
20461         LDKSignature val_ref;
20462         CHECK((*env)->GetArrayLength(env, val) == 64);
20463         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20464         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
20465 }
20466
20467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20468         LDKChannelAnnouncement this_ptr_conv;
20469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20470         this_ptr_conv.is_owned = false;
20471         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
20473         return ret_arr;
20474 }
20475
20476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20477         LDKChannelAnnouncement this_ptr_conv;
20478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20479         this_ptr_conv.is_owned = false;
20480         LDKSignature val_ref;
20481         CHECK((*env)->GetArrayLength(env, val) == 64);
20482         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20483         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
20484 }
20485
20486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20487         LDKChannelAnnouncement this_ptr_conv;
20488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20489         this_ptr_conv.is_owned = false;
20490         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
20491         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20492         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20493         uint64_t ret_ref = (uint64_t)ret_var.inner;
20494         if (ret_var.is_owned) {
20495                 ret_ref |= 1;
20496         }
20497         return ret_ref;
20498 }
20499
20500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20501         LDKChannelAnnouncement this_ptr_conv;
20502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20503         this_ptr_conv.is_owned = false;
20504         LDKUnsignedChannelAnnouncement val_conv;
20505         val_conv.inner = (void*)(val & (~1));
20506         val_conv.is_owned = (val & 1) || (val == 0);
20507         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
20508         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
20509 }
20510
20511 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) {
20512         LDKSignature node_signature_1_arg_ref;
20513         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
20514         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
20515         LDKSignature node_signature_2_arg_ref;
20516         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
20517         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
20518         LDKSignature bitcoin_signature_1_arg_ref;
20519         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
20520         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
20521         LDKSignature bitcoin_signature_2_arg_ref;
20522         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
20523         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
20524         LDKUnsignedChannelAnnouncement contents_arg_conv;
20525         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20526         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20527         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
20528         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);
20529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20531         uint64_t ret_ref = (uint64_t)ret_var.inner;
20532         if (ret_var.is_owned) {
20533                 ret_ref |= 1;
20534         }
20535         return ret_ref;
20536 }
20537
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20539         LDKChannelAnnouncement orig_conv;
20540         orig_conv.inner = (void*)(orig & (~1));
20541         orig_conv.is_owned = false;
20542         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
20543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20545         uint64_t ret_ref = (uint64_t)ret_var.inner;
20546         if (ret_var.is_owned) {
20547                 ret_ref |= 1;
20548         }
20549         return ret_ref;
20550 }
20551
20552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20553         LDKUnsignedChannelUpdate this_obj_conv;
20554         this_obj_conv.inner = (void*)(this_obj & (~1));
20555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20556         UnsignedChannelUpdate_free(this_obj_conv);
20557 }
20558
20559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20560         LDKUnsignedChannelUpdate this_ptr_conv;
20561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20562         this_ptr_conv.is_owned = false;
20563         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20564         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
20565         return ret_arr;
20566 }
20567
20568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20569         LDKUnsignedChannelUpdate this_ptr_conv;
20570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20571         this_ptr_conv.is_owned = false;
20572         LDKThirtyTwoBytes val_ref;
20573         CHECK((*env)->GetArrayLength(env, val) == 32);
20574         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20575         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
20576 }
20577
20578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20579         LDKUnsignedChannelUpdate this_ptr_conv;
20580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20581         this_ptr_conv.is_owned = false;
20582         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
20583         return ret_val;
20584 }
20585
20586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20587         LDKUnsignedChannelUpdate this_ptr_conv;
20588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20589         this_ptr_conv.is_owned = false;
20590         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
20591 }
20592
20593 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20594         LDKUnsignedChannelUpdate this_ptr_conv;
20595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20596         this_ptr_conv.is_owned = false;
20597         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
20598         return ret_val;
20599 }
20600
20601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20602         LDKUnsignedChannelUpdate this_ptr_conv;
20603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20604         this_ptr_conv.is_owned = false;
20605         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
20606 }
20607
20608 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
20609         LDKUnsignedChannelUpdate this_ptr_conv;
20610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20611         this_ptr_conv.is_owned = false;
20612         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
20613         return ret_val;
20614 }
20615
20616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
20617         LDKUnsignedChannelUpdate this_ptr_conv;
20618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20619         this_ptr_conv.is_owned = false;
20620         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
20621 }
20622
20623 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20624         LDKUnsignedChannelUpdate this_ptr_conv;
20625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20626         this_ptr_conv.is_owned = false;
20627         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
20628         return ret_val;
20629 }
20630
20631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20632         LDKUnsignedChannelUpdate this_ptr_conv;
20633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20634         this_ptr_conv.is_owned = false;
20635         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
20636 }
20637
20638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20639         LDKUnsignedChannelUpdate this_ptr_conv;
20640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20641         this_ptr_conv.is_owned = false;
20642         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
20643         return ret_val;
20644 }
20645
20646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20647         LDKUnsignedChannelUpdate this_ptr_conv;
20648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20649         this_ptr_conv.is_owned = false;
20650         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
20651 }
20652
20653 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20654         LDKUnsignedChannelUpdate this_ptr_conv;
20655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20656         this_ptr_conv.is_owned = false;
20657         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
20658         return ret_val;
20659 }
20660
20661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20662         LDKUnsignedChannelUpdate this_ptr_conv;
20663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20664         this_ptr_conv.is_owned = false;
20665         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
20666 }
20667
20668 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20669         LDKUnsignedChannelUpdate this_ptr_conv;
20670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20671         this_ptr_conv.is_owned = false;
20672         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
20673         return ret_val;
20674 }
20675
20676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20677         LDKUnsignedChannelUpdate this_ptr_conv;
20678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20679         this_ptr_conv.is_owned = false;
20680         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
20681 }
20682
20683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20684         LDKUnsignedChannelUpdate orig_conv;
20685         orig_conv.inner = (void*)(orig & (~1));
20686         orig_conv.is_owned = false;
20687         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
20688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20690         uint64_t ret_ref = (uint64_t)ret_var.inner;
20691         if (ret_var.is_owned) {
20692                 ret_ref |= 1;
20693         }
20694         return ret_ref;
20695 }
20696
20697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20698         LDKChannelUpdate this_obj_conv;
20699         this_obj_conv.inner = (void*)(this_obj & (~1));
20700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20701         ChannelUpdate_free(this_obj_conv);
20702 }
20703
20704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20705         LDKChannelUpdate this_ptr_conv;
20706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20707         this_ptr_conv.is_owned = false;
20708         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
20710         return ret_arr;
20711 }
20712
20713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20714         LDKChannelUpdate this_ptr_conv;
20715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20716         this_ptr_conv.is_owned = false;
20717         LDKSignature val_ref;
20718         CHECK((*env)->GetArrayLength(env, val) == 64);
20719         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20720         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
20721 }
20722
20723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20724         LDKChannelUpdate this_ptr_conv;
20725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20726         this_ptr_conv.is_owned = false;
20727         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
20728         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20729         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20730         uint64_t ret_ref = (uint64_t)ret_var.inner;
20731         if (ret_var.is_owned) {
20732                 ret_ref |= 1;
20733         }
20734         return ret_ref;
20735 }
20736
20737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20738         LDKChannelUpdate this_ptr_conv;
20739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20740         this_ptr_conv.is_owned = false;
20741         LDKUnsignedChannelUpdate val_conv;
20742         val_conv.inner = (void*)(val & (~1));
20743         val_conv.is_owned = (val & 1) || (val == 0);
20744         val_conv = UnsignedChannelUpdate_clone(&val_conv);
20745         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
20746 }
20747
20748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
20749         LDKSignature signature_arg_ref;
20750         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20751         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20752         LDKUnsignedChannelUpdate contents_arg_conv;
20753         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20754         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20755         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
20756         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
20757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20759         uint64_t ret_ref = (uint64_t)ret_var.inner;
20760         if (ret_var.is_owned) {
20761                 ret_ref |= 1;
20762         }
20763         return ret_ref;
20764 }
20765
20766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20767         LDKChannelUpdate orig_conv;
20768         orig_conv.inner = (void*)(orig & (~1));
20769         orig_conv.is_owned = false;
20770         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
20771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20773         uint64_t ret_ref = (uint64_t)ret_var.inner;
20774         if (ret_var.is_owned) {
20775                 ret_ref |= 1;
20776         }
20777         return ret_ref;
20778 }
20779
20780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20781         LDKQueryChannelRange this_obj_conv;
20782         this_obj_conv.inner = (void*)(this_obj & (~1));
20783         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20784         QueryChannelRange_free(this_obj_conv);
20785 }
20786
20787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20788         LDKQueryChannelRange this_ptr_conv;
20789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20790         this_ptr_conv.is_owned = false;
20791         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
20793         return ret_arr;
20794 }
20795
20796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20797         LDKQueryChannelRange this_ptr_conv;
20798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20799         this_ptr_conv.is_owned = false;
20800         LDKThirtyTwoBytes val_ref;
20801         CHECK((*env)->GetArrayLength(env, val) == 32);
20802         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20803         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20804 }
20805
20806 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20807         LDKQueryChannelRange this_ptr_conv;
20808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20809         this_ptr_conv.is_owned = false;
20810         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
20811         return ret_val;
20812 }
20813
20814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20815         LDKQueryChannelRange this_ptr_conv;
20816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20817         this_ptr_conv.is_owned = false;
20818         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
20819 }
20820
20821 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20822         LDKQueryChannelRange this_ptr_conv;
20823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20824         this_ptr_conv.is_owned = false;
20825         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
20826         return ret_val;
20827 }
20828
20829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20830         LDKQueryChannelRange this_ptr_conv;
20831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20832         this_ptr_conv.is_owned = false;
20833         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20834 }
20835
20836 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) {
20837         LDKThirtyTwoBytes chain_hash_arg_ref;
20838         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20839         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20840         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
20841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20843         uint64_t ret_ref = (uint64_t)ret_var.inner;
20844         if (ret_var.is_owned) {
20845                 ret_ref |= 1;
20846         }
20847         return ret_ref;
20848 }
20849
20850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20851         LDKQueryChannelRange orig_conv;
20852         orig_conv.inner = (void*)(orig & (~1));
20853         orig_conv.is_owned = false;
20854         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
20855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20857         uint64_t ret_ref = (uint64_t)ret_var.inner;
20858         if (ret_var.is_owned) {
20859                 ret_ref |= 1;
20860         }
20861         return ret_ref;
20862 }
20863
20864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20865         LDKReplyChannelRange this_obj_conv;
20866         this_obj_conv.inner = (void*)(this_obj & (~1));
20867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20868         ReplyChannelRange_free(this_obj_conv);
20869 }
20870
20871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20872         LDKReplyChannelRange this_ptr_conv;
20873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20874         this_ptr_conv.is_owned = false;
20875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
20877         return ret_arr;
20878 }
20879
20880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20881         LDKReplyChannelRange this_ptr_conv;
20882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20883         this_ptr_conv.is_owned = false;
20884         LDKThirtyTwoBytes val_ref;
20885         CHECK((*env)->GetArrayLength(env, val) == 32);
20886         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20887         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20888 }
20889
20890 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20891         LDKReplyChannelRange this_ptr_conv;
20892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20893         this_ptr_conv.is_owned = false;
20894         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20895         return ret_val;
20896 }
20897
20898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20899         LDKReplyChannelRange this_ptr_conv;
20900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20901         this_ptr_conv.is_owned = false;
20902         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20903 }
20904
20905 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20906         LDKReplyChannelRange this_ptr_conv;
20907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20908         this_ptr_conv.is_owned = false;
20909         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20910         return ret_val;
20911 }
20912
20913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20914         LDKReplyChannelRange this_ptr_conv;
20915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20916         this_ptr_conv.is_owned = false;
20917         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20918 }
20919
20920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
20921         LDKReplyChannelRange this_ptr_conv;
20922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20923         this_ptr_conv.is_owned = false;
20924         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20925         return ret_val;
20926 }
20927
20928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20929         LDKReplyChannelRange this_ptr_conv;
20930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20931         this_ptr_conv.is_owned = false;
20932         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20933 }
20934
20935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20936         LDKReplyChannelRange this_ptr_conv;
20937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20938         this_ptr_conv.is_owned = false;
20939         LDKCVec_u64Z val_constr;
20940         val_constr.datalen = (*env)->GetArrayLength(env, val);
20941         if (val_constr.datalen > 0)
20942                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20943         else
20944                 val_constr.data = NULL;
20945         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20946         for (size_t g = 0; g < val_constr.datalen; g++) {
20947                 int64_t val_conv_6 = val_vals[g];
20948                 val_constr.data[g] = val_conv_6;
20949         }
20950         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20951         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20952 }
20953
20954 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) {
20955         LDKThirtyTwoBytes chain_hash_arg_ref;
20956         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20957         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20958         LDKCVec_u64Z short_channel_ids_arg_constr;
20959         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20960         if (short_channel_ids_arg_constr.datalen > 0)
20961                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20962         else
20963                 short_channel_ids_arg_constr.data = NULL;
20964         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20965         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20966                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20967                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20968         }
20969         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20970         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20973         uint64_t ret_ref = (uint64_t)ret_var.inner;
20974         if (ret_var.is_owned) {
20975                 ret_ref |= 1;
20976         }
20977         return ret_ref;
20978 }
20979
20980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20981         LDKReplyChannelRange orig_conv;
20982         orig_conv.inner = (void*)(orig & (~1));
20983         orig_conv.is_owned = false;
20984         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20985         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20986         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20987         uint64_t ret_ref = (uint64_t)ret_var.inner;
20988         if (ret_var.is_owned) {
20989                 ret_ref |= 1;
20990         }
20991         return ret_ref;
20992 }
20993
20994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20995         LDKQueryShortChannelIds this_obj_conv;
20996         this_obj_conv.inner = (void*)(this_obj & (~1));
20997         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20998         QueryShortChannelIds_free(this_obj_conv);
20999 }
21000
21001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21002         LDKQueryShortChannelIds this_ptr_conv;
21003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21004         this_ptr_conv.is_owned = false;
21005         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
21007         return ret_arr;
21008 }
21009
21010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21011         LDKQueryShortChannelIds this_ptr_conv;
21012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21013         this_ptr_conv.is_owned = false;
21014         LDKThirtyTwoBytes val_ref;
21015         CHECK((*env)->GetArrayLength(env, val) == 32);
21016         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21017         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
21018 }
21019
21020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21021         LDKQueryShortChannelIds this_ptr_conv;
21022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21023         this_ptr_conv.is_owned = false;
21024         LDKCVec_u64Z val_constr;
21025         val_constr.datalen = (*env)->GetArrayLength(env, val);
21026         if (val_constr.datalen > 0)
21027                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21028         else
21029                 val_constr.data = NULL;
21030         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21031         for (size_t g = 0; g < val_constr.datalen; g++) {
21032                 int64_t val_conv_6 = val_vals[g];
21033                 val_constr.data[g] = val_conv_6;
21034         }
21035         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21036         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
21037 }
21038
21039 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) {
21040         LDKThirtyTwoBytes chain_hash_arg_ref;
21041         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
21042         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
21043         LDKCVec_u64Z short_channel_ids_arg_constr;
21044         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
21045         if (short_channel_ids_arg_constr.datalen > 0)
21046                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21047         else
21048                 short_channel_ids_arg_constr.data = NULL;
21049         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
21050         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
21051                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
21052                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
21053         }
21054         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
21055         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
21056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21058         uint64_t ret_ref = (uint64_t)ret_var.inner;
21059         if (ret_var.is_owned) {
21060                 ret_ref |= 1;
21061         }
21062         return ret_ref;
21063 }
21064
21065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21066         LDKQueryShortChannelIds orig_conv;
21067         orig_conv.inner = (void*)(orig & (~1));
21068         orig_conv.is_owned = false;
21069         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
21070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21072         uint64_t ret_ref = (uint64_t)ret_var.inner;
21073         if (ret_var.is_owned) {
21074                 ret_ref |= 1;
21075         }
21076         return ret_ref;
21077 }
21078
21079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21080         LDKReplyShortChannelIdsEnd this_obj_conv;
21081         this_obj_conv.inner = (void*)(this_obj & (~1));
21082         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21083         ReplyShortChannelIdsEnd_free(this_obj_conv);
21084 }
21085
21086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21087         LDKReplyShortChannelIdsEnd this_ptr_conv;
21088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21089         this_ptr_conv.is_owned = false;
21090         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21091         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
21092         return ret_arr;
21093 }
21094
21095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21096         LDKReplyShortChannelIdsEnd this_ptr_conv;
21097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21098         this_ptr_conv.is_owned = false;
21099         LDKThirtyTwoBytes val_ref;
21100         CHECK((*env)->GetArrayLength(env, val) == 32);
21101         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21102         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
21103 }
21104
21105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
21106         LDKReplyShortChannelIdsEnd this_ptr_conv;
21107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21108         this_ptr_conv.is_owned = false;
21109         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
21110         return ret_val;
21111 }
21112
21113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21114         LDKReplyShortChannelIdsEnd this_ptr_conv;
21115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21116         this_ptr_conv.is_owned = false;
21117         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
21118 }
21119
21120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
21121         LDKThirtyTwoBytes chain_hash_arg_ref;
21122         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
21123         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
21124         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
21125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21127         uint64_t ret_ref = (uint64_t)ret_var.inner;
21128         if (ret_var.is_owned) {
21129                 ret_ref |= 1;
21130         }
21131         return ret_ref;
21132 }
21133
21134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21135         LDKReplyShortChannelIdsEnd orig_conv;
21136         orig_conv.inner = (void*)(orig & (~1));
21137         orig_conv.is_owned = false;
21138         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
21139         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21140         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21141         uint64_t ret_ref = (uint64_t)ret_var.inner;
21142         if (ret_var.is_owned) {
21143                 ret_ref |= 1;
21144         }
21145         return ret_ref;
21146 }
21147
21148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21149         LDKGossipTimestampFilter this_obj_conv;
21150         this_obj_conv.inner = (void*)(this_obj & (~1));
21151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21152         GossipTimestampFilter_free(this_obj_conv);
21153 }
21154
21155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21156         LDKGossipTimestampFilter this_ptr_conv;
21157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21158         this_ptr_conv.is_owned = false;
21159         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
21161         return ret_arr;
21162 }
21163
21164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21165         LDKGossipTimestampFilter this_ptr_conv;
21166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21167         this_ptr_conv.is_owned = false;
21168         LDKThirtyTwoBytes val_ref;
21169         CHECK((*env)->GetArrayLength(env, val) == 32);
21170         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21171         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
21172 }
21173
21174 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
21175         LDKGossipTimestampFilter this_ptr_conv;
21176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21177         this_ptr_conv.is_owned = false;
21178         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
21179         return ret_val;
21180 }
21181
21182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21183         LDKGossipTimestampFilter this_ptr_conv;
21184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21185         this_ptr_conv.is_owned = false;
21186         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
21187 }
21188
21189 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
21190         LDKGossipTimestampFilter this_ptr_conv;
21191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21192         this_ptr_conv.is_owned = false;
21193         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
21194         return ret_val;
21195 }
21196
21197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21198         LDKGossipTimestampFilter this_ptr_conv;
21199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21200         this_ptr_conv.is_owned = false;
21201         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
21202 }
21203
21204 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) {
21205         LDKThirtyTwoBytes chain_hash_arg_ref;
21206         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
21207         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
21208         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
21209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21211         uint64_t ret_ref = (uint64_t)ret_var.inner;
21212         if (ret_var.is_owned) {
21213                 ret_ref |= 1;
21214         }
21215         return ret_ref;
21216 }
21217
21218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21219         LDKGossipTimestampFilter orig_conv;
21220         orig_conv.inner = (void*)(orig & (~1));
21221         orig_conv.is_owned = false;
21222         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
21223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21225         uint64_t ret_ref = (uint64_t)ret_var.inner;
21226         if (ret_var.is_owned) {
21227                 ret_ref |= 1;
21228         }
21229         return ret_ref;
21230 }
21231
21232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21233         if ((this_ptr & 1) != 0) return;
21234         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
21235         FREE((void*)this_ptr);
21236         ErrorAction_free(this_ptr_conv);
21237 }
21238
21239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21240         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
21241         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21242         *ret_copy = ErrorAction_clone(orig_conv);
21243         uint64_t ret_ref = (uint64_t)ret_copy;
21244         return ret_ref;
21245 }
21246
21247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
21248         LDKErrorMessage msg_conv;
21249         msg_conv.inner = (void*)(msg & (~1));
21250         msg_conv.is_owned = (msg & 1) || (msg == 0);
21251         msg_conv = ErrorMessage_clone(&msg_conv);
21252         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21253         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
21254         uint64_t ret_ref = (uint64_t)ret_copy;
21255         return ret_ref;
21256 }
21257
21258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
21259         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21260         *ret_copy = ErrorAction_ignore_error();
21261         uint64_t ret_ref = (uint64_t)ret_copy;
21262         return ret_ref;
21263 }
21264
21265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
21266         LDKLevel a_conv = LDKLevel_from_java(env, a);
21267         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21268         *ret_copy = ErrorAction_ignore_and_log(a_conv);
21269         uint64_t ret_ref = (uint64_t)ret_copy;
21270         return ret_ref;
21271 }
21272
21273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
21274         LDKErrorMessage msg_conv;
21275         msg_conv.inner = (void*)(msg & (~1));
21276         msg_conv.is_owned = (msg & 1) || (msg == 0);
21277         msg_conv = ErrorMessage_clone(&msg_conv);
21278         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21279         *ret_copy = ErrorAction_send_error_message(msg_conv);
21280         uint64_t ret_ref = (uint64_t)ret_copy;
21281         return ret_ref;
21282 }
21283
21284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21285         LDKLightningError this_obj_conv;
21286         this_obj_conv.inner = (void*)(this_obj & (~1));
21287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21288         LightningError_free(this_obj_conv);
21289 }
21290
21291 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
21292         LDKLightningError this_ptr_conv;
21293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21294         this_ptr_conv.is_owned = false;
21295         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
21296         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
21297         Str_free(ret_str);
21298         return ret_conv;
21299 }
21300
21301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
21302         LDKLightningError this_ptr_conv;
21303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21304         this_ptr_conv.is_owned = false;
21305         LDKStr val_conv = java_to_owned_str(env, val);
21306         LightningError_set_err(&this_ptr_conv, val_conv);
21307 }
21308
21309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
21310         LDKLightningError this_ptr_conv;
21311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21312         this_ptr_conv.is_owned = false;
21313         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21314         *ret_copy = LightningError_get_action(&this_ptr_conv);
21315         uint64_t ret_ref = (uint64_t)ret_copy;
21316         return ret_ref;
21317 }
21318
21319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21320         LDKLightningError this_ptr_conv;
21321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21322         this_ptr_conv.is_owned = false;
21323         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
21324         LightningError_set_action(&this_ptr_conv, val_conv);
21325 }
21326
21327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
21328         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
21329         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
21330         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
21331         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21332         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21333         uint64_t ret_ref = (uint64_t)ret_var.inner;
21334         if (ret_var.is_owned) {
21335                 ret_ref |= 1;
21336         }
21337         return ret_ref;
21338 }
21339
21340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21341         LDKLightningError orig_conv;
21342         orig_conv.inner = (void*)(orig & (~1));
21343         orig_conv.is_owned = false;
21344         LDKLightningError ret_var = LightningError_clone(&orig_conv);
21345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21347         uint64_t ret_ref = (uint64_t)ret_var.inner;
21348         if (ret_var.is_owned) {
21349                 ret_ref |= 1;
21350         }
21351         return ret_ref;
21352 }
21353
21354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21355         LDKCommitmentUpdate this_obj_conv;
21356         this_obj_conv.inner = (void*)(this_obj & (~1));
21357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21358         CommitmentUpdate_free(this_obj_conv);
21359 }
21360
21361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21362         LDKCommitmentUpdate this_ptr_conv;
21363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21364         this_ptr_conv.is_owned = false;
21365         LDKCVec_UpdateAddHTLCZ val_constr;
21366         val_constr.datalen = (*env)->GetArrayLength(env, val);
21367         if (val_constr.datalen > 0)
21368                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21369         else
21370                 val_constr.data = NULL;
21371         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21372         for (size_t p = 0; p < val_constr.datalen; p++) {
21373                 int64_t val_conv_15 = val_vals[p];
21374                 LDKUpdateAddHTLC val_conv_15_conv;
21375                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
21376                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
21377                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
21378                 val_constr.data[p] = val_conv_15_conv;
21379         }
21380         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21381         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
21382 }
21383
21384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21385         LDKCommitmentUpdate this_ptr_conv;
21386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21387         this_ptr_conv.is_owned = false;
21388         LDKCVec_UpdateFulfillHTLCZ val_constr;
21389         val_constr.datalen = (*env)->GetArrayLength(env, val);
21390         if (val_constr.datalen > 0)
21391                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21392         else
21393                 val_constr.data = NULL;
21394         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21395         for (size_t t = 0; t < val_constr.datalen; t++) {
21396                 int64_t val_conv_19 = val_vals[t];
21397                 LDKUpdateFulfillHTLC val_conv_19_conv;
21398                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
21399                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
21400                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
21401                 val_constr.data[t] = val_conv_19_conv;
21402         }
21403         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21404         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
21405 }
21406
21407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21408         LDKCommitmentUpdate this_ptr_conv;
21409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21410         this_ptr_conv.is_owned = false;
21411         LDKCVec_UpdateFailHTLCZ val_constr;
21412         val_constr.datalen = (*env)->GetArrayLength(env, val);
21413         if (val_constr.datalen > 0)
21414                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21415         else
21416                 val_constr.data = NULL;
21417         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21418         for (size_t q = 0; q < val_constr.datalen; q++) {
21419                 int64_t val_conv_16 = val_vals[q];
21420                 LDKUpdateFailHTLC val_conv_16_conv;
21421                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
21422                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
21423                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
21424                 val_constr.data[q] = val_conv_16_conv;
21425         }
21426         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21427         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
21428 }
21429
21430 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) {
21431         LDKCommitmentUpdate this_ptr_conv;
21432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21433         this_ptr_conv.is_owned = false;
21434         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
21435         val_constr.datalen = (*env)->GetArrayLength(env, val);
21436         if (val_constr.datalen > 0)
21437                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21438         else
21439                 val_constr.data = NULL;
21440         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21441         for (size_t z = 0; z < val_constr.datalen; z++) {
21442                 int64_t val_conv_25 = val_vals[z];
21443                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
21444                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
21445                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
21446                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
21447                 val_constr.data[z] = val_conv_25_conv;
21448         }
21449         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21450         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
21451 }
21452
21453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
21454         LDKCommitmentUpdate this_ptr_conv;
21455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21456         this_ptr_conv.is_owned = false;
21457         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
21458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21460         uint64_t ret_ref = (uint64_t)ret_var.inner;
21461         if (ret_var.is_owned) {
21462                 ret_ref |= 1;
21463         }
21464         return ret_ref;
21465 }
21466
21467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21468         LDKCommitmentUpdate this_ptr_conv;
21469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21470         this_ptr_conv.is_owned = false;
21471         LDKUpdateFee val_conv;
21472         val_conv.inner = (void*)(val & (~1));
21473         val_conv.is_owned = (val & 1) || (val == 0);
21474         val_conv = UpdateFee_clone(&val_conv);
21475         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
21476 }
21477
21478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
21479         LDKCommitmentUpdate this_ptr_conv;
21480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21481         this_ptr_conv.is_owned = false;
21482         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
21483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21485         uint64_t ret_ref = (uint64_t)ret_var.inner;
21486         if (ret_var.is_owned) {
21487                 ret_ref |= 1;
21488         }
21489         return ret_ref;
21490 }
21491
21492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21493         LDKCommitmentUpdate this_ptr_conv;
21494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21495         this_ptr_conv.is_owned = false;
21496         LDKCommitmentSigned val_conv;
21497         val_conv.inner = (void*)(val & (~1));
21498         val_conv.is_owned = (val & 1) || (val == 0);
21499         val_conv = CommitmentSigned_clone(&val_conv);
21500         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
21501 }
21502
21503 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) {
21504         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
21505         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
21506         if (update_add_htlcs_arg_constr.datalen > 0)
21507                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21508         else
21509                 update_add_htlcs_arg_constr.data = NULL;
21510         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
21511         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
21512                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
21513                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
21514                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
21515                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
21516                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
21517                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
21518         }
21519         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
21520         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
21521         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
21522         if (update_fulfill_htlcs_arg_constr.datalen > 0)
21523                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21524         else
21525                 update_fulfill_htlcs_arg_constr.data = NULL;
21526         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
21527         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
21528                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
21529                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
21530                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
21531                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
21532                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
21533                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
21534         }
21535         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
21536         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
21537         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
21538         if (update_fail_htlcs_arg_constr.datalen > 0)
21539                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21540         else
21541                 update_fail_htlcs_arg_constr.data = NULL;
21542         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
21543         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
21544                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
21545                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
21546                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
21547                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
21548                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
21549                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
21550         }
21551         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
21552         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
21553         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
21554         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
21555                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21556         else
21557                 update_fail_malformed_htlcs_arg_constr.data = NULL;
21558         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
21559         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
21560                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
21561                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
21562                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
21563                 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);
21564                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
21565                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
21566         }
21567         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
21568         LDKUpdateFee update_fee_arg_conv;
21569         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
21570         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
21571         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
21572         LDKCommitmentSigned commitment_signed_arg_conv;
21573         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
21574         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
21575         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
21576         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);
21577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21579         uint64_t ret_ref = (uint64_t)ret_var.inner;
21580         if (ret_var.is_owned) {
21581                 ret_ref |= 1;
21582         }
21583         return ret_ref;
21584 }
21585
21586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21587         LDKCommitmentUpdate orig_conv;
21588         orig_conv.inner = (void*)(orig & (~1));
21589         orig_conv.is_owned = false;
21590         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
21591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21593         uint64_t ret_ref = (uint64_t)ret_var.inner;
21594         if (ret_var.is_owned) {
21595                 ret_ref |= 1;
21596         }
21597         return ret_ref;
21598 }
21599
21600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21601         if ((this_ptr & 1) != 0) return;
21602         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
21603         FREE((void*)this_ptr);
21604         HTLCFailChannelUpdate_free(this_ptr_conv);
21605 }
21606
21607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21608         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
21609         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21610         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
21611         uint64_t ret_ref = (uint64_t)ret_copy;
21612         return ret_ref;
21613 }
21614
21615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
21616         LDKChannelUpdate msg_conv;
21617         msg_conv.inner = (void*)(msg & (~1));
21618         msg_conv.is_owned = (msg & 1) || (msg == 0);
21619         msg_conv = ChannelUpdate_clone(&msg_conv);
21620         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21621         *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv);
21622         uint64_t ret_ref = (uint64_t)ret_copy;
21623         return ret_ref;
21624 }
21625
21626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
21627         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21628         *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent);
21629         uint64_t ret_ref = (uint64_t)ret_copy;
21630         return ret_ref;
21631 }
21632
21633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
21634         LDKPublicKey node_id_ref;
21635         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21636         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21637         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21638         *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent);
21639         uint64_t ret_ref = (uint64_t)ret_copy;
21640         return ret_ref;
21641 }
21642
21643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21644         if ((this_ptr & 1) != 0) return;
21645         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
21646         FREE((void*)this_ptr);
21647         ChannelMessageHandler_free(this_ptr_conv);
21648 }
21649
21650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21651         if ((this_ptr & 1) != 0) return;
21652         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
21653         FREE((void*)this_ptr);
21654         RoutingMessageHandler_free(this_ptr_conv);
21655 }
21656
21657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21658         LDKAcceptChannel obj_conv;
21659         obj_conv.inner = (void*)(obj & (~1));
21660         obj_conv.is_owned = false;
21661         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
21662         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21663         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21664         CVec_u8Z_free(ret_var);
21665         return ret_arr;
21666 }
21667
21668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21669         LDKu8slice ser_ref;
21670         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21671         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21672         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21673         *ret_conv = AcceptChannel_read(ser_ref);
21674         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21675         return (uint64_t)ret_conv;
21676 }
21677
21678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
21679         LDKAnnouncementSignatures obj_conv;
21680         obj_conv.inner = (void*)(obj & (~1));
21681         obj_conv.is_owned = false;
21682         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
21683         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21684         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21685         CVec_u8Z_free(ret_var);
21686         return ret_arr;
21687 }
21688
21689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21690         LDKu8slice ser_ref;
21691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21693         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21694         *ret_conv = AnnouncementSignatures_read(ser_ref);
21695         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21696         return (uint64_t)ret_conv;
21697 }
21698
21699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
21700         LDKChannelReestablish obj_conv;
21701         obj_conv.inner = (void*)(obj & (~1));
21702         obj_conv.is_owned = false;
21703         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
21704         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21705         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21706         CVec_u8Z_free(ret_var);
21707         return ret_arr;
21708 }
21709
21710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21711         LDKu8slice ser_ref;
21712         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21713         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21714         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21715         *ret_conv = ChannelReestablish_read(ser_ref);
21716         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21717         return (uint64_t)ret_conv;
21718 }
21719
21720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21721         LDKClosingSigned obj_conv;
21722         obj_conv.inner = (void*)(obj & (~1));
21723         obj_conv.is_owned = false;
21724         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
21725         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21726         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21727         CVec_u8Z_free(ret_var);
21728         return ret_arr;
21729 }
21730
21731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21732         LDKu8slice ser_ref;
21733         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21734         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21735         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21736         *ret_conv = ClosingSigned_read(ser_ref);
21737         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21738         return (uint64_t)ret_conv;
21739 }
21740
21741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21742         LDKClosingSignedFeeRange obj_conv;
21743         obj_conv.inner = (void*)(obj & (~1));
21744         obj_conv.is_owned = false;
21745         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
21746         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21747         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21748         CVec_u8Z_free(ret_var);
21749         return ret_arr;
21750 }
21751
21752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21753         LDKu8slice ser_ref;
21754         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21755         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21756         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21757         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
21758         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21759         return (uint64_t)ret_conv;
21760 }
21761
21762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21763         LDKCommitmentSigned obj_conv;
21764         obj_conv.inner = (void*)(obj & (~1));
21765         obj_conv.is_owned = false;
21766         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
21767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21769         CVec_u8Z_free(ret_var);
21770         return ret_arr;
21771 }
21772
21773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21774         LDKu8slice ser_ref;
21775         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21776         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21777         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21778         *ret_conv = CommitmentSigned_read(ser_ref);
21779         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21780         return (uint64_t)ret_conv;
21781 }
21782
21783 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
21784         LDKFundingCreated obj_conv;
21785         obj_conv.inner = (void*)(obj & (~1));
21786         obj_conv.is_owned = false;
21787         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
21788         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21789         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21790         CVec_u8Z_free(ret_var);
21791         return ret_arr;
21792 }
21793
21794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21795         LDKu8slice ser_ref;
21796         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21797         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21798         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21799         *ret_conv = FundingCreated_read(ser_ref);
21800         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21801         return (uint64_t)ret_conv;
21802 }
21803
21804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21805         LDKFundingSigned obj_conv;
21806         obj_conv.inner = (void*)(obj & (~1));
21807         obj_conv.is_owned = false;
21808         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
21809         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21810         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21811         CVec_u8Z_free(ret_var);
21812         return ret_arr;
21813 }
21814
21815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21816         LDKu8slice ser_ref;
21817         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21818         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21819         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21820         *ret_conv = FundingSigned_read(ser_ref);
21821         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21822         return (uint64_t)ret_conv;
21823 }
21824
21825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
21826         LDKFundingLocked obj_conv;
21827         obj_conv.inner = (void*)(obj & (~1));
21828         obj_conv.is_owned = false;
21829         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
21830         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21831         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21832         CVec_u8Z_free(ret_var);
21833         return ret_arr;
21834 }
21835
21836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21837         LDKu8slice ser_ref;
21838         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21839         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21840         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21841         *ret_conv = FundingLocked_read(ser_ref);
21842         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21843         return (uint64_t)ret_conv;
21844 }
21845
21846 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
21847         LDKInit obj_conv;
21848         obj_conv.inner = (void*)(obj & (~1));
21849         obj_conv.is_owned = false;
21850         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
21851         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21852         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21853         CVec_u8Z_free(ret_var);
21854         return ret_arr;
21855 }
21856
21857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21858         LDKu8slice ser_ref;
21859         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21860         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21861         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21862         *ret_conv = Init_read(ser_ref);
21863         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21864         return (uint64_t)ret_conv;
21865 }
21866
21867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21868         LDKOpenChannel obj_conv;
21869         obj_conv.inner = (void*)(obj & (~1));
21870         obj_conv.is_owned = false;
21871         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
21872         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21873         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21874         CVec_u8Z_free(ret_var);
21875         return ret_arr;
21876 }
21877
21878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21879         LDKu8slice ser_ref;
21880         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21881         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21882         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21883         *ret_conv = OpenChannel_read(ser_ref);
21884         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21885         return (uint64_t)ret_conv;
21886 }
21887
21888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
21889         LDKRevokeAndACK obj_conv;
21890         obj_conv.inner = (void*)(obj & (~1));
21891         obj_conv.is_owned = false;
21892         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
21893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21895         CVec_u8Z_free(ret_var);
21896         return ret_arr;
21897 }
21898
21899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21900         LDKu8slice ser_ref;
21901         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21902         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21903         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21904         *ret_conv = RevokeAndACK_read(ser_ref);
21905         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21906         return (uint64_t)ret_conv;
21907 }
21908
21909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
21910         LDKShutdown obj_conv;
21911         obj_conv.inner = (void*)(obj & (~1));
21912         obj_conv.is_owned = false;
21913         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
21914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21916         CVec_u8Z_free(ret_var);
21917         return ret_arr;
21918 }
21919
21920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21921         LDKu8slice ser_ref;
21922         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21923         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21924         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21925         *ret_conv = Shutdown_read(ser_ref);
21926         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21927         return (uint64_t)ret_conv;
21928 }
21929
21930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21931         LDKUpdateFailHTLC obj_conv;
21932         obj_conv.inner = (void*)(obj & (~1));
21933         obj_conv.is_owned = false;
21934         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
21935         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21936         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21937         CVec_u8Z_free(ret_var);
21938         return ret_arr;
21939 }
21940
21941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21942         LDKu8slice ser_ref;
21943         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21944         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21945         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21946         *ret_conv = UpdateFailHTLC_read(ser_ref);
21947         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21948         return (uint64_t)ret_conv;
21949 }
21950
21951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21952         LDKUpdateFailMalformedHTLC obj_conv;
21953         obj_conv.inner = (void*)(obj & (~1));
21954         obj_conv.is_owned = false;
21955         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
21956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21958         CVec_u8Z_free(ret_var);
21959         return ret_arr;
21960 }
21961
21962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21963         LDKu8slice ser_ref;
21964         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21965         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21966         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21967         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21968         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21969         return (uint64_t)ret_conv;
21970 }
21971
21972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
21973         LDKUpdateFee obj_conv;
21974         obj_conv.inner = (void*)(obj & (~1));
21975         obj_conv.is_owned = false;
21976         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21977         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21978         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21979         CVec_u8Z_free(ret_var);
21980         return ret_arr;
21981 }
21982
21983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21984         LDKu8slice ser_ref;
21985         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21986         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21987         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21988         *ret_conv = UpdateFee_read(ser_ref);
21989         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21990         return (uint64_t)ret_conv;
21991 }
21992
21993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21994         LDKUpdateFulfillHTLC obj_conv;
21995         obj_conv.inner = (void*)(obj & (~1));
21996         obj_conv.is_owned = false;
21997         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21998         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21999         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22000         CVec_u8Z_free(ret_var);
22001         return ret_arr;
22002 }
22003
22004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22005         LDKu8slice ser_ref;
22006         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22007         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22008         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22009         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
22010         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22011         return (uint64_t)ret_conv;
22012 }
22013
22014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
22015         LDKUpdateAddHTLC obj_conv;
22016         obj_conv.inner = (void*)(obj & (~1));
22017         obj_conv.is_owned = false;
22018         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
22019         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22020         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22021         CVec_u8Z_free(ret_var);
22022         return ret_arr;
22023 }
22024
22025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22026         LDKu8slice ser_ref;
22027         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22028         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22029         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22030         *ret_conv = UpdateAddHTLC_read(ser_ref);
22031         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22032         return (uint64_t)ret_conv;
22033 }
22034
22035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
22036         LDKPing obj_conv;
22037         obj_conv.inner = (void*)(obj & (~1));
22038         obj_conv.is_owned = false;
22039         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
22040         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22041         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22042         CVec_u8Z_free(ret_var);
22043         return ret_arr;
22044 }
22045
22046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22047         LDKu8slice ser_ref;
22048         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22049         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22050         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22051         *ret_conv = Ping_read(ser_ref);
22052         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22053         return (uint64_t)ret_conv;
22054 }
22055
22056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
22057         LDKPong obj_conv;
22058         obj_conv.inner = (void*)(obj & (~1));
22059         obj_conv.is_owned = false;
22060         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
22061         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22062         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22063         CVec_u8Z_free(ret_var);
22064         return ret_arr;
22065 }
22066
22067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22068         LDKu8slice ser_ref;
22069         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22070         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22071         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22072         *ret_conv = Pong_read(ser_ref);
22073         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22074         return (uint64_t)ret_conv;
22075 }
22076
22077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22078         LDKUnsignedChannelAnnouncement obj_conv;
22079         obj_conv.inner = (void*)(obj & (~1));
22080         obj_conv.is_owned = false;
22081         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
22082         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22083         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22084         CVec_u8Z_free(ret_var);
22085         return ret_arr;
22086 }
22087
22088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22089         LDKu8slice ser_ref;
22090         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22091         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22092         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22093         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
22094         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22095         return (uint64_t)ret_conv;
22096 }
22097
22098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22099         LDKChannelAnnouncement obj_conv;
22100         obj_conv.inner = (void*)(obj & (~1));
22101         obj_conv.is_owned = false;
22102         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
22103         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22104         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22105         CVec_u8Z_free(ret_var);
22106         return ret_arr;
22107 }
22108
22109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22110         LDKu8slice ser_ref;
22111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22113         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22114         *ret_conv = ChannelAnnouncement_read(ser_ref);
22115         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22116         return (uint64_t)ret_conv;
22117 }
22118
22119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
22120         LDKUnsignedChannelUpdate obj_conv;
22121         obj_conv.inner = (void*)(obj & (~1));
22122         obj_conv.is_owned = false;
22123         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
22124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22126         CVec_u8Z_free(ret_var);
22127         return ret_arr;
22128 }
22129
22130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22131         LDKu8slice ser_ref;
22132         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22133         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22134         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22135         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
22136         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22137         return (uint64_t)ret_conv;
22138 }
22139
22140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
22141         LDKChannelUpdate obj_conv;
22142         obj_conv.inner = (void*)(obj & (~1));
22143         obj_conv.is_owned = false;
22144         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
22145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22147         CVec_u8Z_free(ret_var);
22148         return ret_arr;
22149 }
22150
22151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22152         LDKu8slice ser_ref;
22153         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22154         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22155         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22156         *ret_conv = ChannelUpdate_read(ser_ref);
22157         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22158         return (uint64_t)ret_conv;
22159 }
22160
22161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
22162         LDKErrorMessage obj_conv;
22163         obj_conv.inner = (void*)(obj & (~1));
22164         obj_conv.is_owned = false;
22165         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
22166         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22167         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22168         CVec_u8Z_free(ret_var);
22169         return ret_arr;
22170 }
22171
22172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22173         LDKu8slice ser_ref;
22174         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22175         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22176         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22177         *ret_conv = ErrorMessage_read(ser_ref);
22178         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22179         return (uint64_t)ret_conv;
22180 }
22181
22182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22183         LDKUnsignedNodeAnnouncement obj_conv;
22184         obj_conv.inner = (void*)(obj & (~1));
22185         obj_conv.is_owned = false;
22186         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
22187         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22188         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22189         CVec_u8Z_free(ret_var);
22190         return ret_arr;
22191 }
22192
22193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22194         LDKu8slice ser_ref;
22195         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22196         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22197         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22198         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
22199         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22200         return (uint64_t)ret_conv;
22201 }
22202
22203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22204         LDKNodeAnnouncement obj_conv;
22205         obj_conv.inner = (void*)(obj & (~1));
22206         obj_conv.is_owned = false;
22207         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
22208         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22209         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22210         CVec_u8Z_free(ret_var);
22211         return ret_arr;
22212 }
22213
22214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22215         LDKu8slice ser_ref;
22216         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22217         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22218         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22219         *ret_conv = NodeAnnouncement_read(ser_ref);
22220         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22221         return (uint64_t)ret_conv;
22222 }
22223
22224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22225         LDKu8slice ser_ref;
22226         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22227         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22228         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22229         *ret_conv = QueryShortChannelIds_read(ser_ref);
22230         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22231         return (uint64_t)ret_conv;
22232 }
22233
22234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
22235         LDKQueryShortChannelIds obj_conv;
22236         obj_conv.inner = (void*)(obj & (~1));
22237         obj_conv.is_owned = false;
22238         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
22239         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22240         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22241         CVec_u8Z_free(ret_var);
22242         return ret_arr;
22243 }
22244
22245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22246         LDKu8slice ser_ref;
22247         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22248         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22249         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22250         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
22251         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22252         return (uint64_t)ret_conv;
22253 }
22254
22255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
22256         LDKReplyShortChannelIdsEnd obj_conv;
22257         obj_conv.inner = (void*)(obj & (~1));
22258         obj_conv.is_owned = false;
22259         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
22260         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22261         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22262         CVec_u8Z_free(ret_var);
22263         return ret_arr;
22264 }
22265
22266 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
22267         LDKQueryChannelRange this_arg_conv;
22268         this_arg_conv.inner = (void*)(this_arg & (~1));
22269         this_arg_conv.is_owned = false;
22270         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
22271         return ret_val;
22272 }
22273
22274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22275         LDKu8slice ser_ref;
22276         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22277         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22278         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22279         *ret_conv = QueryChannelRange_read(ser_ref);
22280         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22281         return (uint64_t)ret_conv;
22282 }
22283
22284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
22285         LDKQueryChannelRange obj_conv;
22286         obj_conv.inner = (void*)(obj & (~1));
22287         obj_conv.is_owned = false;
22288         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
22289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22291         CVec_u8Z_free(ret_var);
22292         return ret_arr;
22293 }
22294
22295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22296         LDKu8slice ser_ref;
22297         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22298         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22299         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22300         *ret_conv = ReplyChannelRange_read(ser_ref);
22301         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22302         return (uint64_t)ret_conv;
22303 }
22304
22305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
22306         LDKReplyChannelRange obj_conv;
22307         obj_conv.inner = (void*)(obj & (~1));
22308         obj_conv.is_owned = false;
22309         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
22310         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22311         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22312         CVec_u8Z_free(ret_var);
22313         return ret_arr;
22314 }
22315
22316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22317         LDKu8slice ser_ref;
22318         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22319         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22320         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22321         *ret_conv = GossipTimestampFilter_read(ser_ref);
22322         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22323         return (uint64_t)ret_conv;
22324 }
22325
22326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
22327         LDKGossipTimestampFilter obj_conv;
22328         obj_conv.inner = (void*)(obj & (~1));
22329         obj_conv.is_owned = false;
22330         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
22331         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22332         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22333         CVec_u8Z_free(ret_var);
22334         return ret_arr;
22335 }
22336
22337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22338         LDKIgnoringMessageHandler this_obj_conv;
22339         this_obj_conv.inner = (void*)(this_obj & (~1));
22340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22341         IgnoringMessageHandler_free(this_obj_conv);
22342 }
22343
22344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
22345         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
22346         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22347         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22348         uint64_t ret_ref = (uint64_t)ret_var.inner;
22349         if (ret_var.is_owned) {
22350                 ret_ref |= 1;
22351         }
22352         return ret_ref;
22353 }
22354
22355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
22356         LDKIgnoringMessageHandler this_arg_conv;
22357         this_arg_conv.inner = (void*)(this_arg & (~1));
22358         this_arg_conv.is_owned = false;
22359         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22360         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
22361         return (uint64_t)ret;
22362 }
22363
22364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
22365         LDKIgnoringMessageHandler this_arg_conv;
22366         this_arg_conv.inner = (void*)(this_arg & (~1));
22367         this_arg_conv.is_owned = false;
22368         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
22369         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
22370         return (uint64_t)ret;
22371 }
22372
22373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22374         LDKErroringMessageHandler this_obj_conv;
22375         this_obj_conv.inner = (void*)(this_obj & (~1));
22376         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22377         ErroringMessageHandler_free(this_obj_conv);
22378 }
22379
22380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
22381         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
22382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22384         uint64_t ret_ref = (uint64_t)ret_var.inner;
22385         if (ret_var.is_owned) {
22386                 ret_ref |= 1;
22387         }
22388         return ret_ref;
22389 }
22390
22391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
22392         LDKErroringMessageHandler this_arg_conv;
22393         this_arg_conv.inner = (void*)(this_arg & (~1));
22394         this_arg_conv.is_owned = false;
22395         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22396         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
22397         return (uint64_t)ret;
22398 }
22399
22400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
22401         LDKErroringMessageHandler this_arg_conv;
22402         this_arg_conv.inner = (void*)(this_arg & (~1));
22403         this_arg_conv.is_owned = false;
22404         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
22405         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
22406         return (uint64_t)ret;
22407 }
22408
22409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22410         LDKMessageHandler this_obj_conv;
22411         this_obj_conv.inner = (void*)(this_obj & (~1));
22412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22413         MessageHandler_free(this_obj_conv);
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
22417         LDKMessageHandler this_ptr_conv;
22418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22419         this_ptr_conv.is_owned = false;
22420         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
22421         return ret_ret;
22422 }
22423
22424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22425         LDKMessageHandler this_ptr_conv;
22426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22427         this_ptr_conv.is_owned = false;
22428         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
22429         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
22430                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22431                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
22432         }
22433         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
22434 }
22435
22436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
22437         LDKMessageHandler this_ptr_conv;
22438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22439         this_ptr_conv.is_owned = false;
22440         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
22441         return ret_ret;
22442 }
22443
22444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22445         LDKMessageHandler this_ptr_conv;
22446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22447         this_ptr_conv.is_owned = false;
22448         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
22449         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
22450                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22451                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
22452         }
22453         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
22454 }
22455
22456 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) {
22457         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
22458         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
22459                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22460                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
22461         }
22462         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
22463         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
22464                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22465                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
22466         }
22467         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
22468         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22469         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22470         uint64_t ret_ref = (uint64_t)ret_var.inner;
22471         if (ret_var.is_owned) {
22472                 ret_ref |= 1;
22473         }
22474         return ret_ref;
22475 }
22476
22477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22478         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
22479         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
22480         *ret = SocketDescriptor_clone(orig_conv);
22481         return (uint64_t)ret;
22482 }
22483
22484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22485         if ((this_ptr & 1) != 0) return;
22486         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
22487         FREE((void*)this_ptr);
22488         SocketDescriptor_free(this_ptr_conv);
22489 }
22490
22491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22492         LDKPeerHandleError this_obj_conv;
22493         this_obj_conv.inner = (void*)(this_obj & (~1));
22494         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22495         PeerHandleError_free(this_obj_conv);
22496 }
22497
22498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
22499         LDKPeerHandleError this_ptr_conv;
22500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22501         this_ptr_conv.is_owned = false;
22502         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
22503         return ret_val;
22504 }
22505
22506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22507         LDKPeerHandleError this_ptr_conv;
22508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22509         this_ptr_conv.is_owned = false;
22510         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
22511 }
22512
22513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
22514         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
22515         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22516         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22517         uint64_t ret_ref = (uint64_t)ret_var.inner;
22518         if (ret_var.is_owned) {
22519                 ret_ref |= 1;
22520         }
22521         return ret_ref;
22522 }
22523
22524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22525         LDKPeerHandleError orig_conv;
22526         orig_conv.inner = (void*)(orig & (~1));
22527         orig_conv.is_owned = false;
22528         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
22529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22531         uint64_t ret_ref = (uint64_t)ret_var.inner;
22532         if (ret_var.is_owned) {
22533                 ret_ref |= 1;
22534         }
22535         return ret_ref;
22536 }
22537
22538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22539         LDKPeerManager this_obj_conv;
22540         this_obj_conv.inner = (void*)(this_obj & (~1));
22541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22542         PeerManager_free(this_obj_conv);
22543 }
22544
22545 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) {
22546         LDKMessageHandler message_handler_conv;
22547         message_handler_conv.inner = (void*)(message_handler & (~1));
22548         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
22549         // Warning: we need a move here but no clone is available for LDKMessageHandler
22550         LDKSecretKey our_node_secret_ref;
22551         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
22552         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
22553         unsigned char ephemeral_random_data_arr[32];
22554         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
22555         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
22556         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
22557         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22558         if (logger_conv.free == LDKLogger_JCalls_free) {
22559                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22560                 LDKLogger_JCalls_cloned(&logger_conv);
22561         }
22562         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
22563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22565         uint64_t ret_ref = (uint64_t)ret_var.inner;
22566         if (ret_var.is_owned) {
22567                 ret_ref |= 1;
22568         }
22569         return ret_ref;
22570 }
22571
22572 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
22573         LDKPeerManager this_arg_conv;
22574         this_arg_conv.inner = (void*)(this_arg & (~1));
22575         this_arg_conv.is_owned = false;
22576         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
22577         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22578         ;
22579         for (size_t i = 0; i < ret_var.datalen; i++) {
22580                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
22581                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
22582                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22583         }
22584         FREE(ret_var.data);
22585         return ret_arr;
22586 }
22587
22588 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) {
22589         LDKPeerManager this_arg_conv;
22590         this_arg_conv.inner = (void*)(this_arg & (~1));
22591         this_arg_conv.is_owned = false;
22592         LDKPublicKey their_node_id_ref;
22593         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
22594         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
22595         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22596         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22598                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22599         }
22600         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22601         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
22602         return (uint64_t)ret_conv;
22603 }
22604
22605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22606         LDKPeerManager this_arg_conv;
22607         this_arg_conv.inner = (void*)(this_arg & (~1));
22608         this_arg_conv.is_owned = false;
22609         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22610         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22612                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22613         }
22614         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22615         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
22616         return (uint64_t)ret_conv;
22617 }
22618
22619 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) {
22620         LDKPeerManager this_arg_conv;
22621         this_arg_conv.inner = (void*)(this_arg & (~1));
22622         this_arg_conv.is_owned = false;
22623         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22624         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22625         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
22626         return (uint64_t)ret_conv;
22627 }
22628
22629 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) {
22630         LDKPeerManager this_arg_conv;
22631         this_arg_conv.inner = (void*)(this_arg & (~1));
22632         this_arg_conv.is_owned = false;
22633         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
22634         LDKu8slice data_ref;
22635         data_ref.datalen = (*env)->GetArrayLength(env, data);
22636         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
22637         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22638         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
22639         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
22640         return (uint64_t)ret_conv;
22641 }
22642
22643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22644         LDKPeerManager this_arg_conv;
22645         this_arg_conv.inner = (void*)(this_arg & (~1));
22646         this_arg_conv.is_owned = false;
22647         PeerManager_process_events(&this_arg_conv);
22648 }
22649
22650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22651         LDKPeerManager this_arg_conv;
22652         this_arg_conv.inner = (void*)(this_arg & (~1));
22653         this_arg_conv.is_owned = false;
22654         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22655         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
22656 }
22657
22658 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) {
22659         LDKPeerManager this_arg_conv;
22660         this_arg_conv.inner = (void*)(this_arg & (~1));
22661         this_arg_conv.is_owned = false;
22662         LDKPublicKey node_id_ref;
22663         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22664         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22665         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
22666 }
22667
22668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
22669         LDKPeerManager this_arg_conv;
22670         this_arg_conv.inner = (void*)(this_arg & (~1));
22671         this_arg_conv.is_owned = false;
22672         PeerManager_timer_tick_occurred(&this_arg_conv);
22673 }
22674
22675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
22676         unsigned char commitment_seed_arr[32];
22677         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
22678         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
22679         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
22680         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22681         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
22682         return ret_arr;
22683 }
22684
22685 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) {
22686         LDKPublicKey per_commitment_point_ref;
22687         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22688         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22689         unsigned char base_secret_arr[32];
22690         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
22691         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
22692         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
22693         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22694         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
22695         return (uint64_t)ret_conv;
22696 }
22697
22698 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) {
22699         LDKPublicKey per_commitment_point_ref;
22700         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22701         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22702         LDKPublicKey base_point_ref;
22703         CHECK((*env)->GetArrayLength(env, base_point) == 33);
22704         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
22705         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22706         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
22707         return (uint64_t)ret_conv;
22708 }
22709
22710 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) {
22711         unsigned char per_commitment_secret_arr[32];
22712         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
22713         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
22714         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
22715         unsigned char countersignatory_revocation_base_secret_arr[32];
22716         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
22717         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
22718         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
22719         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22720         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
22721         return (uint64_t)ret_conv;
22722 }
22723
22724 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) {
22725         LDKPublicKey per_commitment_point_ref;
22726         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22727         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22728         LDKPublicKey countersignatory_revocation_base_point_ref;
22729         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
22730         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
22731         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22732         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
22733         return (uint64_t)ret_conv;
22734 }
22735
22736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22737         LDKTxCreationKeys this_obj_conv;
22738         this_obj_conv.inner = (void*)(this_obj & (~1));
22739         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22740         TxCreationKeys_free(this_obj_conv);
22741 }
22742
22743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22744         LDKTxCreationKeys this_ptr_conv;
22745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22746         this_ptr_conv.is_owned = false;
22747         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
22749         return ret_arr;
22750 }
22751
22752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22753         LDKTxCreationKeys this_ptr_conv;
22754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22755         this_ptr_conv.is_owned = false;
22756         LDKPublicKey val_ref;
22757         CHECK((*env)->GetArrayLength(env, val) == 33);
22758         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22759         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
22760 }
22761
22762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22763         LDKTxCreationKeys this_ptr_conv;
22764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22765         this_ptr_conv.is_owned = false;
22766         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22767         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
22768         return ret_arr;
22769 }
22770
22771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22772         LDKTxCreationKeys this_ptr_conv;
22773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22774         this_ptr_conv.is_owned = false;
22775         LDKPublicKey val_ref;
22776         CHECK((*env)->GetArrayLength(env, val) == 33);
22777         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22778         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
22779 }
22780
22781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22782         LDKTxCreationKeys this_ptr_conv;
22783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22784         this_ptr_conv.is_owned = false;
22785         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
22787         return ret_arr;
22788 }
22789
22790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22791         LDKTxCreationKeys this_ptr_conv;
22792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22793         this_ptr_conv.is_owned = false;
22794         LDKPublicKey val_ref;
22795         CHECK((*env)->GetArrayLength(env, val) == 33);
22796         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22797         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
22798 }
22799
22800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22801         LDKTxCreationKeys this_ptr_conv;
22802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22803         this_ptr_conv.is_owned = false;
22804         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22805         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
22806         return ret_arr;
22807 }
22808
22809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22810         LDKTxCreationKeys this_ptr_conv;
22811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22812         this_ptr_conv.is_owned = false;
22813         LDKPublicKey val_ref;
22814         CHECK((*env)->GetArrayLength(env, val) == 33);
22815         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22816         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
22817 }
22818
22819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22820         LDKTxCreationKeys this_ptr_conv;
22821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22822         this_ptr_conv.is_owned = false;
22823         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
22825         return ret_arr;
22826 }
22827
22828 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) {
22829         LDKTxCreationKeys this_ptr_conv;
22830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22831         this_ptr_conv.is_owned = false;
22832         LDKPublicKey val_ref;
22833         CHECK((*env)->GetArrayLength(env, val) == 33);
22834         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22835         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
22836 }
22837
22838 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) {
22839         LDKPublicKey per_commitment_point_arg_ref;
22840         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
22841         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
22842         LDKPublicKey revocation_key_arg_ref;
22843         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
22844         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
22845         LDKPublicKey broadcaster_htlc_key_arg_ref;
22846         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
22847         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
22848         LDKPublicKey countersignatory_htlc_key_arg_ref;
22849         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
22850         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
22851         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
22852         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
22853         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
22854         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);
22855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22857         uint64_t ret_ref = (uint64_t)ret_var.inner;
22858         if (ret_var.is_owned) {
22859                 ret_ref |= 1;
22860         }
22861         return ret_ref;
22862 }
22863
22864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22865         LDKTxCreationKeys orig_conv;
22866         orig_conv.inner = (void*)(orig & (~1));
22867         orig_conv.is_owned = false;
22868         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
22869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22871         uint64_t ret_ref = (uint64_t)ret_var.inner;
22872         if (ret_var.is_owned) {
22873                 ret_ref |= 1;
22874         }
22875         return ret_ref;
22876 }
22877
22878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22879         LDKTxCreationKeys obj_conv;
22880         obj_conv.inner = (void*)(obj & (~1));
22881         obj_conv.is_owned = false;
22882         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
22883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22885         CVec_u8Z_free(ret_var);
22886         return ret_arr;
22887 }
22888
22889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22890         LDKu8slice ser_ref;
22891         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22892         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22893         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
22894         *ret_conv = TxCreationKeys_read(ser_ref);
22895         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22896         return (uint64_t)ret_conv;
22897 }
22898
22899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22900         LDKChannelPublicKeys this_obj_conv;
22901         this_obj_conv.inner = (void*)(this_obj & (~1));
22902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22903         ChannelPublicKeys_free(this_obj_conv);
22904 }
22905
22906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22907         LDKChannelPublicKeys this_ptr_conv;
22908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22909         this_ptr_conv.is_owned = false;
22910         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
22912         return ret_arr;
22913 }
22914
22915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22916         LDKChannelPublicKeys this_ptr_conv;
22917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22918         this_ptr_conv.is_owned = false;
22919         LDKPublicKey val_ref;
22920         CHECK((*env)->GetArrayLength(env, val) == 33);
22921         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22922         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
22923 }
22924
22925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22926         LDKChannelPublicKeys this_ptr_conv;
22927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22928         this_ptr_conv.is_owned = false;
22929         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
22931         return ret_arr;
22932 }
22933
22934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22935         LDKChannelPublicKeys this_ptr_conv;
22936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22937         this_ptr_conv.is_owned = false;
22938         LDKPublicKey val_ref;
22939         CHECK((*env)->GetArrayLength(env, val) == 33);
22940         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22941         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
22942 }
22943
22944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22945         LDKChannelPublicKeys this_ptr_conv;
22946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22947         this_ptr_conv.is_owned = false;
22948         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
22950         return ret_arr;
22951 }
22952
22953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22954         LDKChannelPublicKeys this_ptr_conv;
22955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22956         this_ptr_conv.is_owned = false;
22957         LDKPublicKey val_ref;
22958         CHECK((*env)->GetArrayLength(env, val) == 33);
22959         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22960         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
22961 }
22962
22963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22964         LDKChannelPublicKeys this_ptr_conv;
22965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22966         this_ptr_conv.is_owned = false;
22967         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22969         return ret_arr;
22970 }
22971
22972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22973         LDKChannelPublicKeys this_ptr_conv;
22974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22975         this_ptr_conv.is_owned = false;
22976         LDKPublicKey val_ref;
22977         CHECK((*env)->GetArrayLength(env, val) == 33);
22978         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22979         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22980 }
22981
22982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22983         LDKChannelPublicKeys this_ptr_conv;
22984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22985         this_ptr_conv.is_owned = false;
22986         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22988         return ret_arr;
22989 }
22990
22991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22992         LDKChannelPublicKeys this_ptr_conv;
22993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22994         this_ptr_conv.is_owned = false;
22995         LDKPublicKey val_ref;
22996         CHECK((*env)->GetArrayLength(env, val) == 33);
22997         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22998         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22999 }
23000
23001 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) {
23002         LDKPublicKey funding_pubkey_arg_ref;
23003         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
23004         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
23005         LDKPublicKey revocation_basepoint_arg_ref;
23006         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
23007         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
23008         LDKPublicKey payment_point_arg_ref;
23009         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
23010         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
23011         LDKPublicKey delayed_payment_basepoint_arg_ref;
23012         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
23013         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
23014         LDKPublicKey htlc_basepoint_arg_ref;
23015         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
23016         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
23017         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);
23018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23020         uint64_t ret_ref = (uint64_t)ret_var.inner;
23021         if (ret_var.is_owned) {
23022                 ret_ref |= 1;
23023         }
23024         return ret_ref;
23025 }
23026
23027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23028         LDKChannelPublicKeys orig_conv;
23029         orig_conv.inner = (void*)(orig & (~1));
23030         orig_conv.is_owned = false;
23031         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
23032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23034         uint64_t ret_ref = (uint64_t)ret_var.inner;
23035         if (ret_var.is_owned) {
23036                 ret_ref |= 1;
23037         }
23038         return ret_ref;
23039 }
23040
23041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
23042         LDKChannelPublicKeys obj_conv;
23043         obj_conv.inner = (void*)(obj & (~1));
23044         obj_conv.is_owned = false;
23045         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
23046         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23047         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23048         CVec_u8Z_free(ret_var);
23049         return ret_arr;
23050 }
23051
23052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23053         LDKu8slice ser_ref;
23054         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23055         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23056         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
23057         *ret_conv = ChannelPublicKeys_read(ser_ref);
23058         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23059         return (uint64_t)ret_conv;
23060 }
23061
23062 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) {
23063         LDKPublicKey per_commitment_point_ref;
23064         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
23065         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
23066         LDKPublicKey broadcaster_delayed_payment_base_ref;
23067         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
23068         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
23069         LDKPublicKey broadcaster_htlc_base_ref;
23070         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
23071         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
23072         LDKPublicKey countersignatory_revocation_base_ref;
23073         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
23074         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
23075         LDKPublicKey countersignatory_htlc_base_ref;
23076         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
23077         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
23078         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
23079         *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);
23080         return (uint64_t)ret_conv;
23081 }
23082
23083 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) {
23084         LDKPublicKey per_commitment_point_ref;
23085         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
23086         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
23087         LDKChannelPublicKeys broadcaster_keys_conv;
23088         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23089         broadcaster_keys_conv.is_owned = false;
23090         LDKChannelPublicKeys countersignatory_keys_conv;
23091         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23092         countersignatory_keys_conv.is_owned = false;
23093         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
23094         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
23095         return (uint64_t)ret_conv;
23096 }
23097
23098 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) {
23099         LDKPublicKey revocation_key_ref;
23100         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
23101         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
23102         LDKPublicKey broadcaster_delayed_payment_key_ref;
23103         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
23104         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
23105         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
23106         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23107         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23108         CVec_u8Z_free(ret_var);
23109         return ret_arr;
23110 }
23111
23112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23113         LDKHTLCOutputInCommitment this_obj_conv;
23114         this_obj_conv.inner = (void*)(this_obj & (~1));
23115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23116         HTLCOutputInCommitment_free(this_obj_conv);
23117 }
23118
23119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
23120         LDKHTLCOutputInCommitment this_ptr_conv;
23121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23122         this_ptr_conv.is_owned = false;
23123         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
23124         return ret_val;
23125 }
23126
23127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23128         LDKHTLCOutputInCommitment this_ptr_conv;
23129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23130         this_ptr_conv.is_owned = false;
23131         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
23132 }
23133
23134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23135         LDKHTLCOutputInCommitment this_ptr_conv;
23136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23137         this_ptr_conv.is_owned = false;
23138         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
23139         return ret_val;
23140 }
23141
23142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23143         LDKHTLCOutputInCommitment this_ptr_conv;
23144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23145         this_ptr_conv.is_owned = false;
23146         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
23147 }
23148
23149 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
23150         LDKHTLCOutputInCommitment this_ptr_conv;
23151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23152         this_ptr_conv.is_owned = false;
23153         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
23154         return ret_val;
23155 }
23156
23157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23158         LDKHTLCOutputInCommitment this_ptr_conv;
23159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23160         this_ptr_conv.is_owned = false;
23161         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
23162 }
23163
23164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23165         LDKHTLCOutputInCommitment this_ptr_conv;
23166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23167         this_ptr_conv.is_owned = false;
23168         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23169         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
23170         return ret_arr;
23171 }
23172
23173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23174         LDKHTLCOutputInCommitment this_ptr_conv;
23175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23176         this_ptr_conv.is_owned = false;
23177         LDKThirtyTwoBytes val_ref;
23178         CHECK((*env)->GetArrayLength(env, val) == 32);
23179         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23180         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
23181 }
23182
23183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
23184         LDKHTLCOutputInCommitment this_ptr_conv;
23185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23186         this_ptr_conv.is_owned = false;
23187         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
23188         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
23189         uint64_t ret_ref = (uint64_t)ret_copy;
23190         return ret_ref;
23191 }
23192
23193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23194         LDKHTLCOutputInCommitment this_ptr_conv;
23195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23196         this_ptr_conv.is_owned = false;
23197         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
23198         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
23199 }
23200
23201 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) {
23202         LDKThirtyTwoBytes payment_hash_arg_ref;
23203         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
23204         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
23205         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
23206         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
23207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23209         uint64_t ret_ref = (uint64_t)ret_var.inner;
23210         if (ret_var.is_owned) {
23211                 ret_ref |= 1;
23212         }
23213         return ret_ref;
23214 }
23215
23216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23217         LDKHTLCOutputInCommitment orig_conv;
23218         orig_conv.inner = (void*)(orig & (~1));
23219         orig_conv.is_owned = false;
23220         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
23221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23223         uint64_t ret_ref = (uint64_t)ret_var.inner;
23224         if (ret_var.is_owned) {
23225                 ret_ref |= 1;
23226         }
23227         return ret_ref;
23228 }
23229
23230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
23231         LDKHTLCOutputInCommitment obj_conv;
23232         obj_conv.inner = (void*)(obj & (~1));
23233         obj_conv.is_owned = false;
23234         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
23235         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23236         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23237         CVec_u8Z_free(ret_var);
23238         return ret_arr;
23239 }
23240
23241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23242         LDKu8slice ser_ref;
23243         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23244         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23245         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
23246         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
23247         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23248         return (uint64_t)ret_conv;
23249 }
23250
23251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
23252         LDKHTLCOutputInCommitment htlc_conv;
23253         htlc_conv.inner = (void*)(htlc & (~1));
23254         htlc_conv.is_owned = false;
23255         LDKTxCreationKeys keys_conv;
23256         keys_conv.inner = (void*)(keys & (~1));
23257         keys_conv.is_owned = false;
23258         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
23259         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23260         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23261         CVec_u8Z_free(ret_var);
23262         return ret_arr;
23263 }
23264
23265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
23266         LDKPublicKey broadcaster_ref;
23267         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
23268         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
23269         LDKPublicKey countersignatory_ref;
23270         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
23271         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
23272         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
23273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23275         CVec_u8Z_free(ret_var);
23276         return ret_arr;
23277 }
23278
23279 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) {
23280         unsigned char commitment_txid_arr[32];
23281         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
23282         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
23283         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
23284         LDKHTLCOutputInCommitment htlc_conv;
23285         htlc_conv.inner = (void*)(htlc & (~1));
23286         htlc_conv.is_owned = false;
23287         LDKPublicKey broadcaster_delayed_payment_key_ref;
23288         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
23289         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
23290         LDKPublicKey revocation_key_ref;
23291         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
23292         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
23293         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
23294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23296         Transaction_free(ret_var);
23297         return ret_arr;
23298 }
23299
23300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23301         LDKChannelTransactionParameters this_obj_conv;
23302         this_obj_conv.inner = (void*)(this_obj & (~1));
23303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23304         ChannelTransactionParameters_free(this_obj_conv);
23305 }
23306
23307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
23308         LDKChannelTransactionParameters this_ptr_conv;
23309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23310         this_ptr_conv.is_owned = false;
23311         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
23312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23314         uint64_t ret_ref = (uint64_t)ret_var.inner;
23315         if (ret_var.is_owned) {
23316                 ret_ref |= 1;
23317         }
23318         return ret_ref;
23319 }
23320
23321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23322         LDKChannelTransactionParameters this_ptr_conv;
23323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23324         this_ptr_conv.is_owned = false;
23325         LDKChannelPublicKeys val_conv;
23326         val_conv.inner = (void*)(val & (~1));
23327         val_conv.is_owned = (val & 1) || (val == 0);
23328         val_conv = ChannelPublicKeys_clone(&val_conv);
23329         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
23330 }
23331
23332 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23333         LDKChannelTransactionParameters this_ptr_conv;
23334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23335         this_ptr_conv.is_owned = false;
23336         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
23337         return ret_val;
23338 }
23339
23340 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) {
23341         LDKChannelTransactionParameters this_ptr_conv;
23342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23343         this_ptr_conv.is_owned = false;
23344         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
23345 }
23346
23347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
23348         LDKChannelTransactionParameters this_ptr_conv;
23349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23350         this_ptr_conv.is_owned = false;
23351         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
23352         return ret_val;
23353 }
23354
23355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23356         LDKChannelTransactionParameters this_ptr_conv;
23357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23358         this_ptr_conv.is_owned = false;
23359         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
23360 }
23361
23362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
23363         LDKChannelTransactionParameters this_ptr_conv;
23364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23365         this_ptr_conv.is_owned = false;
23366         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
23367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23369         uint64_t ret_ref = (uint64_t)ret_var.inner;
23370         if (ret_var.is_owned) {
23371                 ret_ref |= 1;
23372         }
23373         return ret_ref;
23374 }
23375
23376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23377         LDKChannelTransactionParameters this_ptr_conv;
23378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23379         this_ptr_conv.is_owned = false;
23380         LDKCounterpartyChannelTransactionParameters val_conv;
23381         val_conv.inner = (void*)(val & (~1));
23382         val_conv.is_owned = (val & 1) || (val == 0);
23383         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
23384         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
23385 }
23386
23387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
23388         LDKChannelTransactionParameters this_ptr_conv;
23389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23390         this_ptr_conv.is_owned = false;
23391         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
23392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23394         uint64_t ret_ref = (uint64_t)ret_var.inner;
23395         if (ret_var.is_owned) {
23396                 ret_ref |= 1;
23397         }
23398         return ret_ref;
23399 }
23400
23401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23402         LDKChannelTransactionParameters this_ptr_conv;
23403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23404         this_ptr_conv.is_owned = false;
23405         LDKOutPoint val_conv;
23406         val_conv.inner = (void*)(val & (~1));
23407         val_conv.is_owned = (val & 1) || (val == 0);
23408         val_conv = OutPoint_clone(&val_conv);
23409         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
23410 }
23411
23412 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) {
23413         LDKChannelPublicKeys holder_pubkeys_arg_conv;
23414         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
23415         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
23416         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
23417         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
23418         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
23419         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
23420         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
23421         LDKOutPoint funding_outpoint_arg_conv;
23422         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
23423         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
23424         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
23425         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);
23426         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23427         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23428         uint64_t ret_ref = (uint64_t)ret_var.inner;
23429         if (ret_var.is_owned) {
23430                 ret_ref |= 1;
23431         }
23432         return ret_ref;
23433 }
23434
23435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23436         LDKChannelTransactionParameters orig_conv;
23437         orig_conv.inner = (void*)(orig & (~1));
23438         orig_conv.is_owned = false;
23439         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
23440         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23441         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23442         uint64_t ret_ref = (uint64_t)ret_var.inner;
23443         if (ret_var.is_owned) {
23444                 ret_ref |= 1;
23445         }
23446         return ret_ref;
23447 }
23448
23449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23450         LDKCounterpartyChannelTransactionParameters this_obj_conv;
23451         this_obj_conv.inner = (void*)(this_obj & (~1));
23452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23453         CounterpartyChannelTransactionParameters_free(this_obj_conv);
23454 }
23455
23456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
23457         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23459         this_ptr_conv.is_owned = false;
23460         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
23461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23463         uint64_t ret_ref = (uint64_t)ret_var.inner;
23464         if (ret_var.is_owned) {
23465                 ret_ref |= 1;
23466         }
23467         return ret_ref;
23468 }
23469
23470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23471         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23473         this_ptr_conv.is_owned = false;
23474         LDKChannelPublicKeys val_conv;
23475         val_conv.inner = (void*)(val & (~1));
23476         val_conv.is_owned = (val & 1) || (val == 0);
23477         val_conv = ChannelPublicKeys_clone(&val_conv);
23478         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
23479 }
23480
23481 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23482         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23484         this_ptr_conv.is_owned = false;
23485         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
23486         return ret_val;
23487 }
23488
23489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23490         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23492         this_ptr_conv.is_owned = false;
23493         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
23494 }
23495
23496 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) {
23497         LDKChannelPublicKeys pubkeys_arg_conv;
23498         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
23499         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
23500         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
23501         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
23502         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23503         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23504         uint64_t ret_ref = (uint64_t)ret_var.inner;
23505         if (ret_var.is_owned) {
23506                 ret_ref |= 1;
23507         }
23508         return ret_ref;
23509 }
23510
23511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23512         LDKCounterpartyChannelTransactionParameters orig_conv;
23513         orig_conv.inner = (void*)(orig & (~1));
23514         orig_conv.is_owned = false;
23515         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
23516         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23517         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23518         uint64_t ret_ref = (uint64_t)ret_var.inner;
23519         if (ret_var.is_owned) {
23520                 ret_ref |= 1;
23521         }
23522         return ret_ref;
23523 }
23524
23525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
23526         LDKChannelTransactionParameters this_arg_conv;
23527         this_arg_conv.inner = (void*)(this_arg & (~1));
23528         this_arg_conv.is_owned = false;
23529         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
23530         return ret_val;
23531 }
23532
23533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23534         LDKChannelTransactionParameters this_arg_conv;
23535         this_arg_conv.inner = (void*)(this_arg & (~1));
23536         this_arg_conv.is_owned = false;
23537         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
23538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23540         uint64_t ret_ref = (uint64_t)ret_var.inner;
23541         if (ret_var.is_owned) {
23542                 ret_ref |= 1;
23543         }
23544         return ret_ref;
23545 }
23546
23547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23548         LDKChannelTransactionParameters this_arg_conv;
23549         this_arg_conv.inner = (void*)(this_arg & (~1));
23550         this_arg_conv.is_owned = false;
23551         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
23552         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23553         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23554         uint64_t ret_ref = (uint64_t)ret_var.inner;
23555         if (ret_var.is_owned) {
23556                 ret_ref |= 1;
23557         }
23558         return ret_ref;
23559 }
23560
23561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23562         LDKCounterpartyChannelTransactionParameters obj_conv;
23563         obj_conv.inner = (void*)(obj & (~1));
23564         obj_conv.is_owned = false;
23565         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
23566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23568         CVec_u8Z_free(ret_var);
23569         return ret_arr;
23570 }
23571
23572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23573         LDKu8slice ser_ref;
23574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23576         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
23577         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
23578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23579         return (uint64_t)ret_conv;
23580 }
23581
23582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23583         LDKChannelTransactionParameters obj_conv;
23584         obj_conv.inner = (void*)(obj & (~1));
23585         obj_conv.is_owned = false;
23586         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
23587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23589         CVec_u8Z_free(ret_var);
23590         return ret_arr;
23591 }
23592
23593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23594         LDKu8slice ser_ref;
23595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23597         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
23598         *ret_conv = ChannelTransactionParameters_read(ser_ref);
23599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23600         return (uint64_t)ret_conv;
23601 }
23602
23603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23604         LDKDirectedChannelTransactionParameters this_obj_conv;
23605         this_obj_conv.inner = (void*)(this_obj & (~1));
23606         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23607         DirectedChannelTransactionParameters_free(this_obj_conv);
23608 }
23609
23610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23611         LDKDirectedChannelTransactionParameters this_arg_conv;
23612         this_arg_conv.inner = (void*)(this_arg & (~1));
23613         this_arg_conv.is_owned = false;
23614         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
23615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23617         uint64_t ret_ref = (uint64_t)ret_var.inner;
23618         if (ret_var.is_owned) {
23619                 ret_ref |= 1;
23620         }
23621         return ret_ref;
23622 }
23623
23624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23625         LDKDirectedChannelTransactionParameters this_arg_conv;
23626         this_arg_conv.inner = (void*)(this_arg & (~1));
23627         this_arg_conv.is_owned = false;
23628         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
23629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23631         uint64_t ret_ref = (uint64_t)ret_var.inner;
23632         if (ret_var.is_owned) {
23633                 ret_ref |= 1;
23634         }
23635         return ret_ref;
23636 }
23637
23638 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23639         LDKDirectedChannelTransactionParameters this_arg_conv;
23640         this_arg_conv.inner = (void*)(this_arg & (~1));
23641         this_arg_conv.is_owned = false;
23642         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
23643         return ret_val;
23644 }
23645
23646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
23647         LDKDirectedChannelTransactionParameters this_arg_conv;
23648         this_arg_conv.inner = (void*)(this_arg & (~1));
23649         this_arg_conv.is_owned = false;
23650         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
23651         return ret_val;
23652 }
23653
23654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
23655         LDKDirectedChannelTransactionParameters this_arg_conv;
23656         this_arg_conv.inner = (void*)(this_arg & (~1));
23657         this_arg_conv.is_owned = false;
23658         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
23659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23661         uint64_t ret_ref = (uint64_t)ret_var.inner;
23662         if (ret_var.is_owned) {
23663                 ret_ref |= 1;
23664         }
23665         return ret_ref;
23666 }
23667
23668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23669         LDKHolderCommitmentTransaction this_obj_conv;
23670         this_obj_conv.inner = (void*)(this_obj & (~1));
23671         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23672         HolderCommitmentTransaction_free(this_obj_conv);
23673 }
23674
23675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
23676         LDKHolderCommitmentTransaction this_ptr_conv;
23677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23678         this_ptr_conv.is_owned = false;
23679         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23680         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
23681         return ret_arr;
23682 }
23683
23684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23685         LDKHolderCommitmentTransaction this_ptr_conv;
23686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23687         this_ptr_conv.is_owned = false;
23688         LDKSignature val_ref;
23689         CHECK((*env)->GetArrayLength(env, val) == 64);
23690         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23691         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
23692 }
23693
23694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23695         LDKHolderCommitmentTransaction this_ptr_conv;
23696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23697         this_ptr_conv.is_owned = false;
23698         LDKCVec_SignatureZ val_constr;
23699         val_constr.datalen = (*env)->GetArrayLength(env, val);
23700         if (val_constr.datalen > 0)
23701                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23702         else
23703                 val_constr.data = NULL;
23704         for (size_t i = 0; i < val_constr.datalen; i++) {
23705                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
23706                 LDKSignature val_conv_8_ref;
23707                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
23708                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
23709                 val_constr.data[i] = val_conv_8_ref;
23710         }
23711         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
23712 }
23713
23714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23715         LDKHolderCommitmentTransaction orig_conv;
23716         orig_conv.inner = (void*)(orig & (~1));
23717         orig_conv.is_owned = false;
23718         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
23719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23721         uint64_t ret_ref = (uint64_t)ret_var.inner;
23722         if (ret_var.is_owned) {
23723                 ret_ref |= 1;
23724         }
23725         return ret_ref;
23726 }
23727
23728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23729         LDKHolderCommitmentTransaction obj_conv;
23730         obj_conv.inner = (void*)(obj & (~1));
23731         obj_conv.is_owned = false;
23732         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
23733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23735         CVec_u8Z_free(ret_var);
23736         return ret_arr;
23737 }
23738
23739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23740         LDKu8slice ser_ref;
23741         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23742         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23743         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
23744         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
23745         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23746         return (uint64_t)ret_conv;
23747 }
23748
23749 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) {
23750         LDKCommitmentTransaction commitment_tx_conv;
23751         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
23752         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
23753         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
23754         LDKSignature counterparty_sig_ref;
23755         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
23756         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
23757         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
23758         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
23759         if (counterparty_htlc_sigs_constr.datalen > 0)
23760                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23761         else
23762                 counterparty_htlc_sigs_constr.data = NULL;
23763         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
23764                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
23765                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
23766                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
23767                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
23768                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
23769         }
23770         LDKPublicKey holder_funding_key_ref;
23771         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
23772         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
23773         LDKPublicKey counterparty_funding_key_ref;
23774         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
23775         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
23776         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
23777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23779         uint64_t ret_ref = (uint64_t)ret_var.inner;
23780         if (ret_var.is_owned) {
23781                 ret_ref |= 1;
23782         }
23783         return ret_ref;
23784 }
23785
23786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23787         LDKBuiltCommitmentTransaction this_obj_conv;
23788         this_obj_conv.inner = (void*)(this_obj & (~1));
23789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23790         BuiltCommitmentTransaction_free(this_obj_conv);
23791 }
23792
23793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
23794         LDKBuiltCommitmentTransaction this_ptr_conv;
23795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23796         this_ptr_conv.is_owned = false;
23797         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
23798         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23799         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23800         Transaction_free(ret_var);
23801         return ret_arr;
23802 }
23803
23804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23805         LDKBuiltCommitmentTransaction this_ptr_conv;
23806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23807         this_ptr_conv.is_owned = false;
23808         LDKTransaction val_ref;
23809         val_ref.datalen = (*env)->GetArrayLength(env, val);
23810         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
23811         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
23812         val_ref.data_is_owned = true;
23813         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
23814 }
23815
23816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
23817         LDKBuiltCommitmentTransaction this_ptr_conv;
23818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23819         this_ptr_conv.is_owned = false;
23820         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
23822         return ret_arr;
23823 }
23824
23825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23826         LDKBuiltCommitmentTransaction this_ptr_conv;
23827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23828         this_ptr_conv.is_owned = false;
23829         LDKThirtyTwoBytes val_ref;
23830         CHECK((*env)->GetArrayLength(env, val) == 32);
23831         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23832         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
23833 }
23834
23835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
23836         LDKTransaction transaction_arg_ref;
23837         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
23838         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
23839         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
23840         transaction_arg_ref.data_is_owned = true;
23841         LDKThirtyTwoBytes txid_arg_ref;
23842         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
23843         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
23844         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
23845         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23846         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23847         uint64_t ret_ref = (uint64_t)ret_var.inner;
23848         if (ret_var.is_owned) {
23849                 ret_ref |= 1;
23850         }
23851         return ret_ref;
23852 }
23853
23854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23855         LDKBuiltCommitmentTransaction orig_conv;
23856         orig_conv.inner = (void*)(orig & (~1));
23857         orig_conv.is_owned = false;
23858         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
23859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23861         uint64_t ret_ref = (uint64_t)ret_var.inner;
23862         if (ret_var.is_owned) {
23863                 ret_ref |= 1;
23864         }
23865         return ret_ref;
23866 }
23867
23868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23869         LDKBuiltCommitmentTransaction obj_conv;
23870         obj_conv.inner = (void*)(obj & (~1));
23871         obj_conv.is_owned = false;
23872         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
23873         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23874         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23875         CVec_u8Z_free(ret_var);
23876         return ret_arr;
23877 }
23878
23879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23880         LDKu8slice ser_ref;
23881         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23882         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23883         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
23884         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
23885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23886         return (uint64_t)ret_conv;
23887 }
23888
23889 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) {
23890         LDKBuiltCommitmentTransaction this_arg_conv;
23891         this_arg_conv.inner = (void*)(this_arg & (~1));
23892         this_arg_conv.is_owned = false;
23893         LDKu8slice funding_redeemscript_ref;
23894         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23895         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23896         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
23898         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23899         return ret_arr;
23900 }
23901
23902 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) {
23903         LDKBuiltCommitmentTransaction this_arg_conv;
23904         this_arg_conv.inner = (void*)(this_arg & (~1));
23905         this_arg_conv.is_owned = false;
23906         unsigned char funding_key_arr[32];
23907         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
23908         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
23909         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
23910         LDKu8slice funding_redeemscript_ref;
23911         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23912         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23913         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
23915         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23916         return ret_arr;
23917 }
23918
23919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23920         LDKCommitmentTransaction this_obj_conv;
23921         this_obj_conv.inner = (void*)(this_obj & (~1));
23922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23923         CommitmentTransaction_free(this_obj_conv);
23924 }
23925
23926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23927         LDKCommitmentTransaction orig_conv;
23928         orig_conv.inner = (void*)(orig & (~1));
23929         orig_conv.is_owned = false;
23930         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
23931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23933         uint64_t ret_ref = (uint64_t)ret_var.inner;
23934         if (ret_var.is_owned) {
23935                 ret_ref |= 1;
23936         }
23937         return ret_ref;
23938 }
23939
23940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23941         LDKCommitmentTransaction obj_conv;
23942         obj_conv.inner = (void*)(obj & (~1));
23943         obj_conv.is_owned = false;
23944         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
23945         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23946         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23947         CVec_u8Z_free(ret_var);
23948         return ret_arr;
23949 }
23950
23951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23952         LDKu8slice ser_ref;
23953         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23954         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23955         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
23956         *ret_conv = CommitmentTransaction_read(ser_ref);
23957         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23958         return (uint64_t)ret_conv;
23959 }
23960
23961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
23962         LDKCommitmentTransaction this_arg_conv;
23963         this_arg_conv.inner = (void*)(this_arg & (~1));
23964         this_arg_conv.is_owned = false;
23965         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23966         return ret_val;
23967 }
23968
23969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23970         LDKCommitmentTransaction this_arg_conv;
23971         this_arg_conv.inner = (void*)(this_arg & (~1));
23972         this_arg_conv.is_owned = false;
23973         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23974         return ret_val;
23975 }
23976
23977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23978         LDKCommitmentTransaction this_arg_conv;
23979         this_arg_conv.inner = (void*)(this_arg & (~1));
23980         this_arg_conv.is_owned = false;
23981         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23982         return ret_val;
23983 }
23984
23985 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
23986         LDKCommitmentTransaction this_arg_conv;
23987         this_arg_conv.inner = (void*)(this_arg & (~1));
23988         this_arg_conv.is_owned = false;
23989         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23990         return ret_val;
23991 }
23992
23993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
23994         LDKCommitmentTransaction this_arg_conv;
23995         this_arg_conv.inner = (void*)(this_arg & (~1));
23996         this_arg_conv.is_owned = false;
23997         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24000         uint64_t ret_ref = (uint64_t)ret_var.inner;
24001         if (ret_var.is_owned) {
24002                 ret_ref |= 1;
24003         }
24004         return ret_ref;
24005 }
24006
24007 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) {
24008         LDKCommitmentTransaction this_arg_conv;
24009         this_arg_conv.inner = (void*)(this_arg & (~1));
24010         this_arg_conv.is_owned = false;
24011         LDKDirectedChannelTransactionParameters channel_parameters_conv;
24012         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
24013         channel_parameters_conv.is_owned = false;
24014         LDKChannelPublicKeys broadcaster_keys_conv;
24015         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
24016         broadcaster_keys_conv.is_owned = false;
24017         LDKChannelPublicKeys countersignatory_keys_conv;
24018         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
24019         countersignatory_keys_conv.is_owned = false;
24020         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
24021         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
24022         return (uint64_t)ret_conv;
24023 }
24024
24025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24026         LDKTrustedCommitmentTransaction this_obj_conv;
24027         this_obj_conv.inner = (void*)(this_obj & (~1));
24028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24029         TrustedCommitmentTransaction_free(this_obj_conv);
24030 }
24031
24032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
24033         LDKTrustedCommitmentTransaction this_arg_conv;
24034         this_arg_conv.inner = (void*)(this_arg & (~1));
24035         this_arg_conv.is_owned = false;
24036         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
24038         return ret_arr;
24039 }
24040
24041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
24042         LDKTrustedCommitmentTransaction this_arg_conv;
24043         this_arg_conv.inner = (void*)(this_arg & (~1));
24044         this_arg_conv.is_owned = false;
24045         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
24046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24048         uint64_t ret_ref = (uint64_t)ret_var.inner;
24049         if (ret_var.is_owned) {
24050                 ret_ref |= 1;
24051         }
24052         return ret_ref;
24053 }
24054
24055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
24056         LDKTrustedCommitmentTransaction this_arg_conv;
24057         this_arg_conv.inner = (void*)(this_arg & (~1));
24058         this_arg_conv.is_owned = false;
24059         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
24060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24062         uint64_t ret_ref = (uint64_t)ret_var.inner;
24063         if (ret_var.is_owned) {
24064                 ret_ref |= 1;
24065         }
24066         return ret_ref;
24067 }
24068
24069 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) {
24070         LDKTrustedCommitmentTransaction this_arg_conv;
24071         this_arg_conv.inner = (void*)(this_arg & (~1));
24072         this_arg_conv.is_owned = false;
24073         unsigned char htlc_base_key_arr[32];
24074         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
24075         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
24076         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
24077         LDKDirectedChannelTransactionParameters channel_parameters_conv;
24078         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
24079         channel_parameters_conv.is_owned = false;
24080         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
24081         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
24082         return (uint64_t)ret_conv;
24083 }
24084
24085 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) {
24086         LDKPublicKey broadcaster_payment_basepoint_ref;
24087         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
24088         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
24089         LDKPublicKey countersignatory_payment_basepoint_ref;
24090         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
24091         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
24092         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
24093         return ret_val;
24094 }
24095
24096 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24097         LDKInitFeatures a_conv;
24098         a_conv.inner = (void*)(a & (~1));
24099         a_conv.is_owned = false;
24100         LDKInitFeatures b_conv;
24101         b_conv.inner = (void*)(b & (~1));
24102         b_conv.is_owned = false;
24103         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
24104         return ret_val;
24105 }
24106
24107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24108         LDKNodeFeatures a_conv;
24109         a_conv.inner = (void*)(a & (~1));
24110         a_conv.is_owned = false;
24111         LDKNodeFeatures b_conv;
24112         b_conv.inner = (void*)(b & (~1));
24113         b_conv.is_owned = false;
24114         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
24115         return ret_val;
24116 }
24117
24118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24119         LDKChannelFeatures a_conv;
24120         a_conv.inner = (void*)(a & (~1));
24121         a_conv.is_owned = false;
24122         LDKChannelFeatures b_conv;
24123         b_conv.inner = (void*)(b & (~1));
24124         b_conv.is_owned = false;
24125         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
24126         return ret_val;
24127 }
24128
24129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24130         LDKInvoiceFeatures a_conv;
24131         a_conv.inner = (void*)(a & (~1));
24132         a_conv.is_owned = false;
24133         LDKInvoiceFeatures b_conv;
24134         b_conv.inner = (void*)(b & (~1));
24135         b_conv.is_owned = false;
24136         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
24137         return ret_val;
24138 }
24139
24140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24141         LDKInitFeatures orig_conv;
24142         orig_conv.inner = (void*)(orig & (~1));
24143         orig_conv.is_owned = false;
24144         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
24145         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24146         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24147         uint64_t ret_ref = (uint64_t)ret_var.inner;
24148         if (ret_var.is_owned) {
24149                 ret_ref |= 1;
24150         }
24151         return ret_ref;
24152 }
24153
24154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24155         LDKNodeFeatures orig_conv;
24156         orig_conv.inner = (void*)(orig & (~1));
24157         orig_conv.is_owned = false;
24158         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
24159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24161         uint64_t ret_ref = (uint64_t)ret_var.inner;
24162         if (ret_var.is_owned) {
24163                 ret_ref |= 1;
24164         }
24165         return ret_ref;
24166 }
24167
24168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24169         LDKChannelFeatures orig_conv;
24170         orig_conv.inner = (void*)(orig & (~1));
24171         orig_conv.is_owned = false;
24172         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
24173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24175         uint64_t ret_ref = (uint64_t)ret_var.inner;
24176         if (ret_var.is_owned) {
24177                 ret_ref |= 1;
24178         }
24179         return ret_ref;
24180 }
24181
24182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24183         LDKInvoiceFeatures orig_conv;
24184         orig_conv.inner = (void*)(orig & (~1));
24185         orig_conv.is_owned = false;
24186         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
24187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24189         uint64_t ret_ref = (uint64_t)ret_var.inner;
24190         if (ret_var.is_owned) {
24191                 ret_ref |= 1;
24192         }
24193         return ret_ref;
24194 }
24195
24196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24197         LDKInitFeatures this_obj_conv;
24198         this_obj_conv.inner = (void*)(this_obj & (~1));
24199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24200         InitFeatures_free(this_obj_conv);
24201 }
24202
24203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24204         LDKNodeFeatures this_obj_conv;
24205         this_obj_conv.inner = (void*)(this_obj & (~1));
24206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24207         NodeFeatures_free(this_obj_conv);
24208 }
24209
24210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24211         LDKChannelFeatures this_obj_conv;
24212         this_obj_conv.inner = (void*)(this_obj & (~1));
24213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24214         ChannelFeatures_free(this_obj_conv);
24215 }
24216
24217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24218         LDKInvoiceFeatures this_obj_conv;
24219         this_obj_conv.inner = (void*)(this_obj & (~1));
24220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24221         InvoiceFeatures_free(this_obj_conv);
24222 }
24223
24224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
24225         LDKInitFeatures ret_var = InitFeatures_empty();
24226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24228         uint64_t ret_ref = (uint64_t)ret_var.inner;
24229         if (ret_var.is_owned) {
24230                 ret_ref |= 1;
24231         }
24232         return ret_ref;
24233 }
24234
24235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
24236         LDKInitFeatures ret_var = InitFeatures_known();
24237         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24238         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24239         uint64_t ret_ref = (uint64_t)ret_var.inner;
24240         if (ret_var.is_owned) {
24241                 ret_ref |= 1;
24242         }
24243         return ret_ref;
24244 }
24245
24246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
24247         LDKNodeFeatures ret_var = NodeFeatures_empty();
24248         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24249         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24250         uint64_t ret_ref = (uint64_t)ret_var.inner;
24251         if (ret_var.is_owned) {
24252                 ret_ref |= 1;
24253         }
24254         return ret_ref;
24255 }
24256
24257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
24258         LDKNodeFeatures ret_var = NodeFeatures_known();
24259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24261         uint64_t ret_ref = (uint64_t)ret_var.inner;
24262         if (ret_var.is_owned) {
24263                 ret_ref |= 1;
24264         }
24265         return ret_ref;
24266 }
24267
24268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
24269         LDKChannelFeatures ret_var = ChannelFeatures_empty();
24270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24272         uint64_t ret_ref = (uint64_t)ret_var.inner;
24273         if (ret_var.is_owned) {
24274                 ret_ref |= 1;
24275         }
24276         return ret_ref;
24277 }
24278
24279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
24280         LDKChannelFeatures ret_var = ChannelFeatures_known();
24281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24283         uint64_t ret_ref = (uint64_t)ret_var.inner;
24284         if (ret_var.is_owned) {
24285                 ret_ref |= 1;
24286         }
24287         return ret_ref;
24288 }
24289
24290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
24291         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
24292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24294         uint64_t ret_ref = (uint64_t)ret_var.inner;
24295         if (ret_var.is_owned) {
24296                 ret_ref |= 1;
24297         }
24298         return ret_ref;
24299 }
24300
24301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
24302         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
24303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24305         uint64_t ret_ref = (uint64_t)ret_var.inner;
24306         if (ret_var.is_owned) {
24307                 ret_ref |= 1;
24308         }
24309         return ret_ref;
24310 }
24311
24312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
24313         LDKInitFeatures this_arg_conv;
24314         this_arg_conv.inner = (void*)(this_arg & (~1));
24315         this_arg_conv.is_owned = false;
24316         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
24317         return ret_val;
24318 }
24319
24320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
24321         LDKNodeFeatures this_arg_conv;
24322         this_arg_conv.inner = (void*)(this_arg & (~1));
24323         this_arg_conv.is_owned = false;
24324         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
24325         return ret_val;
24326 }
24327
24328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
24329         LDKInvoiceFeatures this_arg_conv;
24330         this_arg_conv.inner = (void*)(this_arg & (~1));
24331         this_arg_conv.is_owned = false;
24332         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
24333         return ret_val;
24334 }
24335
24336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24337         LDKInitFeatures obj_conv;
24338         obj_conv.inner = (void*)(obj & (~1));
24339         obj_conv.is_owned = false;
24340         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
24341         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24342         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24343         CVec_u8Z_free(ret_var);
24344         return ret_arr;
24345 }
24346
24347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24348         LDKNodeFeatures obj_conv;
24349         obj_conv.inner = (void*)(obj & (~1));
24350         obj_conv.is_owned = false;
24351         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
24352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24354         CVec_u8Z_free(ret_var);
24355         return ret_arr;
24356 }
24357
24358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24359         LDKChannelFeatures obj_conv;
24360         obj_conv.inner = (void*)(obj & (~1));
24361         obj_conv.is_owned = false;
24362         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
24363         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24364         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24365         CVec_u8Z_free(ret_var);
24366         return ret_arr;
24367 }
24368
24369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24370         LDKInvoiceFeatures obj_conv;
24371         obj_conv.inner = (void*)(obj & (~1));
24372         obj_conv.is_owned = false;
24373         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
24374         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24375         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24376         CVec_u8Z_free(ret_var);
24377         return ret_arr;
24378 }
24379
24380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24381         LDKu8slice ser_ref;
24382         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24383         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24384         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
24385         *ret_conv = InitFeatures_read(ser_ref);
24386         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24387         return (uint64_t)ret_conv;
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24391         LDKu8slice ser_ref;
24392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24394         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
24395         *ret_conv = NodeFeatures_read(ser_ref);
24396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24397         return (uint64_t)ret_conv;
24398 }
24399
24400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24401         LDKu8slice ser_ref;
24402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24404         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
24405         *ret_conv = ChannelFeatures_read(ser_ref);
24406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24407         return (uint64_t)ret_conv;
24408 }
24409
24410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24411         LDKu8slice ser_ref;
24412         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24413         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24414         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
24415         *ret_conv = InvoiceFeatures_read(ser_ref);
24416         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24417         return (uint64_t)ret_conv;
24418 }
24419
24420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24421         LDKShutdownScript this_obj_conv;
24422         this_obj_conv.inner = (void*)(this_obj & (~1));
24423         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24424         ShutdownScript_free(this_obj_conv);
24425 }
24426
24427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24428         LDKShutdownScript orig_conv;
24429         orig_conv.inner = (void*)(orig & (~1));
24430         orig_conv.is_owned = false;
24431         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
24432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24434         uint64_t ret_ref = (uint64_t)ret_var.inner;
24435         if (ret_var.is_owned) {
24436                 ret_ref |= 1;
24437         }
24438         return ret_ref;
24439 }
24440
24441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24442         LDKInvalidShutdownScript this_obj_conv;
24443         this_obj_conv.inner = (void*)(this_obj & (~1));
24444         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24445         InvalidShutdownScript_free(this_obj_conv);
24446 }
24447
24448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
24449         LDKInvalidShutdownScript this_ptr_conv;
24450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24451         this_ptr_conv.is_owned = false;
24452         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
24453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24455         return ret_arr;
24456 }
24457
24458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24459         LDKInvalidShutdownScript this_ptr_conv;
24460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24461         this_ptr_conv.is_owned = false;
24462         LDKCVec_u8Z val_ref;
24463         val_ref.datalen = (*env)->GetArrayLength(env, val);
24464         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
24465         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
24466         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
24467 }
24468
24469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
24470         LDKCVec_u8Z script_arg_ref;
24471         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
24472         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
24473         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
24474         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
24475         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24476         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24477         uint64_t ret_ref = (uint64_t)ret_var.inner;
24478         if (ret_var.is_owned) {
24479                 ret_ref |= 1;
24480         }
24481         return ret_ref;
24482 }
24483
24484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
24485         LDKShutdownScript obj_conv;
24486         obj_conv.inner = (void*)(obj & (~1));
24487         obj_conv.is_owned = false;
24488         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
24489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24491         CVec_u8Z_free(ret_var);
24492         return ret_arr;
24493 }
24494
24495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24496         LDKu8slice ser_ref;
24497         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24498         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24499         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
24500         *ret_conv = ShutdownScript_read(ser_ref);
24501         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24502         return (uint64_t)ret_conv;
24503 }
24504
24505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2pkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
24506         unsigned char pubkey_hash_arr[20];
24507         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
24508         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
24509         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
24510         LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref);
24511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24513         uint64_t ret_ref = (uint64_t)ret_var.inner;
24514         if (ret_var.is_owned) {
24515                 ret_ref |= 1;
24516         }
24517         return ret_ref;
24518 }
24519
24520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2sh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
24521         unsigned char script_hash_arr[20];
24522         CHECK((*env)->GetArrayLength(env, script_hash) == 20);
24523         (*env)->GetByteArrayRegion(env, script_hash, 0, 20, script_hash_arr);
24524         unsigned char (*script_hash_ref)[20] = &script_hash_arr;
24525         LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref);
24526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24528         uint64_t ret_ref = (uint64_t)ret_var.inner;
24529         if (ret_var.is_owned) {
24530                 ret_ref |= 1;
24531         }
24532         return ret_ref;
24533 }
24534
24535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
24536         unsigned char pubkey_hash_arr[20];
24537         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
24538         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
24539         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
24540         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
24541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24543         uint64_t ret_ref = (uint64_t)ret_var.inner;
24544         if (ret_var.is_owned) {
24545                 ret_ref |= 1;
24546         }
24547         return ret_ref;
24548 }
24549
24550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
24551         unsigned char script_hash_arr[32];
24552         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
24553         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
24554         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
24555         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
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 int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
24566         LDKu8slice program_ref;
24567         program_ref.datalen = (*env)->GetArrayLength(env, program);
24568         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
24569         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
24570         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
24571         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
24572         return (uint64_t)ret_conv;
24573 }
24574
24575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
24576         LDKShutdownScript this_arg_conv;
24577         this_arg_conv.inner = (void*)(this_arg & (~1));
24578         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24579         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
24580         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
24581         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24582         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24583         CVec_u8Z_free(ret_var);
24584         return ret_arr;
24585 }
24586
24587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
24588         LDKShutdownScript this_arg_conv;
24589         this_arg_conv.inner = (void*)(this_arg & (~1));
24590         this_arg_conv.is_owned = false;
24591         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
24593         return ret_arr;
24594 }
24595
24596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
24597         LDKShutdownScript this_arg_conv;
24598         this_arg_conv.inner = (void*)(this_arg & (~1));
24599         this_arg_conv.is_owned = false;
24600         LDKInitFeatures features_conv;
24601         features_conv.inner = (void*)(features & (~1));
24602         features_conv.is_owned = false;
24603         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
24604         return ret_val;
24605 }
24606
24607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24608         LDKRouteHop this_obj_conv;
24609         this_obj_conv.inner = (void*)(this_obj & (~1));
24610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24611         RouteHop_free(this_obj_conv);
24612 }
24613
24614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24615         LDKRouteHop this_ptr_conv;
24616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24617         this_ptr_conv.is_owned = false;
24618         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
24620         return ret_arr;
24621 }
24622
24623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24624         LDKRouteHop this_ptr_conv;
24625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24626         this_ptr_conv.is_owned = false;
24627         LDKPublicKey val_ref;
24628         CHECK((*env)->GetArrayLength(env, val) == 33);
24629         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24630         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
24631 }
24632
24633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24634         LDKRouteHop this_ptr_conv;
24635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24636         this_ptr_conv.is_owned = false;
24637         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
24638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24640         uint64_t ret_ref = (uint64_t)ret_var.inner;
24641         if (ret_var.is_owned) {
24642                 ret_ref |= 1;
24643         }
24644         return ret_ref;
24645 }
24646
24647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24648         LDKRouteHop this_ptr_conv;
24649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24650         this_ptr_conv.is_owned = false;
24651         LDKNodeFeatures val_conv;
24652         val_conv.inner = (void*)(val & (~1));
24653         val_conv.is_owned = (val & 1) || (val == 0);
24654         val_conv = NodeFeatures_clone(&val_conv);
24655         RouteHop_set_node_features(&this_ptr_conv, val_conv);
24656 }
24657
24658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24659         LDKRouteHop this_ptr_conv;
24660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24661         this_ptr_conv.is_owned = false;
24662         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
24663         return ret_val;
24664 }
24665
24666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24667         LDKRouteHop this_ptr_conv;
24668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24669         this_ptr_conv.is_owned = false;
24670         RouteHop_set_short_channel_id(&this_ptr_conv, val);
24671 }
24672
24673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24674         LDKRouteHop this_ptr_conv;
24675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24676         this_ptr_conv.is_owned = false;
24677         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
24678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24680         uint64_t ret_ref = (uint64_t)ret_var.inner;
24681         if (ret_var.is_owned) {
24682                 ret_ref |= 1;
24683         }
24684         return ret_ref;
24685 }
24686
24687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24688         LDKRouteHop this_ptr_conv;
24689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24690         this_ptr_conv.is_owned = false;
24691         LDKChannelFeatures val_conv;
24692         val_conv.inner = (void*)(val & (~1));
24693         val_conv.is_owned = (val & 1) || (val == 0);
24694         val_conv = ChannelFeatures_clone(&val_conv);
24695         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
24696 }
24697
24698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24699         LDKRouteHop this_ptr_conv;
24700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24701         this_ptr_conv.is_owned = false;
24702         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
24703         return ret_val;
24704 }
24705
24706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24707         LDKRouteHop this_ptr_conv;
24708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24709         this_ptr_conv.is_owned = false;
24710         RouteHop_set_fee_msat(&this_ptr_conv, val);
24711 }
24712
24713 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24714         LDKRouteHop this_ptr_conv;
24715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24716         this_ptr_conv.is_owned = false;
24717         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
24718         return ret_val;
24719 }
24720
24721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24722         LDKRouteHop this_ptr_conv;
24723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24724         this_ptr_conv.is_owned = false;
24725         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
24726 }
24727
24728 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) {
24729         LDKPublicKey pubkey_arg_ref;
24730         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
24731         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
24732         LDKNodeFeatures node_features_arg_conv;
24733         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
24734         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
24735         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
24736         LDKChannelFeatures channel_features_arg_conv;
24737         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
24738         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
24739         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
24740         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);
24741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24743         uint64_t ret_ref = (uint64_t)ret_var.inner;
24744         if (ret_var.is_owned) {
24745                 ret_ref |= 1;
24746         }
24747         return ret_ref;
24748 }
24749
24750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24751         LDKRouteHop orig_conv;
24752         orig_conv.inner = (void*)(orig & (~1));
24753         orig_conv.is_owned = false;
24754         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
24755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24757         uint64_t ret_ref = (uint64_t)ret_var.inner;
24758         if (ret_var.is_owned) {
24759                 ret_ref |= 1;
24760         }
24761         return ret_ref;
24762 }
24763
24764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
24765         LDKRouteHop obj_conv;
24766         obj_conv.inner = (void*)(obj & (~1));
24767         obj_conv.is_owned = false;
24768         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
24769         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24770         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24771         CVec_u8Z_free(ret_var);
24772         return ret_arr;
24773 }
24774
24775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24776         LDKu8slice ser_ref;
24777         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24778         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24779         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
24780         *ret_conv = RouteHop_read(ser_ref);
24781         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24782         return (uint64_t)ret_conv;
24783 }
24784
24785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24786         LDKRoute this_obj_conv;
24787         this_obj_conv.inner = (void*)(this_obj & (~1));
24788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24789         Route_free(this_obj_conv);
24790 }
24791
24792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
24793         LDKRoute this_ptr_conv;
24794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24795         this_ptr_conv.is_owned = false;
24796         LDKCVec_CVec_RouteHopZZ val_constr;
24797         val_constr.datalen = (*env)->GetArrayLength(env, val);
24798         if (val_constr.datalen > 0)
24799                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24800         else
24801                 val_constr.data = NULL;
24802         for (size_t m = 0; m < val_constr.datalen; m++) {
24803                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
24804                 LDKCVec_RouteHopZ val_conv_12_constr;
24805                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
24806                 if (val_conv_12_constr.datalen > 0)
24807                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24808                 else
24809                         val_conv_12_constr.data = NULL;
24810                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
24811                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
24812                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
24813                         LDKRouteHop val_conv_12_conv_10_conv;
24814                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
24815                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
24816                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
24817                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
24818                 }
24819                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
24820                 val_constr.data[m] = val_conv_12_constr;
24821         }
24822         Route_set_paths(&this_ptr_conv, val_constr);
24823 }
24824
24825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
24826         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
24827         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
24828         if (paths_arg_constr.datalen > 0)
24829                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24830         else
24831                 paths_arg_constr.data = NULL;
24832         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
24833                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
24834                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
24835                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
24836                 if (paths_arg_conv_12_constr.datalen > 0)
24837                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24838                 else
24839                         paths_arg_conv_12_constr.data = NULL;
24840                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
24841                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
24842                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
24843                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
24844                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
24845                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
24846                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
24847                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
24848                 }
24849                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
24850                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
24851         }
24852         LDKRoute ret_var = Route_new(paths_arg_constr);
24853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24855         uint64_t ret_ref = (uint64_t)ret_var.inner;
24856         if (ret_var.is_owned) {
24857                 ret_ref |= 1;
24858         }
24859         return ret_ref;
24860 }
24861
24862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24863         LDKRoute orig_conv;
24864         orig_conv.inner = (void*)(orig & (~1));
24865         orig_conv.is_owned = false;
24866         LDKRoute ret_var = Route_clone(&orig_conv);
24867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24869         uint64_t ret_ref = (uint64_t)ret_var.inner;
24870         if (ret_var.is_owned) {
24871                 ret_ref |= 1;
24872         }
24873         return ret_ref;
24874 }
24875
24876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
24877         LDKRoute obj_conv;
24878         obj_conv.inner = (void*)(obj & (~1));
24879         obj_conv.is_owned = false;
24880         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
24881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24883         CVec_u8Z_free(ret_var);
24884         return ret_arr;
24885 }
24886
24887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24888         LDKu8slice ser_ref;
24889         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24890         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24891         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
24892         *ret_conv = Route_read(ser_ref);
24893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24894         return (uint64_t)ret_conv;
24895 }
24896
24897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24898         LDKRouteHint this_obj_conv;
24899         this_obj_conv.inner = (void*)(this_obj & (~1));
24900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24901         RouteHint_free(this_obj_conv);
24902 }
24903
24904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24905         LDKRouteHint a_conv;
24906         a_conv.inner = (void*)(a & (~1));
24907         a_conv.is_owned = false;
24908         LDKRouteHint b_conv;
24909         b_conv.inner = (void*)(b & (~1));
24910         b_conv.is_owned = false;
24911         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
24912         return ret_val;
24913 }
24914
24915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24916         LDKRouteHint orig_conv;
24917         orig_conv.inner = (void*)(orig & (~1));
24918         orig_conv.is_owned = false;
24919         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
24920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24922         uint64_t ret_ref = (uint64_t)ret_var.inner;
24923         if (ret_var.is_owned) {
24924                 ret_ref |= 1;
24925         }
24926         return ret_ref;
24927 }
24928
24929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24930         LDKRouteHintHop this_obj_conv;
24931         this_obj_conv.inner = (void*)(this_obj & (~1));
24932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24933         RouteHintHop_free(this_obj_conv);
24934 }
24935
24936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24937         LDKRouteHintHop this_ptr_conv;
24938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24939         this_ptr_conv.is_owned = false;
24940         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
24942         return ret_arr;
24943 }
24944
24945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24946         LDKRouteHintHop this_ptr_conv;
24947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24948         this_ptr_conv.is_owned = false;
24949         LDKPublicKey val_ref;
24950         CHECK((*env)->GetArrayLength(env, val) == 33);
24951         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24952         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
24953 }
24954
24955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24956         LDKRouteHintHop this_ptr_conv;
24957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24958         this_ptr_conv.is_owned = false;
24959         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
24960         return ret_val;
24961 }
24962
24963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24964         LDKRouteHintHop this_ptr_conv;
24965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24966         this_ptr_conv.is_owned = false;
24967         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
24968 }
24969
24970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24971         LDKRouteHintHop this_ptr_conv;
24972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24973         this_ptr_conv.is_owned = false;
24974         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
24975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24977         uint64_t ret_ref = (uint64_t)ret_var.inner;
24978         if (ret_var.is_owned) {
24979                 ret_ref |= 1;
24980         }
24981         return ret_ref;
24982 }
24983
24984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24985         LDKRouteHintHop this_ptr_conv;
24986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24987         this_ptr_conv.is_owned = false;
24988         LDKRoutingFees val_conv;
24989         val_conv.inner = (void*)(val & (~1));
24990         val_conv.is_owned = (val & 1) || (val == 0);
24991         val_conv = RoutingFees_clone(&val_conv);
24992         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
24993 }
24994
24995 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24996         LDKRouteHintHop this_ptr_conv;
24997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24998         this_ptr_conv.is_owned = false;
24999         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
25000         return ret_val;
25001 }
25002
25003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25004         LDKRouteHintHop this_ptr_conv;
25005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25006         this_ptr_conv.is_owned = false;
25007         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
25008 }
25009
25010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25011         LDKRouteHintHop this_ptr_conv;
25012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25013         this_ptr_conv.is_owned = false;
25014         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25015         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
25016         uint64_t ret_ref = (uint64_t)ret_copy;
25017         return ret_ref;
25018 }
25019
25020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25021         LDKRouteHintHop this_ptr_conv;
25022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25023         this_ptr_conv.is_owned = false;
25024         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25025         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
25026 }
25027
25028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25029         LDKRouteHintHop this_ptr_conv;
25030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25031         this_ptr_conv.is_owned = false;
25032         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25033         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
25034         uint64_t ret_ref = (uint64_t)ret_copy;
25035         return ret_ref;
25036 }
25037
25038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25039         LDKRouteHintHop this_ptr_conv;
25040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25041         this_ptr_conv.is_owned = false;
25042         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25043         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
25044 }
25045
25046 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) {
25047         LDKPublicKey src_node_id_arg_ref;
25048         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
25049         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
25050         LDKRoutingFees fees_arg_conv;
25051         fees_arg_conv.inner = (void*)(fees_arg & (~1));
25052         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
25053         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
25054         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
25055         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
25056         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);
25057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25059         uint64_t ret_ref = (uint64_t)ret_var.inner;
25060         if (ret_var.is_owned) {
25061                 ret_ref |= 1;
25062         }
25063         return ret_ref;
25064 }
25065
25066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25067         LDKRouteHintHop a_conv;
25068         a_conv.inner = (void*)(a & (~1));
25069         a_conv.is_owned = false;
25070         LDKRouteHintHop b_conv;
25071         b_conv.inner = (void*)(b & (~1));
25072         b_conv.is_owned = false;
25073         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
25074         return ret_val;
25075 }
25076
25077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25078         LDKRouteHintHop orig_conv;
25079         orig_conv.inner = (void*)(orig & (~1));
25080         orig_conv.is_owned = false;
25081         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
25082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25084         uint64_t ret_ref = (uint64_t)ret_var.inner;
25085         if (ret_var.is_owned) {
25086                 ret_ref |= 1;
25087         }
25088         return ret_ref;
25089 }
25090
25091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
25092         LDKPublicKey our_node_id_ref;
25093         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
25094         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
25095         LDKNetworkGraph network_conv;
25096         network_conv.inner = (void*)(network & (~1));
25097         network_conv.is_owned = false;
25098         LDKPublicKey payee_ref;
25099         CHECK((*env)->GetArrayLength(env, payee) == 33);
25100         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
25101         LDKCVec_ChannelDetailsZ first_hops_constr;
25102         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
25103         if (first_hops != NULL) {
25104                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
25105                 if (first_hops_constr.datalen > 0)
25106                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25107                 else
25108                         first_hops_constr.data = NULL;
25109                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
25110                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
25111                         int64_t first_hops_conv_16 = first_hops_vals[q];
25112                         LDKChannelDetails first_hops_conv_16_conv;
25113                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
25114                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
25115                         first_hops_constr.data[q] = first_hops_conv_16_conv;
25116                 }
25117                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
25118                 first_hops_ptr = &first_hops_constr;
25119         }
25120         LDKCVec_RouteHintZ last_hops_constr;
25121         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
25122         if (last_hops_constr.datalen > 0)
25123                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
25124         else
25125                 last_hops_constr.data = NULL;
25126         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
25127         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
25128                 int64_t last_hops_conv_11 = last_hops_vals[l];
25129                 LDKRouteHint last_hops_conv_11_conv;
25130                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
25131                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
25132                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
25133                 last_hops_constr.data[l] = last_hops_conv_11_conv;
25134         }
25135         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
25136         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25137         if (logger_conv.free == LDKLogger_JCalls_free) {
25138                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25139                 LDKLogger_JCalls_cloned(&logger_conv);
25140         }
25141         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
25142         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
25143         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
25144         return (uint64_t)ret_conv;
25145 }
25146
25147 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) {
25148         LDKPublicKey our_node_id_ref;
25149         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
25150         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
25151         LDKNetworkGraph network_conv;
25152         network_conv.inner = (void*)(network & (~1));
25153         network_conv.is_owned = false;
25154         LDKPublicKey payee_ref;
25155         CHECK((*env)->GetArrayLength(env, payee) == 33);
25156         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
25157         LDKInvoiceFeatures payee_features_conv;
25158         payee_features_conv.inner = (void*)(payee_features & (~1));
25159         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
25160         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
25161         LDKCVec_ChannelDetailsZ first_hops_constr;
25162         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
25163         if (first_hops != NULL) {
25164                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
25165                 if (first_hops_constr.datalen > 0)
25166                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25167                 else
25168                         first_hops_constr.data = NULL;
25169                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
25170                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
25171                         int64_t first_hops_conv_16 = first_hops_vals[q];
25172                         LDKChannelDetails first_hops_conv_16_conv;
25173                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
25174                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
25175                         first_hops_constr.data[q] = first_hops_conv_16_conv;
25176                 }
25177                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
25178                 first_hops_ptr = &first_hops_constr;
25179         }
25180         LDKCVec_RouteHintZ last_hops_constr;
25181         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
25182         if (last_hops_constr.datalen > 0)
25183                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
25184         else
25185                 last_hops_constr.data = NULL;
25186         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
25187         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
25188                 int64_t last_hops_conv_11 = last_hops_vals[l];
25189                 LDKRouteHint last_hops_conv_11_conv;
25190                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
25191                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
25192                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
25193                 last_hops_constr.data[l] = last_hops_conv_11_conv;
25194         }
25195         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
25196         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25197         if (logger_conv.free == LDKLogger_JCalls_free) {
25198                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25199                 LDKLogger_JCalls_cloned(&logger_conv);
25200         }
25201         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
25202         *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);
25203         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
25204         return (uint64_t)ret_conv;
25205 }
25206
25207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25208         LDKNetworkGraph this_obj_conv;
25209         this_obj_conv.inner = (void*)(this_obj & (~1));
25210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25211         NetworkGraph_free(this_obj_conv);
25212 }
25213
25214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25215         LDKNetworkGraph orig_conv;
25216         orig_conv.inner = (void*)(orig & (~1));
25217         orig_conv.is_owned = false;
25218         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
25219         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25220         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25221         uint64_t ret_ref = (uint64_t)ret_var.inner;
25222         if (ret_var.is_owned) {
25223                 ret_ref |= 1;
25224         }
25225         return ret_ref;
25226 }
25227
25228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25229         LDKLockedNetworkGraph this_obj_conv;
25230         this_obj_conv.inner = (void*)(this_obj & (~1));
25231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25232         LockedNetworkGraph_free(this_obj_conv);
25233 }
25234
25235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25236         LDKNetGraphMsgHandler this_obj_conv;
25237         this_obj_conv.inner = (void*)(this_obj & (~1));
25238         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25239         NetGraphMsgHandler_free(this_obj_conv);
25240 }
25241
25242 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) {
25243         LDKThirtyTwoBytes genesis_hash_ref;
25244         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
25245         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
25246         LDKAccess *chain_access_conv_ptr = NULL;
25247         if (chain_access != 0) {
25248                 LDKAccess chain_access_conv;
25249                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25250                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25251                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25252                         LDKAccess_JCalls_cloned(&chain_access_conv);
25253                 }
25254                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25255                 *chain_access_conv_ptr = chain_access_conv;
25256         }
25257         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25258         if (logger_conv.free == LDKLogger_JCalls_free) {
25259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25260                 LDKLogger_JCalls_cloned(&logger_conv);
25261         }
25262         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
25263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25265         uint64_t ret_ref = (uint64_t)ret_var.inner;
25266         if (ret_var.is_owned) {
25267                 ret_ref |= 1;
25268         }
25269         return ret_ref;
25270 }
25271
25272 JNIEXPORT 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) {
25273         LDKAccess *chain_access_conv_ptr = NULL;
25274         if (chain_access != 0) {
25275                 LDKAccess chain_access_conv;
25276                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25277                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25278                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25279                         LDKAccess_JCalls_cloned(&chain_access_conv);
25280                 }
25281                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25282                 *chain_access_conv_ptr = chain_access_conv;
25283         }
25284         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25285         if (logger_conv.free == LDKLogger_JCalls_free) {
25286                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25287                 LDKLogger_JCalls_cloned(&logger_conv);
25288         }
25289         LDKNetworkGraph network_graph_conv;
25290         network_graph_conv.inner = (void*)(network_graph & (~1));
25291         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
25292         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
25293         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
25294         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25295         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25296         uint64_t ret_ref = (uint64_t)ret_var.inner;
25297         if (ret_var.is_owned) {
25298                 ret_ref |= 1;
25299         }
25300         return ret_ref;
25301 }
25302
25303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
25304         LDKNetGraphMsgHandler this_arg_conv;
25305         this_arg_conv.inner = (void*)(this_arg & (~1));
25306         this_arg_conv.is_owned = false;
25307         LDKAccess *chain_access_conv_ptr = NULL;
25308         if (chain_access != 0) {
25309                 LDKAccess chain_access_conv;
25310                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25311                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25312                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25313                         LDKAccess_JCalls_cloned(&chain_access_conv);
25314                 }
25315                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25316                 *chain_access_conv_ptr = chain_access_conv;
25317         }
25318         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
25319 }
25320
25321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
25322         LDKNetGraphMsgHandler this_arg_conv;
25323         this_arg_conv.inner = (void*)(this_arg & (~1));
25324         this_arg_conv.is_owned = false;
25325         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
25326         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25327         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25328         uint64_t ret_ref = (uint64_t)ret_var.inner;
25329         if (ret_var.is_owned) {
25330                 ret_ref |= 1;
25331         }
25332         return ret_ref;
25333 }
25334
25335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
25336         LDKLockedNetworkGraph this_arg_conv;
25337         this_arg_conv.inner = (void*)(this_arg & (~1));
25338         this_arg_conv.is_owned = false;
25339         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
25340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25342         uint64_t ret_ref = (uint64_t)ret_var.inner;
25343         if (ret_var.is_owned) {
25344                 ret_ref |= 1;
25345         }
25346         return ret_ref;
25347 }
25348
25349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25350         LDKNetGraphMsgHandler this_arg_conv;
25351         this_arg_conv.inner = (void*)(this_arg & (~1));
25352         this_arg_conv.is_owned = false;
25353         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
25354         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
25355         return (uint64_t)ret;
25356 }
25357
25358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25359         LDKNetGraphMsgHandler this_arg_conv;
25360         this_arg_conv.inner = (void*)(this_arg & (~1));
25361         this_arg_conv.is_owned = false;
25362         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25363         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
25364         return (uint64_t)ret;
25365 }
25366
25367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25368         LDKDirectionalChannelInfo this_obj_conv;
25369         this_obj_conv.inner = (void*)(this_obj & (~1));
25370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25371         DirectionalChannelInfo_free(this_obj_conv);
25372 }
25373
25374 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
25375         LDKDirectionalChannelInfo this_ptr_conv;
25376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25377         this_ptr_conv.is_owned = false;
25378         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
25379         return ret_val;
25380 }
25381
25382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25383         LDKDirectionalChannelInfo this_ptr_conv;
25384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25385         this_ptr_conv.is_owned = false;
25386         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
25387 }
25388
25389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
25390         LDKDirectionalChannelInfo this_ptr_conv;
25391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25392         this_ptr_conv.is_owned = false;
25393         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
25394         return ret_val;
25395 }
25396
25397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25398         LDKDirectionalChannelInfo this_ptr_conv;
25399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25400         this_ptr_conv.is_owned = false;
25401         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
25402 }
25403
25404 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
25405         LDKDirectionalChannelInfo this_ptr_conv;
25406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25407         this_ptr_conv.is_owned = false;
25408         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
25409         return ret_val;
25410 }
25411
25412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25413         LDKDirectionalChannelInfo this_ptr_conv;
25414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25415         this_ptr_conv.is_owned = false;
25416         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25417 }
25418
25419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25420         LDKDirectionalChannelInfo this_ptr_conv;
25421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25422         this_ptr_conv.is_owned = false;
25423         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
25424         return ret_val;
25425 }
25426
25427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25428         LDKDirectionalChannelInfo this_ptr_conv;
25429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25430         this_ptr_conv.is_owned = false;
25431         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
25432 }
25433
25434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25435         LDKDirectionalChannelInfo this_ptr_conv;
25436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25437         this_ptr_conv.is_owned = false;
25438         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25439         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
25440         uint64_t ret_ref = (uint64_t)ret_copy;
25441         return ret_ref;
25442 }
25443
25444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25445         LDKDirectionalChannelInfo this_ptr_conv;
25446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25447         this_ptr_conv.is_owned = false;
25448         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25449         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
25450 }
25451
25452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
25453         LDKDirectionalChannelInfo this_ptr_conv;
25454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25455         this_ptr_conv.is_owned = false;
25456         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
25457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25459         uint64_t ret_ref = (uint64_t)ret_var.inner;
25460         if (ret_var.is_owned) {
25461                 ret_ref |= 1;
25462         }
25463         return ret_ref;
25464 }
25465
25466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25467         LDKDirectionalChannelInfo this_ptr_conv;
25468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25469         this_ptr_conv.is_owned = false;
25470         LDKRoutingFees val_conv;
25471         val_conv.inner = (void*)(val & (~1));
25472         val_conv.is_owned = (val & 1) || (val == 0);
25473         val_conv = RoutingFees_clone(&val_conv);
25474         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
25475 }
25476
25477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25478         LDKDirectionalChannelInfo this_ptr_conv;
25479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25480         this_ptr_conv.is_owned = false;
25481         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
25482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25484         uint64_t ret_ref = (uint64_t)ret_var.inner;
25485         if (ret_var.is_owned) {
25486                 ret_ref |= 1;
25487         }
25488         return ret_ref;
25489 }
25490
25491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25492         LDKDirectionalChannelInfo this_ptr_conv;
25493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25494         this_ptr_conv.is_owned = false;
25495         LDKChannelUpdate val_conv;
25496         val_conv.inner = (void*)(val & (~1));
25497         val_conv.is_owned = (val & 1) || (val == 0);
25498         val_conv = ChannelUpdate_clone(&val_conv);
25499         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
25500 }
25501
25502 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) {
25503         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
25504         LDKRoutingFees fees_arg_conv;
25505         fees_arg_conv.inner = (void*)(fees_arg & (~1));
25506         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
25507         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
25508         LDKChannelUpdate last_update_message_arg_conv;
25509         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
25510         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
25511         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
25512         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);
25513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25515         uint64_t ret_ref = (uint64_t)ret_var.inner;
25516         if (ret_var.is_owned) {
25517                 ret_ref |= 1;
25518         }
25519         return ret_ref;
25520 }
25521
25522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25523         LDKDirectionalChannelInfo orig_conv;
25524         orig_conv.inner = (void*)(orig & (~1));
25525         orig_conv.is_owned = false;
25526         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
25527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25529         uint64_t ret_ref = (uint64_t)ret_var.inner;
25530         if (ret_var.is_owned) {
25531                 ret_ref |= 1;
25532         }
25533         return ret_ref;
25534 }
25535
25536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25537         LDKDirectionalChannelInfo obj_conv;
25538         obj_conv.inner = (void*)(obj & (~1));
25539         obj_conv.is_owned = false;
25540         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
25541         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25542         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25543         CVec_u8Z_free(ret_var);
25544         return ret_arr;
25545 }
25546
25547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25548         LDKu8slice ser_ref;
25549         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25550         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25551         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
25552         *ret_conv = DirectionalChannelInfo_read(ser_ref);
25553         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25554         return (uint64_t)ret_conv;
25555 }
25556
25557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25558         LDKChannelInfo this_obj_conv;
25559         this_obj_conv.inner = (void*)(this_obj & (~1));
25560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25561         ChannelInfo_free(this_obj_conv);
25562 }
25563
25564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25565         LDKChannelInfo this_ptr_conv;
25566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25567         this_ptr_conv.is_owned = false;
25568         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
25569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25571         uint64_t ret_ref = (uint64_t)ret_var.inner;
25572         if (ret_var.is_owned) {
25573                 ret_ref |= 1;
25574         }
25575         return ret_ref;
25576 }
25577
25578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25579         LDKChannelInfo this_ptr_conv;
25580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25581         this_ptr_conv.is_owned = false;
25582         LDKChannelFeatures val_conv;
25583         val_conv.inner = (void*)(val & (~1));
25584         val_conv.is_owned = (val & 1) || (val == 0);
25585         val_conv = ChannelFeatures_clone(&val_conv);
25586         ChannelInfo_set_features(&this_ptr_conv, val_conv);
25587 }
25588
25589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
25590         LDKChannelInfo this_ptr_conv;
25591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25592         this_ptr_conv.is_owned = false;
25593         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
25595         return ret_arr;
25596 }
25597
25598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25599         LDKChannelInfo this_ptr_conv;
25600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25601         this_ptr_conv.is_owned = false;
25602         LDKPublicKey val_ref;
25603         CHECK((*env)->GetArrayLength(env, val) == 33);
25604         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25605         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
25606 }
25607
25608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
25609         LDKChannelInfo this_ptr_conv;
25610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25611         this_ptr_conv.is_owned = false;
25612         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
25613         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25614         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25615         uint64_t ret_ref = (uint64_t)ret_var.inner;
25616         if (ret_var.is_owned) {
25617                 ret_ref |= 1;
25618         }
25619         return ret_ref;
25620 }
25621
25622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25623         LDKChannelInfo this_ptr_conv;
25624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25625         this_ptr_conv.is_owned = false;
25626         LDKDirectionalChannelInfo val_conv;
25627         val_conv.inner = (void*)(val & (~1));
25628         val_conv.is_owned = (val & 1) || (val == 0);
25629         val_conv = DirectionalChannelInfo_clone(&val_conv);
25630         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
25631 }
25632
25633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
25634         LDKChannelInfo this_ptr_conv;
25635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25636         this_ptr_conv.is_owned = false;
25637         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
25639         return ret_arr;
25640 }
25641
25642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25643         LDKChannelInfo this_ptr_conv;
25644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25645         this_ptr_conv.is_owned = false;
25646         LDKPublicKey val_ref;
25647         CHECK((*env)->GetArrayLength(env, val) == 33);
25648         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25649         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
25650 }
25651
25652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
25653         LDKChannelInfo this_ptr_conv;
25654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25655         this_ptr_conv.is_owned = false;
25656         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
25657         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25658         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25659         uint64_t ret_ref = (uint64_t)ret_var.inner;
25660         if (ret_var.is_owned) {
25661                 ret_ref |= 1;
25662         }
25663         return ret_ref;
25664 }
25665
25666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25667         LDKChannelInfo this_ptr_conv;
25668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25669         this_ptr_conv.is_owned = false;
25670         LDKDirectionalChannelInfo val_conv;
25671         val_conv.inner = (void*)(val & (~1));
25672         val_conv.is_owned = (val & 1) || (val == 0);
25673         val_conv = DirectionalChannelInfo_clone(&val_conv);
25674         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
25675 }
25676
25677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
25678         LDKChannelInfo this_ptr_conv;
25679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25680         this_ptr_conv.is_owned = false;
25681         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25682         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
25683         uint64_t ret_ref = (uint64_t)ret_copy;
25684         return ret_ref;
25685 }
25686
25687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25688         LDKChannelInfo this_ptr_conv;
25689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25690         this_ptr_conv.is_owned = false;
25691         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25692         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
25693 }
25694
25695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25696         LDKChannelInfo this_ptr_conv;
25697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25698         this_ptr_conv.is_owned = false;
25699         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
25700         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25701         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25702         uint64_t ret_ref = (uint64_t)ret_var.inner;
25703         if (ret_var.is_owned) {
25704                 ret_ref |= 1;
25705         }
25706         return ret_ref;
25707 }
25708
25709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25710         LDKChannelInfo this_ptr_conv;
25711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25712         this_ptr_conv.is_owned = false;
25713         LDKChannelAnnouncement val_conv;
25714         val_conv.inner = (void*)(val & (~1));
25715         val_conv.is_owned = (val & 1) || (val == 0);
25716         val_conv = ChannelAnnouncement_clone(&val_conv);
25717         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
25718 }
25719
25720 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) {
25721         LDKChannelFeatures features_arg_conv;
25722         features_arg_conv.inner = (void*)(features_arg & (~1));
25723         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25724         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
25725         LDKPublicKey node_one_arg_ref;
25726         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
25727         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
25728         LDKDirectionalChannelInfo one_to_two_arg_conv;
25729         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
25730         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
25731         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
25732         LDKPublicKey node_two_arg_ref;
25733         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
25734         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
25735         LDKDirectionalChannelInfo two_to_one_arg_conv;
25736         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
25737         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
25738         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
25739         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
25740         LDKChannelAnnouncement announcement_message_arg_conv;
25741         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
25742         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
25743         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
25744         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);
25745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25747         uint64_t ret_ref = (uint64_t)ret_var.inner;
25748         if (ret_var.is_owned) {
25749                 ret_ref |= 1;
25750         }
25751         return ret_ref;
25752 }
25753
25754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25755         LDKChannelInfo orig_conv;
25756         orig_conv.inner = (void*)(orig & (~1));
25757         orig_conv.is_owned = false;
25758         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
25759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25761         uint64_t ret_ref = (uint64_t)ret_var.inner;
25762         if (ret_var.is_owned) {
25763                 ret_ref |= 1;
25764         }
25765         return ret_ref;
25766 }
25767
25768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25769         LDKChannelInfo obj_conv;
25770         obj_conv.inner = (void*)(obj & (~1));
25771         obj_conv.is_owned = false;
25772         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
25773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25775         CVec_u8Z_free(ret_var);
25776         return ret_arr;
25777 }
25778
25779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25780         LDKu8slice ser_ref;
25781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25783         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
25784         *ret_conv = ChannelInfo_read(ser_ref);
25785         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25786         return (uint64_t)ret_conv;
25787 }
25788
25789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25790         LDKRoutingFees this_obj_conv;
25791         this_obj_conv.inner = (void*)(this_obj & (~1));
25792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25793         RoutingFees_free(this_obj_conv);
25794 }
25795
25796 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25797         LDKRoutingFees this_ptr_conv;
25798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25799         this_ptr_conv.is_owned = false;
25800         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
25801         return ret_val;
25802 }
25803
25804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25805         LDKRoutingFees this_ptr_conv;
25806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25807         this_ptr_conv.is_owned = false;
25808         RoutingFees_set_base_msat(&this_ptr_conv, val);
25809 }
25810
25811 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25812         LDKRoutingFees this_ptr_conv;
25813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25814         this_ptr_conv.is_owned = false;
25815         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
25816         return ret_val;
25817 }
25818
25819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25820         LDKRoutingFees this_ptr_conv;
25821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25822         this_ptr_conv.is_owned = false;
25823         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
25824 }
25825
25826 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) {
25827         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
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 jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25838         LDKRoutingFees a_conv;
25839         a_conv.inner = (void*)(a & (~1));
25840         a_conv.is_owned = false;
25841         LDKRoutingFees b_conv;
25842         b_conv.inner = (void*)(b & (~1));
25843         b_conv.is_owned = false;
25844         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
25845         return ret_val;
25846 }
25847
25848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25849         LDKRoutingFees orig_conv;
25850         orig_conv.inner = (void*)(orig & (~1));
25851         orig_conv.is_owned = false;
25852         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
25853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25855         uint64_t ret_ref = (uint64_t)ret_var.inner;
25856         if (ret_var.is_owned) {
25857                 ret_ref |= 1;
25858         }
25859         return ret_ref;
25860 }
25861
25862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
25863         LDKRoutingFees obj_conv;
25864         obj_conv.inner = (void*)(obj & (~1));
25865         obj_conv.is_owned = false;
25866         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
25867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25869         CVec_u8Z_free(ret_var);
25870         return ret_arr;
25871 }
25872
25873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25874         LDKu8slice ser_ref;
25875         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25876         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25877         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
25878         *ret_conv = RoutingFees_read(ser_ref);
25879         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25880         return (uint64_t)ret_conv;
25881 }
25882
25883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25884         LDKNodeAnnouncementInfo this_obj_conv;
25885         this_obj_conv.inner = (void*)(this_obj & (~1));
25886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25887         NodeAnnouncementInfo_free(this_obj_conv);
25888 }
25889
25890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25891         LDKNodeAnnouncementInfo this_ptr_conv;
25892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25893         this_ptr_conv.is_owned = false;
25894         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
25895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25897         uint64_t ret_ref = (uint64_t)ret_var.inner;
25898         if (ret_var.is_owned) {
25899                 ret_ref |= 1;
25900         }
25901         return ret_ref;
25902 }
25903
25904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25905         LDKNodeAnnouncementInfo this_ptr_conv;
25906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25907         this_ptr_conv.is_owned = false;
25908         LDKNodeFeatures val_conv;
25909         val_conv.inner = (void*)(val & (~1));
25910         val_conv.is_owned = (val & 1) || (val == 0);
25911         val_conv = NodeFeatures_clone(&val_conv);
25912         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
25913 }
25914
25915 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
25916         LDKNodeAnnouncementInfo this_ptr_conv;
25917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25918         this_ptr_conv.is_owned = false;
25919         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
25920         return ret_val;
25921 }
25922
25923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25924         LDKNodeAnnouncementInfo this_ptr_conv;
25925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25926         this_ptr_conv.is_owned = false;
25927         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
25928 }
25929
25930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
25931         LDKNodeAnnouncementInfo this_ptr_conv;
25932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25933         this_ptr_conv.is_owned = false;
25934         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
25935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
25936         return ret_arr;
25937 }
25938
25939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25940         LDKNodeAnnouncementInfo this_ptr_conv;
25941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25942         this_ptr_conv.is_owned = false;
25943         LDKThreeBytes val_ref;
25944         CHECK((*env)->GetArrayLength(env, val) == 3);
25945         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
25946         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
25947 }
25948
25949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
25950         LDKNodeAnnouncementInfo this_ptr_conv;
25951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25952         this_ptr_conv.is_owned = false;
25953         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
25955         return ret_arr;
25956 }
25957
25958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25959         LDKNodeAnnouncementInfo this_ptr_conv;
25960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25961         this_ptr_conv.is_owned = false;
25962         LDKThirtyTwoBytes val_ref;
25963         CHECK((*env)->GetArrayLength(env, val) == 32);
25964         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25965         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
25966 }
25967
25968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25969         LDKNodeAnnouncementInfo this_ptr_conv;
25970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25971         this_ptr_conv.is_owned = false;
25972         LDKCVec_NetAddressZ val_constr;
25973         val_constr.datalen = (*env)->GetArrayLength(env, val);
25974         if (val_constr.datalen > 0)
25975                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25976         else
25977                 val_constr.data = NULL;
25978         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25979         for (size_t m = 0; m < val_constr.datalen; m++) {
25980                 int64_t val_conv_12 = val_vals[m];
25981                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
25982                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25983                 val_constr.data[m] = val_conv_12_conv;
25984         }
25985         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25986         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
25987 }
25988
25989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25990         LDKNodeAnnouncementInfo this_ptr_conv;
25991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25992         this_ptr_conv.is_owned = false;
25993         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
25994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25996         uint64_t ret_ref = (uint64_t)ret_var.inner;
25997         if (ret_var.is_owned) {
25998                 ret_ref |= 1;
25999         }
26000         return ret_ref;
26001 }
26002
26003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26004         LDKNodeAnnouncementInfo this_ptr_conv;
26005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26006         this_ptr_conv.is_owned = false;
26007         LDKNodeAnnouncement val_conv;
26008         val_conv.inner = (void*)(val & (~1));
26009         val_conv.is_owned = (val & 1) || (val == 0);
26010         val_conv = NodeAnnouncement_clone(&val_conv);
26011         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
26012 }
26013
26014 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) {
26015         LDKNodeFeatures features_arg_conv;
26016         features_arg_conv.inner = (void*)(features_arg & (~1));
26017         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26018         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
26019         LDKThreeBytes rgb_arg_ref;
26020         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
26021         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
26022         LDKThirtyTwoBytes alias_arg_ref;
26023         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
26024         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
26025         LDKCVec_NetAddressZ addresses_arg_constr;
26026         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
26027         if (addresses_arg_constr.datalen > 0)
26028                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26029         else
26030                 addresses_arg_constr.data = NULL;
26031         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
26032         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
26033                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
26034                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
26035                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
26036         }
26037         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
26038         LDKNodeAnnouncement announcement_message_arg_conv;
26039         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
26040         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
26041         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
26042         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
26043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26045         uint64_t ret_ref = (uint64_t)ret_var.inner;
26046         if (ret_var.is_owned) {
26047                 ret_ref |= 1;
26048         }
26049         return ret_ref;
26050 }
26051
26052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26053         LDKNodeAnnouncementInfo orig_conv;
26054         orig_conv.inner = (void*)(orig & (~1));
26055         orig_conv.is_owned = false;
26056         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
26057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26059         uint64_t ret_ref = (uint64_t)ret_var.inner;
26060         if (ret_var.is_owned) {
26061                 ret_ref |= 1;
26062         }
26063         return ret_ref;
26064 }
26065
26066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
26067         LDKNodeAnnouncementInfo obj_conv;
26068         obj_conv.inner = (void*)(obj & (~1));
26069         obj_conv.is_owned = false;
26070         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
26071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26073         CVec_u8Z_free(ret_var);
26074         return ret_arr;
26075 }
26076
26077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26078         LDKu8slice ser_ref;
26079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26081         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
26082         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
26083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26084         return (uint64_t)ret_conv;
26085 }
26086
26087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26088         LDKNodeInfo this_obj_conv;
26089         this_obj_conv.inner = (void*)(this_obj & (~1));
26090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26091         NodeInfo_free(this_obj_conv);
26092 }
26093
26094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
26095         LDKNodeInfo this_ptr_conv;
26096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26097         this_ptr_conv.is_owned = false;
26098         LDKCVec_u64Z val_constr;
26099         val_constr.datalen = (*env)->GetArrayLength(env, val);
26100         if (val_constr.datalen > 0)
26101                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26102         else
26103                 val_constr.data = NULL;
26104         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
26105         for (size_t g = 0; g < val_constr.datalen; g++) {
26106                 int64_t val_conv_6 = val_vals[g];
26107                 val_constr.data[g] = val_conv_6;
26108         }
26109         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
26110         NodeInfo_set_channels(&this_ptr_conv, val_constr);
26111 }
26112
26113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
26114         LDKNodeInfo this_ptr_conv;
26115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26116         this_ptr_conv.is_owned = false;
26117         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
26118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26120         uint64_t ret_ref = (uint64_t)ret_var.inner;
26121         if (ret_var.is_owned) {
26122                 ret_ref |= 1;
26123         }
26124         return ret_ref;
26125 }
26126
26127 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) {
26128         LDKNodeInfo this_ptr_conv;
26129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26130         this_ptr_conv.is_owned = false;
26131         LDKRoutingFees val_conv;
26132         val_conv.inner = (void*)(val & (~1));
26133         val_conv.is_owned = (val & 1) || (val == 0);
26134         val_conv = RoutingFees_clone(&val_conv);
26135         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
26136 }
26137
26138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
26139         LDKNodeInfo this_ptr_conv;
26140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26141         this_ptr_conv.is_owned = false;
26142         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
26143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26145         uint64_t ret_ref = (uint64_t)ret_var.inner;
26146         if (ret_var.is_owned) {
26147                 ret_ref |= 1;
26148         }
26149         return ret_ref;
26150 }
26151
26152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26153         LDKNodeInfo this_ptr_conv;
26154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26155         this_ptr_conv.is_owned = false;
26156         LDKNodeAnnouncementInfo val_conv;
26157         val_conv.inner = (void*)(val & (~1));
26158         val_conv.is_owned = (val & 1) || (val == 0);
26159         val_conv = NodeAnnouncementInfo_clone(&val_conv);
26160         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
26161 }
26162
26163 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) {
26164         LDKCVec_u64Z channels_arg_constr;
26165         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
26166         if (channels_arg_constr.datalen > 0)
26167                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26168         else
26169                 channels_arg_constr.data = NULL;
26170         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
26171         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
26172                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
26173                 channels_arg_constr.data[g] = channels_arg_conv_6;
26174         }
26175         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
26176         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
26177         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
26178         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
26179         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
26180         LDKNodeAnnouncementInfo announcement_info_arg_conv;
26181         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
26182         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
26183         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
26184         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
26185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26187         uint64_t ret_ref = (uint64_t)ret_var.inner;
26188         if (ret_var.is_owned) {
26189                 ret_ref |= 1;
26190         }
26191         return ret_ref;
26192 }
26193
26194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26195         LDKNodeInfo orig_conv;
26196         orig_conv.inner = (void*)(orig & (~1));
26197         orig_conv.is_owned = false;
26198         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
26199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26201         uint64_t ret_ref = (uint64_t)ret_var.inner;
26202         if (ret_var.is_owned) {
26203                 ret_ref |= 1;
26204         }
26205         return ret_ref;
26206 }
26207
26208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
26209         LDKNodeInfo obj_conv;
26210         obj_conv.inner = (void*)(obj & (~1));
26211         obj_conv.is_owned = false;
26212         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
26213         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26214         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26215         CVec_u8Z_free(ret_var);
26216         return ret_arr;
26217 }
26218
26219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26220         LDKu8slice ser_ref;
26221         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26222         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26223         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
26224         *ret_conv = NodeInfo_read(ser_ref);
26225         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26226         return (uint64_t)ret_conv;
26227 }
26228
26229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
26230         LDKNetworkGraph obj_conv;
26231         obj_conv.inner = (void*)(obj & (~1));
26232         obj_conv.is_owned = false;
26233         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
26234         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26235         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26236         CVec_u8Z_free(ret_var);
26237         return ret_arr;
26238 }
26239
26240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26241         LDKu8slice ser_ref;
26242         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26243         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26244         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
26245         *ret_conv = NetworkGraph_read(ser_ref);
26246         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26247         return (uint64_t)ret_conv;
26248 }
26249
26250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
26251         LDKThirtyTwoBytes genesis_hash_ref;
26252         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
26253         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
26254         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
26255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26257         uint64_t ret_ref = (uint64_t)ret_var.inner;
26258         if (ret_var.is_owned) {
26259                 ret_ref |= 1;
26260         }
26261         return ret_ref;
26262 }
26263
26264 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) {
26265         LDKNetworkGraph this_arg_conv;
26266         this_arg_conv.inner = (void*)(this_arg & (~1));
26267         this_arg_conv.is_owned = false;
26268         LDKNodeAnnouncement msg_conv;
26269         msg_conv.inner = (void*)(msg & (~1));
26270         msg_conv.is_owned = false;
26271         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26272         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
26273         return (uint64_t)ret_conv;
26274 }
26275
26276 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) {
26277         LDKNetworkGraph this_arg_conv;
26278         this_arg_conv.inner = (void*)(this_arg & (~1));
26279         this_arg_conv.is_owned = false;
26280         LDKUnsignedNodeAnnouncement msg_conv;
26281         msg_conv.inner = (void*)(msg & (~1));
26282         msg_conv.is_owned = false;
26283         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26284         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
26285         return (uint64_t)ret_conv;
26286 }
26287
26288 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) {
26289         LDKNetworkGraph this_arg_conv;
26290         this_arg_conv.inner = (void*)(this_arg & (~1));
26291         this_arg_conv.is_owned = false;
26292         LDKChannelAnnouncement msg_conv;
26293         msg_conv.inner = (void*)(msg & (~1));
26294         msg_conv.is_owned = false;
26295         LDKAccess *chain_access_conv_ptr = NULL;
26296         if (chain_access != 0) {
26297                 LDKAccess chain_access_conv;
26298                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
26299                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
26300                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26301                         LDKAccess_JCalls_cloned(&chain_access_conv);
26302                 }
26303                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
26304                 *chain_access_conv_ptr = chain_access_conv;
26305         }
26306         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26307         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
26308         return (uint64_t)ret_conv;
26309 }
26310
26311 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) {
26312         LDKNetworkGraph this_arg_conv;
26313         this_arg_conv.inner = (void*)(this_arg & (~1));
26314         this_arg_conv.is_owned = false;
26315         LDKUnsignedChannelAnnouncement msg_conv;
26316         msg_conv.inner = (void*)(msg & (~1));
26317         msg_conv.is_owned = false;
26318         LDKAccess *chain_access_conv_ptr = NULL;
26319         if (chain_access != 0) {
26320                 LDKAccess chain_access_conv;
26321                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
26322                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
26323                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26324                         LDKAccess_JCalls_cloned(&chain_access_conv);
26325                 }
26326                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
26327                 *chain_access_conv_ptr = chain_access_conv;
26328         }
26329         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26330         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
26331         return (uint64_t)ret_conv;
26332 }
26333
26334 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) {
26335         LDKNetworkGraph this_arg_conv;
26336         this_arg_conv.inner = (void*)(this_arg & (~1));
26337         this_arg_conv.is_owned = false;
26338         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
26339 }
26340
26341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
26342         LDKNetworkGraph this_arg_conv;
26343         this_arg_conv.inner = (void*)(this_arg & (~1));
26344         this_arg_conv.is_owned = false;
26345         LDKChannelUpdate msg_conv;
26346         msg_conv.inner = (void*)(msg & (~1));
26347         msg_conv.is_owned = false;
26348         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26349         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
26350         return (uint64_t)ret_conv;
26351 }
26352
26353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
26354         LDKNetworkGraph this_arg_conv;
26355         this_arg_conv.inner = (void*)(this_arg & (~1));
26356         this_arg_conv.is_owned = false;
26357         LDKUnsignedChannelUpdate msg_conv;
26358         msg_conv.inner = (void*)(msg & (~1));
26359         msg_conv.is_owned = false;
26360         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26361         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
26362         return (uint64_t)ret_conv;
26363 }
26364
26365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26366         LDKFilesystemPersister this_obj_conv;
26367         this_obj_conv.inner = (void*)(this_obj & (~1));
26368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26369         FilesystemPersister_free(this_obj_conv);
26370 }
26371
26372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
26373         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
26374         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
26375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26377         uint64_t ret_ref = (uint64_t)ret_var.inner;
26378         if (ret_var.is_owned) {
26379                 ret_ref |= 1;
26380         }
26381         return ret_ref;
26382 }
26383
26384 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
26385         LDKFilesystemPersister this_arg_conv;
26386         this_arg_conv.inner = (void*)(this_arg & (~1));
26387         this_arg_conv.is_owned = false;
26388         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
26389         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26390         Str_free(ret_str);
26391         return ret_conv;
26392 }
26393
26394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
26395         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
26396         LDKChannelManager manager_conv;
26397         manager_conv.inner = (void*)(manager & (~1));
26398         manager_conv.is_owned = false;
26399         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26400         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
26401         return (uint64_t)ret_conv;
26402 }
26403
26404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
26405         LDKFilesystemPersister this_arg_conv;
26406         this_arg_conv.inner = (void*)(this_arg & (~1));
26407         this_arg_conv.is_owned = false;
26408         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26409         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26410                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26411                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26412         }
26413         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
26414         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
26415         return (uint64_t)ret_conv;
26416 }
26417
26418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
26419         LDKFilesystemPersister this_arg_conv;
26420         this_arg_conv.inner = (void*)(this_arg & (~1));
26421         this_arg_conv.is_owned = false;
26422         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
26423         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
26424         return (uint64_t)ret;
26425 }
26426
26427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26428         LDKBackgroundProcessor this_obj_conv;
26429         this_obj_conv.inner = (void*)(this_obj & (~1));
26430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26431         BackgroundProcessor_free(this_obj_conv);
26432 }
26433
26434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26435         if ((this_ptr & 1) != 0) return;
26436         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
26437         FREE((void*)this_ptr);
26438         ChannelManagerPersister_free(this_ptr_conv);
26439 }
26440
26441 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) {
26442         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
26443         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
26444                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26445                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
26446         }
26447         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
26448         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
26449                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26450                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
26451         }
26452         LDKChainMonitor chain_monitor_conv;
26453         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
26454         chain_monitor_conv.is_owned = false;
26455         LDKChannelManager channel_manager_conv;
26456         channel_manager_conv.inner = (void*)(channel_manager & (~1));
26457         channel_manager_conv.is_owned = false;
26458         LDKPeerManager peer_manager_conv;
26459         peer_manager_conv.inner = (void*)(peer_manager & (~1));
26460         peer_manager_conv.is_owned = false;
26461         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
26462         if (logger_conv.free == LDKLogger_JCalls_free) {
26463                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26464                 LDKLogger_JCalls_cloned(&logger_conv);
26465         }
26466         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
26467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26469         uint64_t ret_ref = (uint64_t)ret_var.inner;
26470         if (ret_var.is_owned) {
26471                 ret_ref |= 1;
26472         }
26473         return ret_ref;
26474 }
26475
26476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
26477         LDKBackgroundProcessor this_arg_conv;
26478         this_arg_conv.inner = (void*)(this_arg & (~1));
26479         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26480         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
26481         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26482         *ret_conv = BackgroundProcessor_join(this_arg_conv);
26483         return (uint64_t)ret_conv;
26484 }
26485
26486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
26487         LDKBackgroundProcessor this_arg_conv;
26488         this_arg_conv.inner = (void*)(this_arg & (~1));
26489         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26490         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
26491         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26492         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
26493         return (uint64_t)ret_conv;
26494 }
26495
26496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
26497         check_platform();
26498 }
26499
26500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26501         LDKInvoice this_obj_conv;
26502         this_obj_conv.inner = (void*)(this_obj & (~1));
26503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26504         Invoice_free(this_obj_conv);
26505 }
26506
26507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26508         LDKInvoice a_conv;
26509         a_conv.inner = (void*)(a & (~1));
26510         a_conv.is_owned = false;
26511         LDKInvoice b_conv;
26512         b_conv.inner = (void*)(b & (~1));
26513         b_conv.is_owned = false;
26514         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
26515         return ret_val;
26516 }
26517
26518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26519         LDKInvoice orig_conv;
26520         orig_conv.inner = (void*)(orig & (~1));
26521         orig_conv.is_owned = false;
26522         LDKInvoice ret_var = Invoice_clone(&orig_conv);
26523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26525         uint64_t ret_ref = (uint64_t)ret_var.inner;
26526         if (ret_var.is_owned) {
26527                 ret_ref |= 1;
26528         }
26529         return ret_ref;
26530 }
26531
26532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26533         LDKSignedRawInvoice this_obj_conv;
26534         this_obj_conv.inner = (void*)(this_obj & (~1));
26535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26536         SignedRawInvoice_free(this_obj_conv);
26537 }
26538
26539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26540         LDKSignedRawInvoice a_conv;
26541         a_conv.inner = (void*)(a & (~1));
26542         a_conv.is_owned = false;
26543         LDKSignedRawInvoice b_conv;
26544         b_conv.inner = (void*)(b & (~1));
26545         b_conv.is_owned = false;
26546         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
26547         return ret_val;
26548 }
26549
26550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26551         LDKSignedRawInvoice orig_conv;
26552         orig_conv.inner = (void*)(orig & (~1));
26553         orig_conv.is_owned = false;
26554         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
26555         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26556         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26557         uint64_t ret_ref = (uint64_t)ret_var.inner;
26558         if (ret_var.is_owned) {
26559                 ret_ref |= 1;
26560         }
26561         return ret_ref;
26562 }
26563
26564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26565         LDKRawInvoice this_obj_conv;
26566         this_obj_conv.inner = (void*)(this_obj & (~1));
26567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26568         RawInvoice_free(this_obj_conv);
26569 }
26570
26571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
26572         LDKRawInvoice this_ptr_conv;
26573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26574         this_ptr_conv.is_owned = false;
26575         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
26576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26578         uint64_t ret_ref = (uint64_t)ret_var.inner;
26579         if (ret_var.is_owned) {
26580                 ret_ref |= 1;
26581         }
26582         return ret_ref;
26583 }
26584
26585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26586         LDKRawInvoice this_ptr_conv;
26587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26588         this_ptr_conv.is_owned = false;
26589         LDKRawDataPart val_conv;
26590         val_conv.inner = (void*)(val & (~1));
26591         val_conv.is_owned = (val & 1) || (val == 0);
26592         val_conv = RawDataPart_clone(&val_conv);
26593         RawInvoice_set_data(&this_ptr_conv, val_conv);
26594 }
26595
26596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26597         LDKRawInvoice a_conv;
26598         a_conv.inner = (void*)(a & (~1));
26599         a_conv.is_owned = false;
26600         LDKRawInvoice b_conv;
26601         b_conv.inner = (void*)(b & (~1));
26602         b_conv.is_owned = false;
26603         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
26604         return ret_val;
26605 }
26606
26607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26608         LDKRawInvoice orig_conv;
26609         orig_conv.inner = (void*)(orig & (~1));
26610         orig_conv.is_owned = false;
26611         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
26612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26614         uint64_t ret_ref = (uint64_t)ret_var.inner;
26615         if (ret_var.is_owned) {
26616                 ret_ref |= 1;
26617         }
26618         return ret_ref;
26619 }
26620
26621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26622         LDKRawDataPart this_obj_conv;
26623         this_obj_conv.inner = (void*)(this_obj & (~1));
26624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26625         RawDataPart_free(this_obj_conv);
26626 }
26627
26628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
26629         LDKRawDataPart this_ptr_conv;
26630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26631         this_ptr_conv.is_owned = false;
26632         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
26633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26635         uint64_t ret_ref = (uint64_t)ret_var.inner;
26636         if (ret_var.is_owned) {
26637                 ret_ref |= 1;
26638         }
26639         return ret_ref;
26640 }
26641
26642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26643         LDKRawDataPart this_ptr_conv;
26644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26645         this_ptr_conv.is_owned = false;
26646         LDKPositiveTimestamp val_conv;
26647         val_conv.inner = (void*)(val & (~1));
26648         val_conv.is_owned = (val & 1) || (val == 0);
26649         val_conv = PositiveTimestamp_clone(&val_conv);
26650         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
26651 }
26652
26653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26654         LDKRawDataPart a_conv;
26655         a_conv.inner = (void*)(a & (~1));
26656         a_conv.is_owned = false;
26657         LDKRawDataPart b_conv;
26658         b_conv.inner = (void*)(b & (~1));
26659         b_conv.is_owned = false;
26660         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
26661         return ret_val;
26662 }
26663
26664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26665         LDKRawDataPart orig_conv;
26666         orig_conv.inner = (void*)(orig & (~1));
26667         orig_conv.is_owned = false;
26668         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
26669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26671         uint64_t ret_ref = (uint64_t)ret_var.inner;
26672         if (ret_var.is_owned) {
26673                 ret_ref |= 1;
26674         }
26675         return ret_ref;
26676 }
26677
26678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26679         LDKPositiveTimestamp this_obj_conv;
26680         this_obj_conv.inner = (void*)(this_obj & (~1));
26681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26682         PositiveTimestamp_free(this_obj_conv);
26683 }
26684
26685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26686         LDKPositiveTimestamp a_conv;
26687         a_conv.inner = (void*)(a & (~1));
26688         a_conv.is_owned = false;
26689         LDKPositiveTimestamp b_conv;
26690         b_conv.inner = (void*)(b & (~1));
26691         b_conv.is_owned = false;
26692         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
26693         return ret_val;
26694 }
26695
26696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26697         LDKPositiveTimestamp orig_conv;
26698         orig_conv.inner = (void*)(orig & (~1));
26699         orig_conv.is_owned = false;
26700         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
26701         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26702         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26703         uint64_t ret_ref = (uint64_t)ret_var.inner;
26704         if (ret_var.is_owned) {
26705                 ret_ref |= 1;
26706         }
26707         return ret_ref;
26708 }
26709
26710 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26711         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
26712         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
26713         return ret_conv;
26714 }
26715
26716 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
26717         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
26718         return ret_conv;
26719 }
26720
26721 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
26722         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
26723         return ret_conv;
26724 }
26725
26726 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
26727         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
26728         return ret_conv;
26729 }
26730
26731 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
26732         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
26733         return ret_conv;
26734 }
26735
26736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26737         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
26738         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
26739         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
26740         return ret_val;
26741 }
26742
26743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
26744         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
26745         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
26746         return ret_val;
26747 }
26748
26749 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26750         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
26751         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
26752         return ret_conv;
26753 }
26754
26755 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
26756         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
26757         return ret_conv;
26758 }
26759
26760 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
26761         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
26762         return ret_conv;
26763 }
26764
26765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
26766         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
26767         return ret_conv;
26768 }
26769
26770 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
26771         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
26772         return ret_conv;
26773 }
26774
26775 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
26776         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
26777         return ret_conv;
26778 }
26779
26780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26781         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
26782         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
26783         jboolean ret_val = Currency_eq(a_conv, b_conv);
26784         return ret_val;
26785 }
26786
26787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26788         LDKSha256 this_obj_conv;
26789         this_obj_conv.inner = (void*)(this_obj & (~1));
26790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26791         Sha256_free(this_obj_conv);
26792 }
26793
26794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26795         LDKSha256 a_conv;
26796         a_conv.inner = (void*)(a & (~1));
26797         a_conv.is_owned = false;
26798         LDKSha256 b_conv;
26799         b_conv.inner = (void*)(b & (~1));
26800         b_conv.is_owned = false;
26801         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
26802         return ret_val;
26803 }
26804
26805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26806         LDKSha256 orig_conv;
26807         orig_conv.inner = (void*)(orig & (~1));
26808         orig_conv.is_owned = false;
26809         LDKSha256 ret_var = Sha256_clone(&orig_conv);
26810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26812         uint64_t ret_ref = (uint64_t)ret_var.inner;
26813         if (ret_var.is_owned) {
26814                 ret_ref |= 1;
26815         }
26816         return ret_ref;
26817 }
26818
26819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26820         LDKDescription this_obj_conv;
26821         this_obj_conv.inner = (void*)(this_obj & (~1));
26822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26823         Description_free(this_obj_conv);
26824 }
26825
26826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26827         LDKDescription a_conv;
26828         a_conv.inner = (void*)(a & (~1));
26829         a_conv.is_owned = false;
26830         LDKDescription b_conv;
26831         b_conv.inner = (void*)(b & (~1));
26832         b_conv.is_owned = false;
26833         jboolean ret_val = Description_eq(&a_conv, &b_conv);
26834         return ret_val;
26835 }
26836
26837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26838         LDKDescription orig_conv;
26839         orig_conv.inner = (void*)(orig & (~1));
26840         orig_conv.is_owned = false;
26841         LDKDescription ret_var = Description_clone(&orig_conv);
26842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26844         uint64_t ret_ref = (uint64_t)ret_var.inner;
26845         if (ret_var.is_owned) {
26846                 ret_ref |= 1;
26847         }
26848         return ret_ref;
26849 }
26850
26851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26852         LDKPayeePubKey this_obj_conv;
26853         this_obj_conv.inner = (void*)(this_obj & (~1));
26854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26855         PayeePubKey_free(this_obj_conv);
26856 }
26857
26858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26859         LDKPayeePubKey a_conv;
26860         a_conv.inner = (void*)(a & (~1));
26861         a_conv.is_owned = false;
26862         LDKPayeePubKey b_conv;
26863         b_conv.inner = (void*)(b & (~1));
26864         b_conv.is_owned = false;
26865         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
26866         return ret_val;
26867 }
26868
26869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26870         LDKPayeePubKey orig_conv;
26871         orig_conv.inner = (void*)(orig & (~1));
26872         orig_conv.is_owned = false;
26873         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
26874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26876         uint64_t ret_ref = (uint64_t)ret_var.inner;
26877         if (ret_var.is_owned) {
26878                 ret_ref |= 1;
26879         }
26880         return ret_ref;
26881 }
26882
26883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26884         LDKExpiryTime this_obj_conv;
26885         this_obj_conv.inner = (void*)(this_obj & (~1));
26886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26887         ExpiryTime_free(this_obj_conv);
26888 }
26889
26890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26891         LDKExpiryTime a_conv;
26892         a_conv.inner = (void*)(a & (~1));
26893         a_conv.is_owned = false;
26894         LDKExpiryTime b_conv;
26895         b_conv.inner = (void*)(b & (~1));
26896         b_conv.is_owned = false;
26897         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
26898         return ret_val;
26899 }
26900
26901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26902         LDKExpiryTime orig_conv;
26903         orig_conv.inner = (void*)(orig & (~1));
26904         orig_conv.is_owned = false;
26905         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
26906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26908         uint64_t ret_ref = (uint64_t)ret_var.inner;
26909         if (ret_var.is_owned) {
26910                 ret_ref |= 1;
26911         }
26912         return ret_ref;
26913 }
26914
26915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26916         LDKMinFinalCltvExpiry this_obj_conv;
26917         this_obj_conv.inner = (void*)(this_obj & (~1));
26918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26919         MinFinalCltvExpiry_free(this_obj_conv);
26920 }
26921
26922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26923         LDKMinFinalCltvExpiry a_conv;
26924         a_conv.inner = (void*)(a & (~1));
26925         a_conv.is_owned = false;
26926         LDKMinFinalCltvExpiry b_conv;
26927         b_conv.inner = (void*)(b & (~1));
26928         b_conv.is_owned = false;
26929         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
26930         return ret_val;
26931 }
26932
26933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26934         LDKMinFinalCltvExpiry orig_conv;
26935         orig_conv.inner = (void*)(orig & (~1));
26936         orig_conv.is_owned = false;
26937         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
26938         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26939         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26940         uint64_t ret_ref = (uint64_t)ret_var.inner;
26941         if (ret_var.is_owned) {
26942                 ret_ref |= 1;
26943         }
26944         return ret_ref;
26945 }
26946
26947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26948         if ((this_ptr & 1) != 0) return;
26949         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
26950         FREE((void*)this_ptr);
26951         Fallback_free(this_ptr_conv);
26952 }
26953
26954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26955         LDKFallback* orig_conv = (LDKFallback*)orig;
26956         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26957         *ret_copy = Fallback_clone(orig_conv);
26958         uint64_t ret_ref = (uint64_t)ret_copy;
26959         return ret_ref;
26960 }
26961
26962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
26963         
26964         LDKCVec_u8Z program_ref;
26965         program_ref.datalen = (*env)->GetArrayLength(env, program);
26966         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
26967         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
26968         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26969         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
26970         uint64_t ret_ref = (uint64_t)ret_copy;
26971         return ret_ref;
26972 }
26973
26974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26975         LDKTwentyBytes a_ref;
26976         CHECK((*env)->GetArrayLength(env, a) == 20);
26977         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26978         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26979         *ret_copy = Fallback_pub_key_hash(a_ref);
26980         uint64_t ret_ref = (uint64_t)ret_copy;
26981         return ret_ref;
26982 }
26983
26984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26985         LDKTwentyBytes a_ref;
26986         CHECK((*env)->GetArrayLength(env, a) == 20);
26987         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26988         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26989         *ret_copy = Fallback_script_hash(a_ref);
26990         uint64_t ret_ref = (uint64_t)ret_copy;
26991         return ret_ref;
26992 }
26993
26994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26995         LDKFallback* a_conv = (LDKFallback*)a;
26996         LDKFallback* b_conv = (LDKFallback*)b;
26997         jboolean ret_val = Fallback_eq(a_conv, b_conv);
26998         return ret_val;
26999 }
27000
27001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27002         LDKInvoiceSignature this_obj_conv;
27003         this_obj_conv.inner = (void*)(this_obj & (~1));
27004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27005         InvoiceSignature_free(this_obj_conv);
27006 }
27007
27008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27009         LDKInvoiceSignature a_conv;
27010         a_conv.inner = (void*)(a & (~1));
27011         a_conv.is_owned = false;
27012         LDKInvoiceSignature b_conv;
27013         b_conv.inner = (void*)(b & (~1));
27014         b_conv.is_owned = false;
27015         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
27016         return ret_val;
27017 }
27018
27019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27020         LDKInvoiceSignature orig_conv;
27021         orig_conv.inner = (void*)(orig & (~1));
27022         orig_conv.is_owned = false;
27023         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
27024         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27025         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27026         uint64_t ret_ref = (uint64_t)ret_var.inner;
27027         if (ret_var.is_owned) {
27028                 ret_ref |= 1;
27029         }
27030         return ret_ref;
27031 }
27032
27033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27034         LDKPrivateRoute this_obj_conv;
27035         this_obj_conv.inner = (void*)(this_obj & (~1));
27036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27037         PrivateRoute_free(this_obj_conv);
27038 }
27039
27040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27041         LDKPrivateRoute a_conv;
27042         a_conv.inner = (void*)(a & (~1));
27043         a_conv.is_owned = false;
27044         LDKPrivateRoute b_conv;
27045         b_conv.inner = (void*)(b & (~1));
27046         b_conv.is_owned = false;
27047         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
27048         return ret_val;
27049 }
27050
27051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27052         LDKPrivateRoute orig_conv;
27053         orig_conv.inner = (void*)(orig & (~1));
27054         orig_conv.is_owned = false;
27055         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
27056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27058         uint64_t ret_ref = (uint64_t)ret_var.inner;
27059         if (ret_var.is_owned) {
27060                 ret_ref |= 1;
27061         }
27062         return ret_ref;
27063 }
27064
27065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
27066         LDKSignedRawInvoice this_arg_conv;
27067         this_arg_conv.inner = (void*)(this_arg & (~1));
27068         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27069         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
27070         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
27071         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
27072         return (uint64_t)ret_ref;
27073 }
27074
27075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
27076         LDKSignedRawInvoice this_arg_conv;
27077         this_arg_conv.inner = (void*)(this_arg & (~1));
27078         this_arg_conv.is_owned = false;
27079         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
27080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27082         uint64_t ret_ref = (uint64_t)ret_var.inner;
27083         if (ret_var.is_owned) {
27084                 ret_ref |= 1;
27085         }
27086         return ret_ref;
27087 }
27088
27089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27090         LDKSignedRawInvoice this_arg_conv;
27091         this_arg_conv.inner = (void*)(this_arg & (~1));
27092         this_arg_conv.is_owned = false;
27093         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27094         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
27095         return ret_arr;
27096 }
27097
27098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
27099         LDKSignedRawInvoice this_arg_conv;
27100         this_arg_conv.inner = (void*)(this_arg & (~1));
27101         this_arg_conv.is_owned = false;
27102         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
27103         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27104         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27105         uint64_t ret_ref = (uint64_t)ret_var.inner;
27106         if (ret_var.is_owned) {
27107                 ret_ref |= 1;
27108         }
27109         return ret_ref;
27110 }
27111
27112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27113         LDKSignedRawInvoice this_arg_conv;
27114         this_arg_conv.inner = (void*)(this_arg & (~1));
27115         this_arg_conv.is_owned = false;
27116         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
27117         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
27118         return (uint64_t)ret_conv;
27119 }
27120
27121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
27122         LDKSignedRawInvoice this_arg_conv;
27123         this_arg_conv.inner = (void*)(this_arg & (~1));
27124         this_arg_conv.is_owned = false;
27125         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
27126         return ret_val;
27127 }
27128
27129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27130         LDKRawInvoice this_arg_conv;
27131         this_arg_conv.inner = (void*)(this_arg & (~1));
27132         this_arg_conv.is_owned = false;
27133         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27134         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
27135         return ret_arr;
27136 }
27137
27138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27139         LDKRawInvoice this_arg_conv;
27140         this_arg_conv.inner = (void*)(this_arg & (~1));
27141         this_arg_conv.is_owned = false;
27142         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
27143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27145         uint64_t ret_ref = (uint64_t)ret_var.inner;
27146         if (ret_var.is_owned) {
27147                 ret_ref |= 1;
27148         }
27149         return ret_ref;
27150 }
27151
27152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
27153         LDKRawInvoice this_arg_conv;
27154         this_arg_conv.inner = (void*)(this_arg & (~1));
27155         this_arg_conv.is_owned = false;
27156         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
27157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27159         uint64_t ret_ref = (uint64_t)ret_var.inner;
27160         if (ret_var.is_owned) {
27161                 ret_ref |= 1;
27162         }
27163         return ret_ref;
27164 }
27165
27166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27167         LDKRawInvoice this_arg_conv;
27168         this_arg_conv.inner = (void*)(this_arg & (~1));
27169         this_arg_conv.is_owned = false;
27170         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
27171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27173         uint64_t ret_ref = (uint64_t)ret_var.inner;
27174         if (ret_var.is_owned) {
27175                 ret_ref |= 1;
27176         }
27177         return ret_ref;
27178 }
27179
27180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27181         LDKRawInvoice this_arg_conv;
27182         this_arg_conv.inner = (void*)(this_arg & (~1));
27183         this_arg_conv.is_owned = false;
27184         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
27185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27187         uint64_t ret_ref = (uint64_t)ret_var.inner;
27188         if (ret_var.is_owned) {
27189                 ret_ref |= 1;
27190         }
27191         return ret_ref;
27192 }
27193
27194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
27195         LDKRawInvoice this_arg_conv;
27196         this_arg_conv.inner = (void*)(this_arg & (~1));
27197         this_arg_conv.is_owned = false;
27198         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
27199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27201         uint64_t ret_ref = (uint64_t)ret_var.inner;
27202         if (ret_var.is_owned) {
27203                 ret_ref |= 1;
27204         }
27205         return ret_ref;
27206 }
27207
27208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
27209         LDKRawInvoice this_arg_conv;
27210         this_arg_conv.inner = (void*)(this_arg & (~1));
27211         this_arg_conv.is_owned = false;
27212         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
27213         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27214         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27215         uint64_t ret_ref = (uint64_t)ret_var.inner;
27216         if (ret_var.is_owned) {
27217                 ret_ref |= 1;
27218         }
27219         return ret_ref;
27220 }
27221
27222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27223         LDKRawInvoice this_arg_conv;
27224         this_arg_conv.inner = (void*)(this_arg & (~1));
27225         this_arg_conv.is_owned = false;
27226         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27227         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
27228         return ret_arr;
27229 }
27230
27231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
27232         LDKRawInvoice this_arg_conv;
27233         this_arg_conv.inner = (void*)(this_arg & (~1));
27234         this_arg_conv.is_owned = false;
27235         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
27236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27238         uint64_t ret_ref = (uint64_t)ret_var.inner;
27239         if (ret_var.is_owned) {
27240                 ret_ref |= 1;
27241         }
27242         return ret_ref;
27243 }
27244
27245 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
27246         LDKRawInvoice this_arg_conv;
27247         this_arg_conv.inner = (void*)(this_arg & (~1));
27248         this_arg_conv.is_owned = false;
27249         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
27250         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27251         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27252         for (size_t o = 0; o < ret_var.datalen; o++) {
27253                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
27254                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27255                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27256                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
27257                 if (ret_conv_14_var.is_owned) {
27258                         ret_conv_14_ref |= 1;
27259                 }
27260                 ret_arr_ptr[o] = ret_conv_14_ref;
27261         }
27262         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27263         FREE(ret_var.data);
27264         return ret_arr;
27265 }
27266
27267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
27268         LDKRawInvoice this_arg_conv;
27269         this_arg_conv.inner = (void*)(this_arg & (~1));
27270         this_arg_conv.is_owned = false;
27271         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27272         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
27273         uint64_t ret_ref = (uint64_t)ret_copy;
27274         return ret_ref;
27275 }
27276
27277 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
27278         LDKRawInvoice this_arg_conv;
27279         this_arg_conv.inner = (void*)(this_arg & (~1));
27280         this_arg_conv.is_owned = false;
27281         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
27282         return ret_conv;
27283 }
27284
27285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
27286         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
27287         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
27288         return (uint64_t)ret_conv;
27289 }
27290
27291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
27292         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
27293         *ret_conv = PositiveTimestamp_from_system_time(time);
27294         return (uint64_t)ret_conv;
27295 }
27296
27297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
27298         LDKPositiveTimestamp this_arg_conv;
27299         this_arg_conv.inner = (void*)(this_arg & (~1));
27300         this_arg_conv.is_owned = false;
27301         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
27302         return ret_val;
27303 }
27304
27305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
27306         LDKPositiveTimestamp this_arg_conv;
27307         this_arg_conv.inner = (void*)(this_arg & (~1));
27308         this_arg_conv.is_owned = false;
27309         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
27310         return ret_val;
27311 }
27312
27313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
27314         LDKInvoice this_arg_conv;
27315         this_arg_conv.inner = (void*)(this_arg & (~1));
27316         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27317         this_arg_conv = Invoice_clone(&this_arg_conv);
27318         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
27319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27321         uint64_t ret_ref = (uint64_t)ret_var.inner;
27322         if (ret_var.is_owned) {
27323                 ret_ref |= 1;
27324         }
27325         return ret_ref;
27326 }
27327
27328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
27329         LDKInvoice this_arg_conv;
27330         this_arg_conv.inner = (void*)(this_arg & (~1));
27331         this_arg_conv.is_owned = false;
27332         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
27333         *ret_conv = Invoice_check_signature(&this_arg_conv);
27334         return (uint64_t)ret_conv;
27335 }
27336
27337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
27338         LDKSignedRawInvoice signed_invoice_conv;
27339         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
27340         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
27341         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
27342         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
27343         *ret_conv = Invoice_from_signed(signed_invoice_conv);
27344         return (uint64_t)ret_conv;
27345 }
27346
27347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
27348         LDKInvoice this_arg_conv;
27349         this_arg_conv.inner = (void*)(this_arg & (~1));
27350         this_arg_conv.is_owned = false;
27351         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
27352         return ret_val;
27353 }
27354
27355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27356         LDKInvoice this_arg_conv;
27357         this_arg_conv.inner = (void*)(this_arg & (~1));
27358         this_arg_conv.is_owned = false;
27359         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27360         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
27361         return ret_arr;
27362 }
27363
27364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27365         LDKInvoice this_arg_conv;
27366         this_arg_conv.inner = (void*)(this_arg & (~1));
27367         this_arg_conv.is_owned = false;
27368         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27369         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
27370         return ret_arr;
27371 }
27372
27373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27374         LDKInvoice this_arg_conv;
27375         this_arg_conv.inner = (void*)(this_arg & (~1));
27376         this_arg_conv.is_owned = false;
27377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
27379         return ret_arr;
27380 }
27381
27382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
27383         LDKInvoice this_arg_conv;
27384         this_arg_conv.inner = (void*)(this_arg & (~1));
27385         this_arg_conv.is_owned = false;
27386         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
27387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27389         uint64_t ret_ref = (uint64_t)ret_var.inner;
27390         if (ret_var.is_owned) {
27391                 ret_ref |= 1;
27392         }
27393         return ret_ref;
27394 }
27395
27396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27397         LDKInvoice this_arg_conv;
27398         this_arg_conv.inner = (void*)(this_arg & (~1));
27399         this_arg_conv.is_owned = false;
27400         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27401         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
27402         return ret_arr;
27403 }
27404
27405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
27406         LDKInvoice this_arg_conv;
27407         this_arg_conv.inner = (void*)(this_arg & (~1));
27408         this_arg_conv.is_owned = false;
27409         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
27410         return ret_val;
27411 }
27412
27413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
27414         LDKInvoice this_arg_conv;
27415         this_arg_conv.inner = (void*)(this_arg & (~1));
27416         this_arg_conv.is_owned = false;
27417         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
27418         return ret_val;
27419 }
27420
27421 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
27422         LDKInvoice this_arg_conv;
27423         this_arg_conv.inner = (void*)(this_arg & (~1));
27424         this_arg_conv.is_owned = false;
27425         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
27426         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27427         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27428         for (size_t o = 0; o < ret_var.datalen; o++) {
27429                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
27430                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27431                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27432                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
27433                 if (ret_conv_14_var.is_owned) {
27434                         ret_conv_14_ref |= 1;
27435                 }
27436                 ret_arr_ptr[o] = ret_conv_14_ref;
27437         }
27438         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27439         FREE(ret_var.data);
27440         return ret_arr;
27441 }
27442
27443 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
27444         LDKInvoice this_arg_conv;
27445         this_arg_conv.inner = (void*)(this_arg & (~1));
27446         this_arg_conv.is_owned = false;
27447         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
27448         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27449         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27450         for (size_t l = 0; l < ret_var.datalen; l++) {
27451                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
27452                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27453                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27454                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
27455                 if (ret_conv_11_var.is_owned) {
27456                         ret_conv_11_ref |= 1;
27457                 }
27458                 ret_arr_ptr[l] = ret_conv_11_ref;
27459         }
27460         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27461         FREE(ret_var.data);
27462         return ret_arr;
27463 }
27464
27465 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
27466         LDKInvoice this_arg_conv;
27467         this_arg_conv.inner = (void*)(this_arg & (~1));
27468         this_arg_conv.is_owned = false;
27469         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
27470         return ret_conv;
27471 }
27472
27473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
27474         LDKInvoice this_arg_conv;
27475         this_arg_conv.inner = (void*)(this_arg & (~1));
27476         this_arg_conv.is_owned = false;
27477         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27478         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
27479         uint64_t ret_ref = (uint64_t)ret_copy;
27480         return ret_ref;
27481 }
27482
27483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
27484         LDKStr description_conv = java_to_owned_str(env, description);
27485         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
27486         *ret_conv = Description_new(description_conv);
27487         return (uint64_t)ret_conv;
27488 }
27489
27490 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
27491         LDKDescription this_arg_conv;
27492         this_arg_conv.inner = (void*)(this_arg & (~1));
27493         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27494         this_arg_conv = Description_clone(&this_arg_conv);
27495         LDKStr ret_str = Description_into_inner(this_arg_conv);
27496         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27497         Str_free(ret_str);
27498         return ret_conv;
27499 }
27500
27501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
27502         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
27503         *ret_conv = ExpiryTime_from_seconds(seconds);
27504         return (uint64_t)ret_conv;
27505 }
27506
27507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
27508         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
27509         *ret_conv = ExpiryTime_from_duration(duration);
27510         return (uint64_t)ret_conv;
27511 }
27512
27513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
27514         LDKExpiryTime this_arg_conv;
27515         this_arg_conv.inner = (void*)(this_arg & (~1));
27516         this_arg_conv.is_owned = false;
27517         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
27518         return ret_val;
27519 }
27520
27521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
27522         LDKExpiryTime this_arg_conv;
27523         this_arg_conv.inner = (void*)(this_arg & (~1));
27524         this_arg_conv.is_owned = false;
27525         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
27526         return ret_val;
27527 }
27528
27529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
27530         LDKRouteHint hops_conv;
27531         hops_conv.inner = (void*)(hops & (~1));
27532         hops_conv.is_owned = (hops & 1) || (hops == 0);
27533         hops_conv = RouteHint_clone(&hops_conv);
27534         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
27535         *ret_conv = PrivateRoute_new(hops_conv);
27536         return (uint64_t)ret_conv;
27537 }
27538
27539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
27540         LDKPrivateRoute this_arg_conv;
27541         this_arg_conv.inner = (void*)(this_arg & (~1));
27542         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27543         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
27544         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
27545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27547         uint64_t ret_ref = (uint64_t)ret_var.inner;
27548         if (ret_var.is_owned) {
27549                 ret_ref |= 1;
27550         }
27551         return ret_ref;
27552 }
27553
27554 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27555         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
27556         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
27557         return ret_conv;
27558 }
27559
27560 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
27561         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
27562         return ret_conv;
27563 }
27564
27565 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
27566         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
27567         return ret_conv;
27568 }
27569
27570 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
27571         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
27572         return ret_conv;
27573 }
27574
27575 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
27576         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
27577         return ret_conv;
27578 }
27579
27580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27581         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
27582         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
27583         jboolean ret_val = CreationError_eq(a_conv, b_conv);
27584         return ret_val;
27585 }
27586
27587 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27588         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
27589         LDKStr ret_str = CreationError_to_str(o_conv);
27590         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27591         Str_free(ret_str);
27592         return ret_conv;
27593 }
27594
27595 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27596         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
27597         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
27598         return ret_conv;
27599 }
27600
27601 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
27602         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
27603         return ret_conv;
27604 }
27605
27606 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
27607         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
27608         return ret_conv;
27609 }
27610
27611 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
27612         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
27613         return ret_conv;
27614 }
27615
27616 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
27617         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
27618         return ret_conv;
27619 }
27620
27621 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
27622         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
27623         return ret_conv;
27624 }
27625
27626 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
27627         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
27628         return ret_conv;
27629 }
27630
27631 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
27632         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
27633         return ret_conv;
27634 }
27635
27636 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
27637         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
27638         return ret_conv;
27639 }
27640
27641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27642         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
27643         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
27644         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
27645         return ret_val;
27646 }
27647
27648 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27649         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
27650         LDKStr ret_str = SemanticError_to_str(o_conv);
27651         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27652         Str_free(ret_str);
27653         return ret_conv;
27654 }
27655
27656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27657         if ((this_ptr & 1) != 0) return;
27658         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
27659         FREE((void*)this_ptr);
27660         SignOrCreationError_free(this_ptr_conv);
27661 }
27662
27663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27664         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
27665         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27666         *ret_copy = SignOrCreationError_clone(orig_conv);
27667         uint64_t ret_ref = (uint64_t)ret_copy;
27668         return ret_ref;
27669 }
27670
27671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
27672         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27673         *ret_copy = SignOrCreationError_sign_error();
27674         uint64_t ret_ref = (uint64_t)ret_copy;
27675         return ret_ref;
27676 }
27677
27678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
27679         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
27680         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27681         *ret_copy = SignOrCreationError_creation_error(a_conv);
27682         uint64_t ret_ref = (uint64_t)ret_copy;
27683         return ret_ref;
27684 }
27685
27686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27687         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
27688         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
27689         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
27690         return ret_val;
27691 }
27692
27693 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27694         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
27695         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
27696         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27697         Str_free(ret_str);
27698         return ret_conv;
27699 }
27700
27701 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) {
27702         LDKChannelManager channelmanager_conv;
27703         channelmanager_conv.inner = (void*)(channelmanager & (~1));
27704         channelmanager_conv.is_owned = false;
27705         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
27706         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27708                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27709         }
27710         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
27711         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
27712         LDKStr description_conv = java_to_owned_str(env, description);
27713         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
27714         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
27715         return (uint64_t)ret_conv;
27716 }
27717
27718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
27719         LDKStr s_conv = java_to_owned_str(env, s);
27720         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
27721         *ret_conv = SiPrefix_from_str(s_conv);
27722         return (uint64_t)ret_conv;
27723 }
27724
27725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
27726         LDKStr s_conv = java_to_owned_str(env, s);
27727         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
27728         *ret_conv = Invoice_from_str(s_conv);
27729         return (uint64_t)ret_conv;
27730 }
27731
27732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
27733         LDKStr s_conv = java_to_owned_str(env, s);
27734         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
27735         *ret_conv = SignedRawInvoice_from_str(s_conv);
27736         return (uint64_t)ret_conv;
27737 }
27738
27739 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27740         LDKInvoice o_conv;
27741         o_conv.inner = (void*)(o & (~1));
27742         o_conv.is_owned = false;
27743         LDKStr ret_str = Invoice_to_str(&o_conv);
27744         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27745         Str_free(ret_str);
27746         return ret_conv;
27747 }
27748
27749 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27750         LDKSignedRawInvoice o_conv;
27751         o_conv.inner = (void*)(o & (~1));
27752         o_conv.is_owned = false;
27753         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
27754         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27755         Str_free(ret_str);
27756         return ret_conv;
27757 }
27758
27759 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27760         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
27761         LDKStr ret_str = Currency_to_str(o_conv);
27762         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27763         Str_free(ret_str);
27764         return ret_conv;
27765 }
27766
27767 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27768         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
27769         LDKStr ret_str = SiPrefix_to_str(o_conv);
27770         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27771         Str_free(ret_str);
27772         return ret_conv;
27773 }
27774