Re-generate auto-generated bindings + add Mac OS generated bindings
[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.98.2", strlen("v0.0.98.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_Off;
458                 case 1: return LDKLevel_Error;
459                 case 2: return LDKLevel_Warn;
460                 case 3: return LDKLevel_Info;
461                 case 4: return LDKLevel_Debug;
462                 case 5: return LDKLevel_Trace;
463         }
464         abort();
465 }
466 static jclass Level_class = NULL;
467 static jfieldID Level_LDKLevel_Off = NULL;
468 static jfieldID Level_LDKLevel_Error = NULL;
469 static jfieldID Level_LDKLevel_Warn = NULL;
470 static jfieldID Level_LDKLevel_Info = NULL;
471 static jfieldID Level_LDKLevel_Debug = NULL;
472 static jfieldID Level_LDKLevel_Trace = NULL;
473 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
474         Level_class = (*env)->NewGlobalRef(env, clz);
475         CHECK(Level_class != NULL);
476         Level_LDKLevel_Off = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Off", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Off != NULL);
478         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Error != 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_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
483         CHECK(Level_LDKLevel_Info != NULL);
484         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
485         CHECK(Level_LDKLevel_Debug != NULL);
486         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
487         CHECK(Level_LDKLevel_Trace != NULL);
488 }
489 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
490         switch (val) {
491                 case LDKLevel_Off:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Off);
493                 case LDKLevel_Error:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
495                 case LDKLevel_Warn:
496                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
497                 case LDKLevel_Info:
498                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
499                 case LDKLevel_Debug:
500                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
501                 case LDKLevel_Trace:
502                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
503                 default: abort();
504         }
505 }
506
507 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
508         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
509                 case 0: return LDKNetwork_Bitcoin;
510                 case 1: return LDKNetwork_Testnet;
511                 case 2: return LDKNetwork_Regtest;
512                 case 3: return LDKNetwork_Signet;
513         }
514         abort();
515 }
516 static jclass Network_class = NULL;
517 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
518 static jfieldID Network_LDKNetwork_Testnet = NULL;
519 static jfieldID Network_LDKNetwork_Regtest = NULL;
520 static jfieldID Network_LDKNetwork_Signet = NULL;
521 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
522         Network_class = (*env)->NewGlobalRef(env, clz);
523         CHECK(Network_class != NULL);
524         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
525         CHECK(Network_LDKNetwork_Bitcoin != NULL);
526         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
527         CHECK(Network_LDKNetwork_Testnet != NULL);
528         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
529         CHECK(Network_LDKNetwork_Regtest != NULL);
530         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
531         CHECK(Network_LDKNetwork_Signet != NULL);
532 }
533 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
534         switch (val) {
535                 case LDKNetwork_Bitcoin:
536                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
537                 case LDKNetwork_Testnet:
538                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
539                 case LDKNetwork_Regtest:
540                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
541                 case LDKNetwork_Signet:
542                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
543                 default: abort();
544         }
545 }
546
547 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
548         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
549                 case 0: return LDKSecp256k1Error_IncorrectSignature;
550                 case 1: return LDKSecp256k1Error_InvalidMessage;
551                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
552                 case 3: return LDKSecp256k1Error_InvalidSignature;
553                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
554                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
555                 case 6: return LDKSecp256k1Error_InvalidTweak;
556                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
557                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
558         }
559         abort();
560 }
561 static jclass Secp256k1Error_class = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
563 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
564 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
565 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
566 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
567 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
568 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
569 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
570 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
571 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
572         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
573         CHECK(Secp256k1Error_class != NULL);
574         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
580         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
582         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
584         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
585         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
586         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
587         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
588         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
589         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
590         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
591         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
592 }
593 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
594         switch (val) {
595                 case LDKSecp256k1Error_IncorrectSignature:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
597                 case LDKSecp256k1Error_InvalidMessage:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
599                 case LDKSecp256k1Error_InvalidPublicKey:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
601                 case LDKSecp256k1Error_InvalidSignature:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
603                 case LDKSecp256k1Error_InvalidSecretKey:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
605                 case LDKSecp256k1Error_InvalidRecoveryId:
606                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
607                 case LDKSecp256k1Error_InvalidTweak:
608                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
609                 case LDKSecp256k1Error_TweakCheckFailed:
610                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
611                 case LDKSecp256k1Error_NotEnoughMemory:
612                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
613                 default: abort();
614         }
615 }
616
617 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
618         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
619                 case 0: return LDKSemanticError_NoPaymentHash;
620                 case 1: return LDKSemanticError_MultiplePaymentHashes;
621                 case 2: return LDKSemanticError_NoDescription;
622                 case 3: return LDKSemanticError_MultipleDescriptions;
623                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
624                 case 5: return LDKSemanticError_InvalidFeatures;
625                 case 6: return LDKSemanticError_InvalidRecoveryId;
626                 case 7: return LDKSemanticError_InvalidSignature;
627         }
628         abort();
629 }
630 static jclass SemanticError_class = NULL;
631 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
632 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
633 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
634 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
635 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
636 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
637 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
638 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
639 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
640         SemanticError_class = (*env)->NewGlobalRef(env, clz);
641         CHECK(SemanticError_class != NULL);
642         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
644         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
646         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
648         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
650         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
651         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
652         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
653         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
654         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
655         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
656         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
657         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
658 }
659 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
660         switch (val) {
661                 case LDKSemanticError_NoPaymentHash:
662                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
663                 case LDKSemanticError_MultiplePaymentHashes:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
665                 case LDKSemanticError_NoDescription:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
667                 case LDKSemanticError_MultipleDescriptions:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
669                 case LDKSemanticError_MultiplePaymentSecrets:
670                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
671                 case LDKSemanticError_InvalidFeatures:
672                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
673                 case LDKSemanticError_InvalidRecoveryId:
674                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
675                 case LDKSemanticError_InvalidSignature:
676                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
677                 default: abort();
678         }
679 }
680
681 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
682         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
683                 case 0: return LDKSiPrefix_Milli;
684                 case 1: return LDKSiPrefix_Micro;
685                 case 2: return LDKSiPrefix_Nano;
686                 case 3: return LDKSiPrefix_Pico;
687         }
688         abort();
689 }
690 static jclass SiPrefix_class = NULL;
691 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
692 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
693 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
694 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
695 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
696         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
697         CHECK(SiPrefix_class != NULL);
698         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
699         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
700         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
701         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
702         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
703         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
704         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
705         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
706 }
707 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
708         switch (val) {
709                 case LDKSiPrefix_Milli:
710                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
711                 case LDKSiPrefix_Micro:
712                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
713                 case LDKSiPrefix_Nano:
714                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
715                 case LDKSiPrefix_Pico:
716                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
717                 default: abort();
718         }
719 }
720
721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
722         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
723         ret->datalen = (*env)->GetArrayLength(env, elems);
724         if (ret->datalen == 0) {
725                 ret->data = NULL;
726         } else {
727                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
728                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
729                 for (size_t i = 0; i < ret->datalen; i++) {
730                         ret->data[i] = java_elems[i];
731                 }
732                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
733         }
734         return (uint64_t)ret;
735 }
736 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
737         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
738         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
739         return ret;
740 }
741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
742         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
743 }
744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
745         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
746         CHECK(val->result_ok);
747         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
748         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
749         return res_arr;
750 }
751 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
752         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
753         CHECK(!val->result_ok);
754         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
755         return err_conv;
756 }
757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
758         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
759 }
760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
761         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
762         CHECK(val->result_ok);
763         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
764         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
765         return res_arr;
766 }
767 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
768         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
769         CHECK(!val->result_ok);
770         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
771         return err_conv;
772 }
773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
774         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
775 }
776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
777         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
778         CHECK(val->result_ok);
779         LDKTxCreationKeys res_var = (*val->contents.result);
780         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
781         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
782         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
783         return res_ref;
784 }
785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
786         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
787         CHECK(!val->result_ok);
788         LDKDecodeError err_var = (*val->contents.err);
789         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
790         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
791         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
792         return err_ref;
793 }
794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
795         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
796 }
797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
798         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
799         CHECK(val->result_ok);
800         LDKChannelPublicKeys res_var = (*val->contents.result);
801         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
802         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
803         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
804         return res_ref;
805 }
806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
807         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
808         CHECK(!val->result_ok);
809         LDKDecodeError err_var = (*val->contents.err);
810         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
811         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
812         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
813         return err_ref;
814 }
815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
816         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
817 }
818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
819         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
820         CHECK(val->result_ok);
821         LDKTxCreationKeys res_var = (*val->contents.result);
822         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
823         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
824         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
825         return res_ref;
826 }
827 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
828         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
829         CHECK(!val->result_ok);
830         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
831         return err_conv;
832 }
833 static jclass LDKCOption_u32Z_Some_class = NULL;
834 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
835 static jclass LDKCOption_u32Z_None_class = NULL;
836 static jmethodID LDKCOption_u32Z_None_meth = NULL;
837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
838         LDKCOption_u32Z_Some_class =
839                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
840         CHECK(LDKCOption_u32Z_Some_class != NULL);
841         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
842         CHECK(LDKCOption_u32Z_Some_meth != NULL);
843         LDKCOption_u32Z_None_class =
844                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
845         CHECK(LDKCOption_u32Z_None_class != NULL);
846         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
847         CHECK(LDKCOption_u32Z_None_meth != NULL);
848 }
849 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
850         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
851         switch(obj->tag) {
852                 case LDKCOption_u32Z_Some: {
853                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
854                 }
855                 case LDKCOption_u32Z_None: {
856                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
857                 }
858                 default: abort();
859         }
860 }
861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
862         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
863 }
864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
865         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
866         CHECK(val->result_ok);
867         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
868         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
869         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
870         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
871         return res_ref;
872 }
873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
874         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
875         CHECK(!val->result_ok);
876         LDKDecodeError err_var = (*val->contents.err);
877         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
878         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
879         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
880         return err_ref;
881 }
882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
883         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
884 }
885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
886         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
887         CHECK(val->result_ok);
888         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
889         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
890         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
891         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
892         return res_ref;
893 }
894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
895         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
896         CHECK(!val->result_ok);
897         LDKDecodeError err_var = (*val->contents.err);
898         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
899         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
900         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
901         return err_ref;
902 }
903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
904         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
905 }
906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
907         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
908         CHECK(val->result_ok);
909         LDKChannelTransactionParameters res_var = (*val->contents.result);
910         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
911         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
912         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
913         return res_ref;
914 }
915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
916         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
917         CHECK(!val->result_ok);
918         LDKDecodeError err_var = (*val->contents.err);
919         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
920         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
921         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
922         return err_ref;
923 }
924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
925         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
926 }
927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
928         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
929         CHECK(val->result_ok);
930         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
931         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
932         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
933         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
934         return res_ref;
935 }
936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
937         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
938         CHECK(!val->result_ok);
939         LDKDecodeError err_var = (*val->contents.err);
940         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
941         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
942         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
943         return err_ref;
944 }
945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
946         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
947 }
948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
949         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
950         CHECK(val->result_ok);
951         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
952         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
953         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
954         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
955         return res_ref;
956 }
957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
958         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
959         CHECK(!val->result_ok);
960         LDKDecodeError err_var = (*val->contents.err);
961         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
962         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
963         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
964         return err_ref;
965 }
966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
967         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
968 }
969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
970         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
971         CHECK(val->result_ok);
972         LDKCommitmentTransaction res_var = (*val->contents.result);
973         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
974         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
975         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
976         return res_ref;
977 }
978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
979         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
980         CHECK(!val->result_ok);
981         LDKDecodeError err_var = (*val->contents.err);
982         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
985         return err_ref;
986 }
987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
988         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
989 }
990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
991         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
992         CHECK(val->result_ok);
993         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
994         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
995         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
996         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
997         return res_ref;
998 }
999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1000         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1001         CHECK(!val->result_ok);
1002         return *val->contents.err;
1003 }
1004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1005         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1006 }
1007 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1008         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1009         CHECK(val->result_ok);
1010         LDKCVec_SignatureZ res_var = (*val->contents.result);
1011         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1012         ;
1013         for (size_t i = 0; i < res_var.datalen; i++) {
1014                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1015                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1016                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1017         }
1018         return res_arr;
1019 }
1020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1021         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1022         CHECK(!val->result_ok);
1023         return *val->contents.err;
1024 }
1025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1026         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1027 }
1028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1029         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1030         CHECK(val->result_ok);
1031         return *val->contents.result;
1032 }
1033 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1034         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1035         CHECK(!val->result_ok);
1036         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1037         return err_conv;
1038 }
1039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1040         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1041 }
1042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1043         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1044         CHECK(val->result_ok);
1045         LDKRouteHop res_var = (*val->contents.result);
1046         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1047         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1048         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1049         return res_ref;
1050 }
1051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1052         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1053         CHECK(!val->result_ok);
1054         LDKDecodeError err_var = (*val->contents.err);
1055         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1056         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1057         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1058         return err_ref;
1059 }
1060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1061         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1062         ret->datalen = (*env)->GetArrayLength(env, elems);
1063         if (ret->datalen == 0) {
1064                 ret->data = NULL;
1065         } else {
1066                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1067                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1068                 for (size_t i = 0; i < ret->datalen; i++) {
1069                         int64_t arr_elem = java_elems[i];
1070                         LDKRouteHop arr_elem_conv;
1071                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1072                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1073                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1074                         ret->data[i] = arr_elem_conv;
1075                 }
1076                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1077         }
1078         return (uint64_t)ret;
1079 }
1080 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1081         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1082         for (size_t i = 0; i < ret.datalen; i++) {
1083                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1084         }
1085         return ret;
1086 }
1087 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1088         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1089         for (size_t i = 0; i < ret.datalen; i++) {
1090                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1091         }
1092         return ret;
1093 }
1094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1095         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1096 }
1097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1098         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1099         CHECK(val->result_ok);
1100         LDKRoute res_var = (*val->contents.result);
1101         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1102         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1103         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1104         return res_ref;
1105 }
1106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1107         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1108         CHECK(!val->result_ok);
1109         LDKDecodeError err_var = (*val->contents.err);
1110         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1113         return err_ref;
1114 }
1115 static jclass LDKCOption_u64Z_Some_class = NULL;
1116 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1117 static jclass LDKCOption_u64Z_None_class = NULL;
1118 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1120         LDKCOption_u64Z_Some_class =
1121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1122         CHECK(LDKCOption_u64Z_Some_class != NULL);
1123         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1124         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1125         LDKCOption_u64Z_None_class =
1126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1127         CHECK(LDKCOption_u64Z_None_class != NULL);
1128         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1129         CHECK(LDKCOption_u64Z_None_meth != NULL);
1130 }
1131 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1132         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1133         switch(obj->tag) {
1134                 case LDKCOption_u64Z_Some: {
1135                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1136                 }
1137                 case LDKCOption_u64Z_None: {
1138                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1139                 }
1140                 default: abort();
1141         }
1142 }
1143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1144         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1145         ret->datalen = (*env)->GetArrayLength(env, elems);
1146         if (ret->datalen == 0) {
1147                 ret->data = NULL;
1148         } else {
1149                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1150                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1151                 for (size_t i = 0; i < ret->datalen; i++) {
1152                         int64_t arr_elem = java_elems[i];
1153                         LDKChannelDetails arr_elem_conv;
1154                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1155                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1156                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1157                         ret->data[i] = arr_elem_conv;
1158                 }
1159                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1160         }
1161         return (uint64_t)ret;
1162 }
1163 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1164         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1165         for (size_t i = 0; i < ret.datalen; i++) {
1166                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1167         }
1168         return ret;
1169 }
1170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1171         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1172         ret->datalen = (*env)->GetArrayLength(env, elems);
1173         if (ret->datalen == 0) {
1174                 ret->data = NULL;
1175         } else {
1176                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1177                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1178                 for (size_t i = 0; i < ret->datalen; i++) {
1179                         int64_t arr_elem = java_elems[i];
1180                         LDKRouteHint arr_elem_conv;
1181                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1182                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1183                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1184                         ret->data[i] = arr_elem_conv;
1185                 }
1186                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1187         }
1188         return (uint64_t)ret;
1189 }
1190 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1191         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1192         for (size_t i = 0; i < ret.datalen; i++) {
1193                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1194         }
1195         return ret;
1196 }
1197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1198         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1199 }
1200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1201         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1202         CHECK(val->result_ok);
1203         LDKRoute res_var = (*val->contents.result);
1204         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1205         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1206         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1207         return res_ref;
1208 }
1209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1210         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1211         CHECK(!val->result_ok);
1212         LDKLightningError err_var = (*val->contents.err);
1213         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1214         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1215         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1216         return err_ref;
1217 }
1218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1219         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1220 }
1221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1222         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1223         CHECK(val->result_ok);
1224         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1225         return (uint64_t)res_ref;
1226 }
1227 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1228         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1229         CHECK(!val->result_ok);
1230         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1231         return err_conv;
1232 }
1233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1234         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1235         ret->a = a;
1236         LDKTransaction b_ref;
1237         b_ref.datalen = (*env)->GetArrayLength(env, b);
1238         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1239         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1240         b_ref.data_is_owned = false;
1241         ret->b = b_ref;
1242         return (uint64_t)ret;
1243 }
1244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1245         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1246         return tuple->a;
1247 }
1248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1249         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1250         LDKTransaction b_var = tuple->b;
1251         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1252         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1253         return b_arr;
1254 }
1255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1256         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1257         ret->datalen = (*env)->GetArrayLength(env, elems);
1258         if (ret->datalen == 0) {
1259                 ret->data = NULL;
1260         } else {
1261                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1262                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1263                 for (size_t i = 0; i < ret->datalen; i++) {
1264                         int64_t arr_elem = java_elems[i];
1265                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1266                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1267                         ret->data[i] = arr_elem_conv;
1268                 }
1269                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1270         }
1271         return (uint64_t)ret;
1272 }
1273 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1274         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1275         for (size_t i = 0; i < ret.datalen; i++) {
1276                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1277         }
1278         return ret;
1279 }
1280 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1281         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1282         for (size_t i = 0; i < ret.datalen; i++) {
1283                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1284         }
1285         return ret;
1286 }
1287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1288         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1289 }
1290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1291         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1292         CHECK(val->result_ok);
1293         return *val->contents.result;
1294 }
1295 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1296         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1297         CHECK(!val->result_ok);
1298         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1299         return err_conv;
1300 }
1301 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1302 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1303 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1304 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1306         LDKMonitorEvent_HTLCEvent_class =
1307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1308         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1309         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1310         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1311         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1313         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1314         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1315         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1316 }
1317 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1318         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1319         switch(obj->tag) {
1320                 case LDKMonitorEvent_HTLCEvent: {
1321                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1322                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1323                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1324                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1325                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1326                 }
1327                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1328                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1329                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1332                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1333                 }
1334                 default: abort();
1335         }
1336 }
1337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1338         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1339         ret->datalen = (*env)->GetArrayLength(env, elems);
1340         if (ret->datalen == 0) {
1341                 ret->data = NULL;
1342         } else {
1343                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1344                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1345                 for (size_t i = 0; i < ret->datalen; i++) {
1346                         int64_t arr_elem = java_elems[i];
1347                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1348                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1349                         ret->data[i] = arr_elem_conv;
1350                 }
1351                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1352         }
1353         return (uint64_t)ret;
1354 }
1355 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1356         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1357         for (size_t i = 0; i < ret.datalen; i++) {
1358                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1359         }
1360         return ret;
1361 }
1362 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1363 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1364 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1365 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1367         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1368                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1369         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1370         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1371         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1372         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1373                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1374         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1375         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1376         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1377 }
1378 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1379         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1380         switch(obj->tag) {
1381                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1382                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1383                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1384                 }
1385                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1386                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1387                 }
1388                 default: abort();
1389         }
1390 }
1391 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1392 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1393 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1394 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1395 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1396 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1398         LDKSpendableOutputDescriptor_StaticOutput_class =
1399                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1400         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1401         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1402         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1403         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1404                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1405         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1406         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1407         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1408         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1409                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1410         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1411         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1412         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1413 }
1414 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1415         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1416         switch(obj->tag) {
1417                 case LDKSpendableOutputDescriptor_StaticOutput: {
1418                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1419                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1420                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1421                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1422                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1423                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1424                 }
1425                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1426                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1427                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1428                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1429                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1430                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1431                 }
1432                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1433                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1434                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1435                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1436                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1437                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1438                 }
1439                 default: abort();
1440         }
1441 }
1442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1443         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1444         ret->datalen = (*env)->GetArrayLength(env, elems);
1445         if (ret->datalen == 0) {
1446                 ret->data = NULL;
1447         } else {
1448                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1449                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1450                 for (size_t i = 0; i < ret->datalen; i++) {
1451                         int64_t arr_elem = java_elems[i];
1452                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1453                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1454                         ret->data[i] = arr_elem_conv;
1455                 }
1456                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1457         }
1458         return (uint64_t)ret;
1459 }
1460 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1461         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1462         for (size_t i = 0; i < ret.datalen; i++) {
1463                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1464         }
1465         return ret;
1466 }
1467 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1468 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1469 static jclass LDKErrorAction_IgnoreError_class = NULL;
1470 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1471 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1472 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1474         LDKErrorAction_DisconnectPeer_class =
1475                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1476         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1477         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1478         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1479         LDKErrorAction_IgnoreError_class =
1480                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1481         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1482         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1483         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1484         LDKErrorAction_SendErrorMessage_class =
1485                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1486         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1487         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1488         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1489 }
1490 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1491         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1492         switch(obj->tag) {
1493                 case LDKErrorAction_DisconnectPeer: {
1494                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1495                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1496                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1497                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1498                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1499                 }
1500                 case LDKErrorAction_IgnoreError: {
1501                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1502                 }
1503                 case LDKErrorAction_SendErrorMessage: {
1504                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1505                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1506                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1507                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1508                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1509                 }
1510                 default: abort();
1511         }
1512 }
1513 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1514 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1515 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1516 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1517 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1518 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1520         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1521                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1522         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1523         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1524         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1525         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1527         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1528         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1529         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1530         LDKHTLCFailChannelUpdate_NodeFailure_class =
1531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1532         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1533         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1534         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1535 }
1536 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1537         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1538         switch(obj->tag) {
1539                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1540                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1541                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1542                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1543                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1544                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1545                 }
1546                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1547                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1548                 }
1549                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1550                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1551                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1552                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1553                 }
1554                 default: abort();
1555         }
1556 }
1557 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1558 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1559 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1560 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1561 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1562 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1563 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1564 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1565 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1566 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1567 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1568 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1569 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1570 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1571 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1572 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1573 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1574 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1575 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1576 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1577 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1578 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1579 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1580 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1581 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1582 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1583 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1584 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1585 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1586 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1587 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1588 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1589 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1590 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1591 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1592 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1593 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1594 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1596         LDKMessageSendEvent_SendAcceptChannel_class =
1597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1598         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1599         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1600         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1601         LDKMessageSendEvent_SendOpenChannel_class =
1602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1603         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1604         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1605         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1606         LDKMessageSendEvent_SendFundingCreated_class =
1607                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1608         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1609         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1610         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1611         LDKMessageSendEvent_SendFundingSigned_class =
1612                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1613         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1614         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1615         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1616         LDKMessageSendEvent_SendFundingLocked_class =
1617                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1618         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1619         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1620         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1621         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1623         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1624         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1625         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1626         LDKMessageSendEvent_UpdateHTLCs_class =
1627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1628         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1629         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1630         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1631         LDKMessageSendEvent_SendRevokeAndACK_class =
1632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1633         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1634         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1635         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1636         LDKMessageSendEvent_SendClosingSigned_class =
1637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1638         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1639         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1640         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1641         LDKMessageSendEvent_SendShutdown_class =
1642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1643         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1644         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1645         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1646         LDKMessageSendEvent_SendChannelReestablish_class =
1647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1648         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1649         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1650         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1651         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1653         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1654         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1655         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1656         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1658         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1659         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1660         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1661         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1663         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1664         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1665         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1666         LDKMessageSendEvent_HandleError_class =
1667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1668         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1669         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1670         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1671         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1673         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1674         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1675         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1676         LDKMessageSendEvent_SendChannelRangeQuery_class =
1677                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1678         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1679         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1680         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1681         LDKMessageSendEvent_SendShortIdsQuery_class =
1682                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1683         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1684         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1685         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1686         LDKMessageSendEvent_SendReplyChannelRange_class =
1687                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1688         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1689         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1690         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1691 }
1692 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1693         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1694         switch(obj->tag) {
1695                 case LDKMessageSendEvent_SendAcceptChannel: {
1696                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1697                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1698                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1699                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1700                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1701                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1702                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1703                 }
1704                 case LDKMessageSendEvent_SendOpenChannel: {
1705                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1706                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1707                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1708                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1709                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1710                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1711                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1712                 }
1713                 case LDKMessageSendEvent_SendFundingCreated: {
1714                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1715                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1716                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1717                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1718                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1719                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1720                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1721                 }
1722                 case LDKMessageSendEvent_SendFundingSigned: {
1723                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1724                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1725                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1726                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1727                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1728                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1729                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1730                 }
1731                 case LDKMessageSendEvent_SendFundingLocked: {
1732                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1733                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1734                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1735                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1736                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1737                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1738                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1739                 }
1740                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1741                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1742                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1743                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1744                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1745                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1746                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1747                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1748                 }
1749                 case LDKMessageSendEvent_UpdateHTLCs: {
1750                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1751                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1752                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1753                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1754                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1755                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1756                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1757                 }
1758                 case LDKMessageSendEvent_SendRevokeAndACK: {
1759                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1760                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1761                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1762                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1763                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1764                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1765                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1766                 }
1767                 case LDKMessageSendEvent_SendClosingSigned: {
1768                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1769                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1770                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1771                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1772                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1773                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1774                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1775                 }
1776                 case LDKMessageSendEvent_SendShutdown: {
1777                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1778                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1779                         LDKShutdown msg_var = obj->send_shutdown.msg;
1780                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1781                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1782                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1783                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1784                 }
1785                 case LDKMessageSendEvent_SendChannelReestablish: {
1786                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1787                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1788                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1789                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1790                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1791                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1792                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1793                 }
1794                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1795                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1796                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1797                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1798                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1799                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1800                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1801                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1802                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1803                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1804                 }
1805                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1806                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1807                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1808                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1809                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1810                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1811                 }
1812                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1813                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1814                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1815                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1816                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1817                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1818                 }
1819                 case LDKMessageSendEvent_HandleError: {
1820                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1821                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1822                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1823                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1824                 }
1825                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1826                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1827                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1828                 }
1829                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1830                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1831                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1832                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1833                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1834                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1835                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1836                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1837                 }
1838                 case LDKMessageSendEvent_SendShortIdsQuery: {
1839                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1840                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1841                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1842                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1843                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1844                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1845                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1846                 }
1847                 case LDKMessageSendEvent_SendReplyChannelRange: {
1848                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1849                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1850                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1851                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1852                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1853                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1854                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1855                 }
1856                 default: abort();
1857         }
1858 }
1859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1860         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1861         ret->datalen = (*env)->GetArrayLength(env, elems);
1862         if (ret->datalen == 0) {
1863                 ret->data = NULL;
1864         } else {
1865                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1866                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1867                 for (size_t i = 0; i < ret->datalen; i++) {
1868                         int64_t arr_elem = java_elems[i];
1869                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1870                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1871                         ret->data[i] = arr_elem_conv;
1872                 }
1873                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1874         }
1875         return (uint64_t)ret;
1876 }
1877 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1878         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1879         for (size_t i = 0; i < ret.datalen; i++) {
1880                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1881         }
1882         return ret;
1883 }
1884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1885         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1886 }
1887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1888         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1889         CHECK(val->result_ok);
1890         LDKInitFeatures res_var = (*val->contents.result);
1891         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1892         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1893         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1894         return res_ref;
1895 }
1896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1897         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1898         CHECK(!val->result_ok);
1899         LDKDecodeError err_var = (*val->contents.err);
1900         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1901         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1902         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1903         return err_ref;
1904 }
1905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1906         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1907 }
1908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1909         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1910         CHECK(val->result_ok);
1911         LDKNodeFeatures res_var = (*val->contents.result);
1912         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1913         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1914         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1915         return res_ref;
1916 }
1917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1918         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1919         CHECK(!val->result_ok);
1920         LDKDecodeError err_var = (*val->contents.err);
1921         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1922         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1923         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1924         return err_ref;
1925 }
1926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1927         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1928 }
1929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1930         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1931         CHECK(val->result_ok);
1932         LDKChannelFeatures res_var = (*val->contents.result);
1933         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1934         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1935         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1936         return res_ref;
1937 }
1938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1939         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1940         CHECK(!val->result_ok);
1941         LDKDecodeError err_var = (*val->contents.err);
1942         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1943         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1944         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1945         return err_ref;
1946 }
1947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1948         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1949 }
1950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1951         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1952         CHECK(val->result_ok);
1953         LDKInvoiceFeatures res_var = (*val->contents.result);
1954         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1955         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1956         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1957         return res_ref;
1958 }
1959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1960         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1961         CHECK(!val->result_ok);
1962         LDKDecodeError err_var = (*val->contents.err);
1963         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1964         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1965         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1966         return err_ref;
1967 }
1968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1969         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1970 }
1971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1972         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1973         CHECK(val->result_ok);
1974         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1975         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1976         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1977         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1978         return res_ref;
1979 }
1980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1981         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1982         CHECK(!val->result_ok);
1983         LDKDecodeError err_var = (*val->contents.err);
1984         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1985         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1986         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1987         return err_ref;
1988 }
1989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1990         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1991 }
1992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1993         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1994         CHECK(val->result_ok);
1995         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1996         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1997         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1998         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1999         return res_ref;
2000 }
2001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2002         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2003         CHECK(!val->result_ok);
2004         LDKDecodeError err_var = (*val->contents.err);
2005         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2006         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2007         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2008         return err_ref;
2009 }
2010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2011         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2012 }
2013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2014         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2015         CHECK(val->result_ok);
2016         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2017         return res_ref;
2018 }
2019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2020         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2021         CHECK(!val->result_ok);
2022         LDKDecodeError err_var = (*val->contents.err);
2023         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2024         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2025         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2026         return err_ref;
2027 }
2028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2029         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2030         LDKSignature a_ref;
2031         CHECK((*env)->GetArrayLength(env, a) == 64);
2032         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2033         ret->a = a_ref;
2034         LDKCVec_SignatureZ b_constr;
2035         b_constr.datalen = (*env)->GetArrayLength(env, b);
2036         if (b_constr.datalen > 0)
2037                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2038         else
2039                 b_constr.data = NULL;
2040         for (size_t i = 0; i < b_constr.datalen; i++) {
2041                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2042                 LDKSignature b_conv_8_ref;
2043                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2044                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2045                 b_constr.data[i] = b_conv_8_ref;
2046         }
2047         ret->b = b_constr;
2048         return (uint64_t)ret;
2049 }
2050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2051         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2052         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2053         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2054         return a_arr;
2055 }
2056 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2057         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2058         LDKCVec_SignatureZ b_var = tuple->b;
2059         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2060         ;
2061         for (size_t i = 0; i < b_var.datalen; i++) {
2062                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2063                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2064                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2065         }
2066         return b_arr;
2067 }
2068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2069         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2070 }
2071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2072         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2073         CHECK(val->result_ok);
2074         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2075         return res_ref;
2076 }
2077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2078         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2079         CHECK(!val->result_ok);
2080         return *val->contents.err;
2081 }
2082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2083         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2084 }
2085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2086         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2087         CHECK(val->result_ok);
2088         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2089         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2090         return res_arr;
2091 }
2092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2093         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2094         CHECK(!val->result_ok);
2095         return *val->contents.err;
2096 }
2097 typedef struct LDKBaseSign_JCalls {
2098         atomic_size_t refcnt;
2099         JavaVM *vm;
2100         jweak o;
2101         jmethodID get_per_commitment_point_meth;
2102         jmethodID release_commitment_secret_meth;
2103         jmethodID channel_keys_id_meth;
2104         jmethodID sign_counterparty_commitment_meth;
2105         jmethodID sign_holder_commitment_and_htlcs_meth;
2106         jmethodID sign_justice_revoked_output_meth;
2107         jmethodID sign_justice_revoked_htlc_meth;
2108         jmethodID sign_counterparty_htlc_transaction_meth;
2109         jmethodID sign_closing_transaction_meth;
2110         jmethodID sign_channel_announcement_meth;
2111         jmethodID ready_channel_meth;
2112 } LDKBaseSign_JCalls;
2113 static void LDKBaseSign_JCalls_free(void* this_arg) {
2114         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2115         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2116                 JNIEnv *env;
2117                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2118                 if (get_jenv_res == JNI_EDETACHED) {
2119                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2120                 } else {
2121                         DO_ASSERT(get_jenv_res == JNI_OK);
2122                 }
2123                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2124                 if (get_jenv_res == JNI_EDETACHED) {
2125                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2126                 }
2127                 FREE(j_calls);
2128         }
2129 }
2130 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2131         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2132         JNIEnv *env;
2133         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2134         if (get_jenv_res == JNI_EDETACHED) {
2135                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2136         } else {
2137                 DO_ASSERT(get_jenv_res == JNI_OK);
2138         }
2139         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2140         CHECK(obj != NULL);
2141         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2142         LDKPublicKey ret_ref;
2143         CHECK((*env)->GetArrayLength(env, ret) == 33);
2144         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2145         if (get_jenv_res == JNI_EDETACHED) {
2146                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2147         }
2148         return ret_ref;
2149 }
2150 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2151         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2152         JNIEnv *env;
2153         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2154         if (get_jenv_res == JNI_EDETACHED) {
2155                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2156         } else {
2157                 DO_ASSERT(get_jenv_res == JNI_OK);
2158         }
2159         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2160         CHECK(obj != NULL);
2161         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2162         LDKThirtyTwoBytes ret_ref;
2163         CHECK((*env)->GetArrayLength(env, ret) == 32);
2164         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2165         if (get_jenv_res == JNI_EDETACHED) {
2166                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2167         }
2168         return ret_ref;
2169 }
2170 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2171         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2172         JNIEnv *env;
2173         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2174         if (get_jenv_res == JNI_EDETACHED) {
2175                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2176         } else {
2177                 DO_ASSERT(get_jenv_res == JNI_OK);
2178         }
2179         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2180         CHECK(obj != NULL);
2181         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2182         LDKThirtyTwoBytes ret_ref;
2183         CHECK((*env)->GetArrayLength(env, ret) == 32);
2184         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2185         if (get_jenv_res == JNI_EDETACHED) {
2186                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2187         }
2188         return ret_ref;
2189 }
2190 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2191         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2192         JNIEnv *env;
2193         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2194         if (get_jenv_res == JNI_EDETACHED) {
2195                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2196         } else {
2197                 DO_ASSERT(get_jenv_res == JNI_OK);
2198         }
2199         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2200         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2201         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2202         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2203         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2204         if (commitment_tx_var.is_owned) {
2205                 commitment_tx_ref |= 1;
2206         }
2207         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2208         CHECK(obj != NULL);
2209         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2210         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2211         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2212         if (get_jenv_res == JNI_EDETACHED) {
2213                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2214         }
2215         return ret_conv;
2216 }
2217 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2218         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2219         JNIEnv *env;
2220         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2221         if (get_jenv_res == JNI_EDETACHED) {
2222                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2223         } else {
2224                 DO_ASSERT(get_jenv_res == JNI_OK);
2225         }
2226         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2227         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2228         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2229         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2230         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2231         if (commitment_tx_var.is_owned) {
2232                 commitment_tx_ref |= 1;
2233         }
2234         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2235         CHECK(obj != NULL);
2236         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2237         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2238         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2239         if (get_jenv_res == JNI_EDETACHED) {
2240                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2241         }
2242         return ret_conv;
2243 }
2244 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]) {
2245         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2246         JNIEnv *env;
2247         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2248         if (get_jenv_res == JNI_EDETACHED) {
2249                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2250         } else {
2251                 DO_ASSERT(get_jenv_res == JNI_OK);
2252         }
2253         LDKTransaction justice_tx_var = justice_tx;
2254         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2255         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2256         Transaction_free(justice_tx_var);
2257         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2258         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2259         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2260         CHECK(obj != NULL);
2261         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2262         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2263         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2264         if (get_jenv_res == JNI_EDETACHED) {
2265                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2266         }
2267         return ret_conv;
2268 }
2269 LDKCResult_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) {
2270         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2271         JNIEnv *env;
2272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2273         if (get_jenv_res == JNI_EDETACHED) {
2274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2275         } else {
2276                 DO_ASSERT(get_jenv_res == JNI_OK);
2277         }
2278         LDKTransaction justice_tx_var = justice_tx;
2279         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2280         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2281         Transaction_free(justice_tx_var);
2282         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2283         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2284         LDKHTLCOutputInCommitment htlc_var = *htlc;
2285         htlc_var = HTLCOutputInCommitment_clone(htlc);
2286         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2287         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2288         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2289         if (htlc_var.is_owned) {
2290                 htlc_ref |= 1;
2291         }
2292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2293         CHECK(obj != NULL);
2294         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2295         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2296         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2297         if (get_jenv_res == JNI_EDETACHED) {
2298                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2299         }
2300         return ret_conv;
2301 }
2302 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) {
2303         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2304         JNIEnv *env;
2305         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2306         if (get_jenv_res == JNI_EDETACHED) {
2307                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2308         } else {
2309                 DO_ASSERT(get_jenv_res == JNI_OK);
2310         }
2311         LDKTransaction htlc_tx_var = htlc_tx;
2312         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2313         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2314         Transaction_free(htlc_tx_var);
2315         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2316         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2317         LDKHTLCOutputInCommitment htlc_var = *htlc;
2318         htlc_var = HTLCOutputInCommitment_clone(htlc);
2319         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2320         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2321         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2322         if (htlc_var.is_owned) {
2323                 htlc_ref |= 1;
2324         }
2325         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2326         CHECK(obj != NULL);
2327         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2328         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2329         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2330         if (get_jenv_res == JNI_EDETACHED) {
2331                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2332         }
2333         return ret_conv;
2334 }
2335 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2336         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2337         JNIEnv *env;
2338         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2339         if (get_jenv_res == JNI_EDETACHED) {
2340                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2341         } else {
2342                 DO_ASSERT(get_jenv_res == JNI_OK);
2343         }
2344         LDKTransaction closing_tx_var = closing_tx;
2345         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2346         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2347         Transaction_free(closing_tx_var);
2348         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2349         CHECK(obj != NULL);
2350         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2351         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2352         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2353         if (get_jenv_res == JNI_EDETACHED) {
2354                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2355         }
2356         return ret_conv;
2357 }
2358 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2359         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2360         JNIEnv *env;
2361         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2362         if (get_jenv_res == JNI_EDETACHED) {
2363                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2364         } else {
2365                 DO_ASSERT(get_jenv_res == JNI_OK);
2366         }
2367         LDKUnsignedChannelAnnouncement msg_var = *msg;
2368         msg_var = UnsignedChannelAnnouncement_clone(msg);
2369         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2370         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2371         uint64_t msg_ref = (uint64_t)msg_var.inner;
2372         if (msg_var.is_owned) {
2373                 msg_ref |= 1;
2374         }
2375         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2376         CHECK(obj != NULL);
2377         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2378         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2379         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2380         if (get_jenv_res == JNI_EDETACHED) {
2381                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2382         }
2383         return ret_conv;
2384 }
2385 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2386         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2387         JNIEnv *env;
2388         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2389         if (get_jenv_res == JNI_EDETACHED) {
2390                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2391         } else {
2392                 DO_ASSERT(get_jenv_res == JNI_OK);
2393         }
2394         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2395         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2396         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2397         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2398         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2399         if (channel_parameters_var.is_owned) {
2400                 channel_parameters_ref |= 1;
2401         }
2402         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2403         CHECK(obj != NULL);
2404         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2405         if (get_jenv_res == JNI_EDETACHED) {
2406                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2407         }
2408 }
2409 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
2410         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2411         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2412         return (void*) this_arg;
2413 }
2414 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2415         jclass c = (*env)->GetObjectClass(env, o);
2416         CHECK(c != NULL);
2417         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2418         atomic_init(&calls->refcnt, 1);
2419         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2420         calls->o = (*env)->NewWeakGlobalRef(env, o);
2421         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2422         CHECK(calls->get_per_commitment_point_meth != NULL);
2423         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2424         CHECK(calls->release_commitment_secret_meth != NULL);
2425         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2426         CHECK(calls->channel_keys_id_meth != NULL);
2427         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2428         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2429         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2430         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2431         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2432         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2433         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2434         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2435         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2436         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2437         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2438         CHECK(calls->sign_closing_transaction_meth != NULL);
2439         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2440         CHECK(calls->sign_channel_announcement_meth != NULL);
2441         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2442         CHECK(calls->ready_channel_meth != NULL);
2443
2444         LDKChannelPublicKeys pubkeys_conv;
2445         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2446         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2447         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2448
2449         LDKBaseSign ret = {
2450                 .this_arg = (void*) calls,
2451                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2452                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2453                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2454                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2455                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2456                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2457                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2458                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2459                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2460                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2461                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2462                 .free = LDKBaseSign_JCalls_free,
2463                 .pubkeys = pubkeys_conv,
2464                 .set_pubkeys = NULL,
2465         };
2466         return ret;
2467 }
2468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2469         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2470         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2471         return (uint64_t)res_ptr;
2472 }
2473 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) {
2474         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2475         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2476         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2477         return ret_arr;
2478 }
2479
2480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2481         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2482         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2483         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2484         return ret_arr;
2485 }
2486
2487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2488         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2489         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2490         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2491         return ret_arr;
2492 }
2493
2494 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) {
2495         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2496         LDKCommitmentTransaction commitment_tx_conv;
2497         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2498         commitment_tx_conv.is_owned = false;
2499         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2500         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2501         return (uint64_t)ret_conv;
2502 }
2503
2504 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) {
2505         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2506         LDKHolderCommitmentTransaction commitment_tx_conv;
2507         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2508         commitment_tx_conv.is_owned = false;
2509         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2510         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2511         return (uint64_t)ret_conv;
2512 }
2513
2514 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) {
2515         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2516         LDKTransaction justice_tx_ref;
2517         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2518         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2519         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2520         justice_tx_ref.data_is_owned = true;
2521         unsigned char per_commitment_key_arr[32];
2522         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2523         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2524         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2525         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2526         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2527         return (uint64_t)ret_conv;
2528 }
2529
2530 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) {
2531         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2532         LDKTransaction justice_tx_ref;
2533         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2534         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2535         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2536         justice_tx_ref.data_is_owned = true;
2537         unsigned char per_commitment_key_arr[32];
2538         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2539         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2540         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2541         LDKHTLCOutputInCommitment htlc_conv;
2542         htlc_conv.inner = (void*)(htlc & (~1));
2543         htlc_conv.is_owned = false;
2544         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2545         *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);
2546         return (uint64_t)ret_conv;
2547 }
2548
2549 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) {
2550         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2551         LDKTransaction htlc_tx_ref;
2552         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2553         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2554         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2555         htlc_tx_ref.data_is_owned = true;
2556         LDKPublicKey per_commitment_point_ref;
2557         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2558         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2559         LDKHTLCOutputInCommitment htlc_conv;
2560         htlc_conv.inner = (void*)(htlc & (~1));
2561         htlc_conv.is_owned = false;
2562         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2563         *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);
2564         return (uint64_t)ret_conv;
2565 }
2566
2567 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) {
2568         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2569         LDKTransaction closing_tx_ref;
2570         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2571         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2572         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2573         closing_tx_ref.data_is_owned = true;
2574         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2575         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2576         return (uint64_t)ret_conv;
2577 }
2578
2579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2580         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2581         LDKUnsignedChannelAnnouncement msg_conv;
2582         msg_conv.inner = (void*)(msg & (~1));
2583         msg_conv.is_owned = false;
2584         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2585         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2586         return (uint64_t)ret_conv;
2587 }
2588
2589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2590         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2591         LDKChannelTransactionParameters channel_parameters_conv;
2592         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2593         channel_parameters_conv.is_owned = false;
2594         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2595 }
2596
2597 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2598         if (this_arg->set_pubkeys != NULL)
2599                 this_arg->set_pubkeys(this_arg);
2600         return this_arg->pubkeys;
2601 }
2602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2603         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2604         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2607         uint64_t ret_ref = (uint64_t)ret_var.inner;
2608         if (ret_var.is_owned) {
2609                 ret_ref |= 1;
2610         }
2611         return ret_ref;
2612 }
2613
2614 typedef struct LDKSign_JCalls {
2615         atomic_size_t refcnt;
2616         JavaVM *vm;
2617         jweak o;
2618         LDKBaseSign_JCalls* BaseSign;
2619         jmethodID write_meth;
2620 } LDKSign_JCalls;
2621 static void LDKSign_JCalls_free(void* this_arg) {
2622         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2623         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2624                 JNIEnv *env;
2625                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2626                 if (get_jenv_res == JNI_EDETACHED) {
2627                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2628                 } else {
2629                         DO_ASSERT(get_jenv_res == JNI_OK);
2630                 }
2631                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2632                 if (get_jenv_res == JNI_EDETACHED) {
2633                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2634                 }
2635                 FREE(j_calls);
2636         }
2637 }
2638 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2639         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2640         JNIEnv *env;
2641         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2642         if (get_jenv_res == JNI_EDETACHED) {
2643                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2644         } else {
2645                 DO_ASSERT(get_jenv_res == JNI_OK);
2646         }
2647         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2648         CHECK(obj != NULL);
2649         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2650         LDKCVec_u8Z ret_ref;
2651         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2652         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2653         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2654         if (get_jenv_res == JNI_EDETACHED) {
2655                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2656         }
2657         return ret_ref;
2658 }
2659 static void* LDKSign_JCalls_clone(const void* this_arg) {
2660         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2661         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2662         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2663         return (void*) this_arg;
2664 }
2665 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2666         jclass c = (*env)->GetObjectClass(env, o);
2667         CHECK(c != NULL);
2668         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2669         atomic_init(&calls->refcnt, 1);
2670         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2671         calls->o = (*env)->NewWeakGlobalRef(env, o);
2672         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2673         CHECK(calls->write_meth != NULL);
2674
2675         LDKChannelPublicKeys pubkeys_conv;
2676         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2677         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2678         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2679
2680         LDKSign ret = {
2681                 .this_arg = (void*) calls,
2682                 .write = write_LDKSign_jcall,
2683                 .clone = LDKSign_JCalls_clone,
2684                 .free = LDKSign_JCalls_free,
2685                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2686         };
2687         calls->BaseSign = ret.BaseSign.this_arg;
2688         return ret;
2689 }
2690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2691         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2692         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2693         return (uint64_t)res_ptr;
2694 }
2695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2696         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2697         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2698         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2699         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2700         CVec_u8Z_free(ret_var);
2701         return ret_arr;
2702 }
2703
2704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2705         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2706 }
2707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2708         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2709         CHECK(val->result_ok);
2710         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2711         *ret = Sign_clone(&(*val->contents.result));
2712         return (uint64_t)ret;
2713 }
2714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2715         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2716         CHECK(!val->result_ok);
2717         LDKDecodeError err_var = (*val->contents.err);
2718         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2719         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2720         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2721         return err_ref;
2722 }
2723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2724         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2725 }
2726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2727         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2728         CHECK(val->result_ok);
2729         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2730         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2731         return es_arr;
2732 }
2733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2734         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2735         CHECK(!val->result_ok);
2736         return *val->contents.err;
2737 }
2738 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2739         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2740         for (size_t i = 0; i < ret.datalen; i++) {
2741                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2742         }
2743         return ret;
2744 }
2745 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2746         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2747 }
2748 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2749         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2750         CHECK(val->result_ok);
2751         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2752         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2753         ;
2754         for (size_t i = 0; i < res_var.datalen; i++) {
2755                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2756                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2757                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2758                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2759         }
2760         return res_arr;
2761 }
2762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2763         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2764         CHECK(!val->result_ok);
2765         return *val->contents.err;
2766 }
2767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2768         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2769 }
2770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2771         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2772         CHECK(val->result_ok);
2773         LDKInMemorySigner res_var = (*val->contents.result);
2774         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2775         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2776         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2777         return res_ref;
2778 }
2779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2780         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2781         CHECK(!val->result_ok);
2782         LDKDecodeError err_var = (*val->contents.err);
2783         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2784         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2785         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2786         return err_ref;
2787 }
2788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2789         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2790         ret->datalen = (*env)->GetArrayLength(env, elems);
2791         if (ret->datalen == 0) {
2792                 ret->data = NULL;
2793         } else {
2794                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2795                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2796                 for (size_t i = 0; i < ret->datalen; i++) {
2797                         int64_t arr_elem = java_elems[i];
2798                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2799                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2800                         ret->data[i] = arr_elem_conv;
2801                 }
2802                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2803         }
2804         return (uint64_t)ret;
2805 }
2806 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2807         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2808         for (size_t i = 0; i < ret.datalen; i++) {
2809                 ret.data[i] = TxOut_clone(&orig->data[i]);
2810         }
2811         return ret;
2812 }
2813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2814         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2815 }
2816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2817         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2818         CHECK(val->result_ok);
2819         LDKTransaction res_var = (*val->contents.result);
2820         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2821         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2822         return res_arr;
2823 }
2824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2825         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2826         CHECK(!val->result_ok);
2827         return *val->contents.err;
2828 }
2829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2830         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2831         LDKThirtyTwoBytes a_ref;
2832         CHECK((*env)->GetArrayLength(env, a) == 32);
2833         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2834         ret->a = a_ref;
2835         LDKChannelMonitor b_conv;
2836         b_conv.inner = (void*)(b & (~1));
2837         b_conv.is_owned = (b & 1) || (b == 0);
2838         b_conv = ChannelMonitor_clone(&b_conv);
2839         ret->b = b_conv;
2840         return (uint64_t)ret;
2841 }
2842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2843         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2844         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2845         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2846         return a_arr;
2847 }
2848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2849         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2850         LDKChannelMonitor b_var = tuple->b;
2851         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2852         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2853         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2854         return b_ref;
2855 }
2856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2857         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2858         ret->datalen = (*env)->GetArrayLength(env, elems);
2859         if (ret->datalen == 0) {
2860                 ret->data = NULL;
2861         } else {
2862                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2863                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2864                 for (size_t i = 0; i < ret->datalen; i++) {
2865                         int64_t arr_elem = java_elems[i];
2866                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2867                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2868                         ret->data[i] = arr_elem_conv;
2869                 }
2870                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2871         }
2872         return (uint64_t)ret;
2873 }
2874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2875         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2876 }
2877 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2878         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2879         CHECK(val->result_ok);
2880         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2881         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2882         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2883         for (size_t i = 0; i < res_var.datalen; i++) {
2884                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2885                 res_arr_ptr[i] = res_conv_34_ref;
2886         }
2887         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2888         return res_arr;
2889 }
2890 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2891         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2892         CHECK(!val->result_ok);
2893         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2894         return err_conv;
2895 }
2896 static jclass LDKAPIError_APIMisuseError_class = NULL;
2897 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
2898 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
2899 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
2900 static jclass LDKAPIError_RouteError_class = NULL;
2901 static jmethodID LDKAPIError_RouteError_meth = NULL;
2902 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
2903 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
2904 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
2905 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
2906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
2907         LDKAPIError_APIMisuseError_class =
2908                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
2909         CHECK(LDKAPIError_APIMisuseError_class != NULL);
2910         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
2911         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
2912         LDKAPIError_FeeRateTooHigh_class =
2913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
2914         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
2915         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
2916         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
2917         LDKAPIError_RouteError_class =
2918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
2919         CHECK(LDKAPIError_RouteError_class != NULL);
2920         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
2921         CHECK(LDKAPIError_RouteError_meth != NULL);
2922         LDKAPIError_ChannelUnavailable_class =
2923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
2924         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
2925         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
2926         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
2927         LDKAPIError_MonitorUpdateFailed_class =
2928                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
2929         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
2930         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
2931         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
2932 }
2933 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2934         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2935         switch(obj->tag) {
2936                 case LDKAPIError_APIMisuseError: {
2937                         LDKStr err_str = obj->api_misuse_error.err;
2938                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2939                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
2940                 }
2941                 case LDKAPIError_FeeRateTooHigh: {
2942                         LDKStr err_str = obj->fee_rate_too_high.err;
2943                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2944                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
2945                 }
2946                 case LDKAPIError_RouteError: {
2947                         LDKStr err_str = obj->route_error.err;
2948                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2949                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
2950                 }
2951                 case LDKAPIError_ChannelUnavailable: {
2952                         LDKStr err_str = obj->channel_unavailable.err;
2953                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2954                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
2955                 }
2956                 case LDKAPIError_MonitorUpdateFailed: {
2957                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
2958                 }
2959                 default: abort();
2960         }
2961 }
2962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2963         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2964 }
2965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2966         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2967         CHECK(val->result_ok);
2968         return *val->contents.result;
2969 }
2970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2971         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2972         CHECK(!val->result_ok);
2973         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2974         return err_ref;
2975 }
2976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2977         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2978         ret->datalen = (*env)->GetArrayLength(env, elems);
2979         if (ret->datalen == 0) {
2980                 ret->data = NULL;
2981         } else {
2982                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2983                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2984                 for (size_t i = 0; i < ret->datalen; i++) {
2985                         int64_t arr_elem = java_elems[i];
2986                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2987                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2988                         ret->data[i] = arr_elem_conv;
2989                 }
2990                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2991         }
2992         return (uint64_t)ret;
2993 }
2994 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2995         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2996         for (size_t i = 0; i < ret.datalen; i++) {
2997                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2998         }
2999         return ret;
3000 }
3001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3002         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3003         ret->datalen = (*env)->GetArrayLength(env, elems);
3004         if (ret->datalen == 0) {
3005                 ret->data = NULL;
3006         } else {
3007                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3008                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3009                 for (size_t i = 0; i < ret->datalen; i++) {
3010                         int64_t arr_elem = java_elems[i];
3011                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3012                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3013                         ret->data[i] = arr_elem_conv;
3014                 }
3015                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3016         }
3017         return (uint64_t)ret;
3018 }
3019 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3020         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3021         for (size_t i = 0; i < ret.datalen; i++) {
3022                 ret.data[i] = APIError_clone(&orig->data[i]);
3023         }
3024         return ret;
3025 }
3026 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3027 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3028 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3029 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3030 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3031 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3032 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3033 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3035         LDKPaymentSendFailure_ParameterError_class =
3036                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3037         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3038         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3039         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3040         LDKPaymentSendFailure_PathParameterError_class =
3041                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3042         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3043         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3044         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3045         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3046                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3047         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3048         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3049         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3050         LDKPaymentSendFailure_PartialFailure_class =
3051                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3052         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3053         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3054         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3055 }
3056 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3057         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3058         switch(obj->tag) {
3059                 case LDKPaymentSendFailure_ParameterError: {
3060                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3061                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3062                 }
3063                 case LDKPaymentSendFailure_PathParameterError: {
3064                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3065                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3066                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3067                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3068                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3069                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3070                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3071                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3072                         }
3073                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3074                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3075                 }
3076                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3077                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3078                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3079                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3080                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3081                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3082                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3083                         }
3084                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3085                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3086                 }
3087                 case LDKPaymentSendFailure_PartialFailure: {
3088                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3089                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3090                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3091                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3092                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3093                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3094                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3095                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3096                         }
3097                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3098                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3099                 }
3100                 default: abort();
3101         }
3102 }
3103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3104         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3105 }
3106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3107         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3108         CHECK(val->result_ok);
3109         return *val->contents.result;
3110 }
3111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3112         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3113         CHECK(!val->result_ok);
3114         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3115         return err_ref;
3116 }
3117 static jclass LDKNetAddress_IPv4_class = NULL;
3118 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3119 static jclass LDKNetAddress_IPv6_class = NULL;
3120 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3121 static jclass LDKNetAddress_OnionV2_class = NULL;
3122 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3123 static jclass LDKNetAddress_OnionV3_class = NULL;
3124 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3126         LDKNetAddress_IPv4_class =
3127                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3128         CHECK(LDKNetAddress_IPv4_class != NULL);
3129         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3130         CHECK(LDKNetAddress_IPv4_meth != NULL);
3131         LDKNetAddress_IPv6_class =
3132                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3133         CHECK(LDKNetAddress_IPv6_class != NULL);
3134         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3135         CHECK(LDKNetAddress_IPv6_meth != NULL);
3136         LDKNetAddress_OnionV2_class =
3137                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3138         CHECK(LDKNetAddress_OnionV2_class != NULL);
3139         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3140         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3141         LDKNetAddress_OnionV3_class =
3142                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3143         CHECK(LDKNetAddress_OnionV3_class != NULL);
3144         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3145         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3146 }
3147 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3148         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3149         switch(obj->tag) {
3150                 case LDKNetAddress_IPv4: {
3151                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3152                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3153                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3154                 }
3155                 case LDKNetAddress_IPv6: {
3156                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3157                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3158                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3159                 }
3160                 case LDKNetAddress_OnionV2: {
3161                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3162                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3163                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3164                 }
3165                 case LDKNetAddress_OnionV3: {
3166                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3167                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3168                         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);
3169                 }
3170                 default: abort();
3171         }
3172 }
3173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3174         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3175         ret->datalen = (*env)->GetArrayLength(env, elems);
3176         if (ret->datalen == 0) {
3177                 ret->data = NULL;
3178         } else {
3179                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3180                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3181                 for (size_t i = 0; i < ret->datalen; i++) {
3182                         int64_t arr_elem = java_elems[i];
3183                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3184                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3185                         ret->data[i] = arr_elem_conv;
3186                 }
3187                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3188         }
3189         return (uint64_t)ret;
3190 }
3191 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3192         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3193         for (size_t i = 0; i < ret.datalen; i++) {
3194                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3195         }
3196         return ret;
3197 }
3198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3199         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3200         LDKThirtyTwoBytes a_ref;
3201         CHECK((*env)->GetArrayLength(env, a) == 32);
3202         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3203         ret->a = a_ref;
3204         LDKThirtyTwoBytes b_ref;
3205         CHECK((*env)->GetArrayLength(env, b) == 32);
3206         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3207         ret->b = b_ref;
3208         return (uint64_t)ret;
3209 }
3210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3211         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3212         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3213         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3214         return a_arr;
3215 }
3216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3217         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3218         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3219         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3220         return b_arr;
3221 }
3222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3223         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3224 }
3225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3226         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3227         CHECK(val->result_ok);
3228         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3229         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3230         return res_arr;
3231 }
3232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3233         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3234         CHECK(!val->result_ok);
3235         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3236         return err_ref;
3237 }
3238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3239         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3240         ret->datalen = (*env)->GetArrayLength(env, elems);
3241         if (ret->datalen == 0) {
3242                 ret->data = NULL;
3243         } else {
3244                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3245                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3246                 for (size_t i = 0; i < ret->datalen; i++) {
3247                         int64_t arr_elem = java_elems[i];
3248                         LDKChannelMonitor arr_elem_conv;
3249                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3250                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3251                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3252                         ret->data[i] = arr_elem_conv;
3253                 }
3254                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3255         }
3256         return (uint64_t)ret;
3257 }
3258 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3259         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3260         for (size_t i = 0; i < ret.datalen; i++) {
3261                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3262         }
3263         return ret;
3264 }
3265 typedef struct LDKWatch_JCalls {
3266         atomic_size_t refcnt;
3267         JavaVM *vm;
3268         jweak o;
3269         jmethodID watch_channel_meth;
3270         jmethodID update_channel_meth;
3271         jmethodID release_pending_monitor_events_meth;
3272 } LDKWatch_JCalls;
3273 static void LDKWatch_JCalls_free(void* this_arg) {
3274         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3275         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3276                 JNIEnv *env;
3277                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3278                 if (get_jenv_res == JNI_EDETACHED) {
3279                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3280                 } else {
3281                         DO_ASSERT(get_jenv_res == JNI_OK);
3282                 }
3283                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3284                 if (get_jenv_res == JNI_EDETACHED) {
3285                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3286                 }
3287                 FREE(j_calls);
3288         }
3289 }
3290 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3291         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3292         JNIEnv *env;
3293         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3294         if (get_jenv_res == JNI_EDETACHED) {
3295                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3296         } else {
3297                 DO_ASSERT(get_jenv_res == JNI_OK);
3298         }
3299         LDKOutPoint funding_txo_var = funding_txo;
3300         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3301         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3302         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3303         if (funding_txo_var.is_owned) {
3304                 funding_txo_ref |= 1;
3305         }
3306         LDKChannelMonitor monitor_var = monitor;
3307         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3308         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3309         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3310         if (monitor_var.is_owned) {
3311                 monitor_ref |= 1;
3312         }
3313         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3314         CHECK(obj != NULL);
3315         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3316         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3317         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3318         if (get_jenv_res == JNI_EDETACHED) {
3319                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3320         }
3321         return ret_conv;
3322 }
3323 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3324         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3325         JNIEnv *env;
3326         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3327         if (get_jenv_res == JNI_EDETACHED) {
3328                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3329         } else {
3330                 DO_ASSERT(get_jenv_res == JNI_OK);
3331         }
3332         LDKOutPoint funding_txo_var = funding_txo;
3333         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3334         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3335         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3336         if (funding_txo_var.is_owned) {
3337                 funding_txo_ref |= 1;
3338         }
3339         LDKChannelMonitorUpdate update_var = update;
3340         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3341         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3342         uint64_t update_ref = (uint64_t)update_var.inner;
3343         if (update_var.is_owned) {
3344                 update_ref |= 1;
3345         }
3346         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3347         CHECK(obj != NULL);
3348         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3349         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3350         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3351         if (get_jenv_res == JNI_EDETACHED) {
3352                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3353         }
3354         return ret_conv;
3355 }
3356 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3357         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3358         JNIEnv *env;
3359         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3360         if (get_jenv_res == JNI_EDETACHED) {
3361                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3362         } else {
3363                 DO_ASSERT(get_jenv_res == JNI_OK);
3364         }
3365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3366         CHECK(obj != NULL);
3367         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3368         LDKCVec_MonitorEventZ ret_constr;
3369         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3370         if (ret_constr.datalen > 0)
3371                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3372         else
3373                 ret_constr.data = NULL;
3374         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3375         for (size_t o = 0; o < ret_constr.datalen; o++) {
3376                 int64_t ret_conv_14 = ret_vals[o];
3377                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3378                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3379                 ret_constr.data[o] = ret_conv_14_conv;
3380         }
3381         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3382         if (get_jenv_res == JNI_EDETACHED) {
3383                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3384         }
3385         return ret_constr;
3386 }
3387 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3388         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3389         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3390         return (void*) this_arg;
3391 }
3392 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3393         jclass c = (*env)->GetObjectClass(env, o);
3394         CHECK(c != NULL);
3395         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3396         atomic_init(&calls->refcnt, 1);
3397         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3398         calls->o = (*env)->NewWeakGlobalRef(env, o);
3399         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3400         CHECK(calls->watch_channel_meth != NULL);
3401         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3402         CHECK(calls->update_channel_meth != NULL);
3403         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3404         CHECK(calls->release_pending_monitor_events_meth != NULL);
3405
3406         LDKWatch ret = {
3407                 .this_arg = (void*) calls,
3408                 .watch_channel = watch_channel_LDKWatch_jcall,
3409                 .update_channel = update_channel_LDKWatch_jcall,
3410                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3411                 .free = LDKWatch_JCalls_free,
3412         };
3413         return ret;
3414 }
3415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3416         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3417         *res_ptr = LDKWatch_init(env, clz, o);
3418         return (uint64_t)res_ptr;
3419 }
3420 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) {
3421         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3422         LDKOutPoint funding_txo_conv;
3423         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3424         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3425         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3426         LDKChannelMonitor monitor_conv;
3427         monitor_conv.inner = (void*)(monitor & (~1));
3428         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3429         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3430         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3431         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3432         return (uint64_t)ret_conv;
3433 }
3434
3435 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) {
3436         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3437         LDKOutPoint funding_txo_conv;
3438         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3439         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3440         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3441         LDKChannelMonitorUpdate update_conv;
3442         update_conv.inner = (void*)(update & (~1));
3443         update_conv.is_owned = (update & 1) || (update == 0);
3444         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3445         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3446         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3447         return (uint64_t)ret_conv;
3448 }
3449
3450 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3451         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3452         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3453         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3454         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3455         for (size_t o = 0; o < ret_var.datalen; o++) {
3456                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3457                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3458                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3459                 ret_arr_ptr[o] = ret_conv_14_ref;
3460         }
3461         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3462         FREE(ret_var.data);
3463         return ret_arr;
3464 }
3465
3466 typedef struct LDKBroadcasterInterface_JCalls {
3467         atomic_size_t refcnt;
3468         JavaVM *vm;
3469         jweak o;
3470         jmethodID broadcast_transaction_meth;
3471 } LDKBroadcasterInterface_JCalls;
3472 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3473         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3474         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3475                 JNIEnv *env;
3476                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3477                 if (get_jenv_res == JNI_EDETACHED) {
3478                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3479                 } else {
3480                         DO_ASSERT(get_jenv_res == JNI_OK);
3481                 }
3482                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3483                 if (get_jenv_res == JNI_EDETACHED) {
3484                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3485                 }
3486                 FREE(j_calls);
3487         }
3488 }
3489 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3490         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3491         JNIEnv *env;
3492         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3493         if (get_jenv_res == JNI_EDETACHED) {
3494                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3495         } else {
3496                 DO_ASSERT(get_jenv_res == JNI_OK);
3497         }
3498         LDKTransaction tx_var = tx;
3499         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3500         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3501         Transaction_free(tx_var);
3502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3503         CHECK(obj != NULL);
3504         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3505         if (get_jenv_res == JNI_EDETACHED) {
3506                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3507         }
3508 }
3509 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3510         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3511         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3512         return (void*) this_arg;
3513 }
3514 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3515         jclass c = (*env)->GetObjectClass(env, o);
3516         CHECK(c != NULL);
3517         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3518         atomic_init(&calls->refcnt, 1);
3519         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3520         calls->o = (*env)->NewWeakGlobalRef(env, o);
3521         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3522         CHECK(calls->broadcast_transaction_meth != NULL);
3523
3524         LDKBroadcasterInterface ret = {
3525                 .this_arg = (void*) calls,
3526                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3527                 .free = LDKBroadcasterInterface_JCalls_free,
3528         };
3529         return ret;
3530 }
3531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3532         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3533         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3534         return (uint64_t)res_ptr;
3535 }
3536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3537         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3538         LDKTransaction tx_ref;
3539         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3540         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3541         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3542         tx_ref.data_is_owned = true;
3543         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3544 }
3545
3546 typedef struct LDKKeysInterface_JCalls {
3547         atomic_size_t refcnt;
3548         JavaVM *vm;
3549         jweak o;
3550         jmethodID get_node_secret_meth;
3551         jmethodID get_destination_script_meth;
3552         jmethodID get_shutdown_pubkey_meth;
3553         jmethodID get_channel_signer_meth;
3554         jmethodID get_secure_random_bytes_meth;
3555         jmethodID read_chan_signer_meth;
3556         jmethodID sign_invoice_meth;
3557 } LDKKeysInterface_JCalls;
3558 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3559         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3560         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3561                 JNIEnv *env;
3562                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3563                 if (get_jenv_res == JNI_EDETACHED) {
3564                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3565                 } else {
3566                         DO_ASSERT(get_jenv_res == JNI_OK);
3567                 }
3568                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3569                 if (get_jenv_res == JNI_EDETACHED) {
3570                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3571                 }
3572                 FREE(j_calls);
3573         }
3574 }
3575 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3576         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3577         JNIEnv *env;
3578         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3579         if (get_jenv_res == JNI_EDETACHED) {
3580                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3581         } else {
3582                 DO_ASSERT(get_jenv_res == JNI_OK);
3583         }
3584         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3585         CHECK(obj != NULL);
3586         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3587         LDKSecretKey ret_ref;
3588         CHECK((*env)->GetArrayLength(env, ret) == 32);
3589         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3590         if (get_jenv_res == JNI_EDETACHED) {
3591                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3592         }
3593         return ret_ref;
3594 }
3595 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3596         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3597         JNIEnv *env;
3598         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3599         if (get_jenv_res == JNI_EDETACHED) {
3600                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3601         } else {
3602                 DO_ASSERT(get_jenv_res == JNI_OK);
3603         }
3604         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3605         CHECK(obj != NULL);
3606         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3607         LDKCVec_u8Z ret_ref;
3608         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3609         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3610         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3611         if (get_jenv_res == JNI_EDETACHED) {
3612                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3613         }
3614         return ret_ref;
3615 }
3616 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3617         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3618         JNIEnv *env;
3619         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3620         if (get_jenv_res == JNI_EDETACHED) {
3621                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3622         } else {
3623                 DO_ASSERT(get_jenv_res == JNI_OK);
3624         }
3625         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3626         CHECK(obj != NULL);
3627         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3628         LDKPublicKey ret_ref;
3629         CHECK((*env)->GetArrayLength(env, ret) == 33);
3630         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3631         if (get_jenv_res == JNI_EDETACHED) {
3632                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3633         }
3634         return ret_ref;
3635 }
3636 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3637         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3638         JNIEnv *env;
3639         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3640         if (get_jenv_res == JNI_EDETACHED) {
3641                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3642         } else {
3643                 DO_ASSERT(get_jenv_res == JNI_OK);
3644         }
3645         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3646         CHECK(obj != NULL);
3647         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3648         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3649         ret_conv = Sign_clone(ret);
3650         if (get_jenv_res == JNI_EDETACHED) {
3651                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3652         }
3653         return ret_conv;
3654 }
3655 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3656         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3657         JNIEnv *env;
3658         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3659         if (get_jenv_res == JNI_EDETACHED) {
3660                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3661         } else {
3662                 DO_ASSERT(get_jenv_res == JNI_OK);
3663         }
3664         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3665         CHECK(obj != NULL);
3666         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3667         LDKThirtyTwoBytes ret_ref;
3668         CHECK((*env)->GetArrayLength(env, ret) == 32);
3669         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3670         if (get_jenv_res == JNI_EDETACHED) {
3671                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3672         }
3673         return ret_ref;
3674 }
3675 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3676         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3677         JNIEnv *env;
3678         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3679         if (get_jenv_res == JNI_EDETACHED) {
3680                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3681         } else {
3682                 DO_ASSERT(get_jenv_res == JNI_OK);
3683         }
3684         LDKu8slice reader_var = reader;
3685         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3686         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3687         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3688         CHECK(obj != NULL);
3689         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3690         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3691         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3692         if (get_jenv_res == JNI_EDETACHED) {
3693                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3694         }
3695         return ret_conv;
3696 }
3697 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3698         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3699         JNIEnv *env;
3700         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3701         if (get_jenv_res == JNI_EDETACHED) {
3702                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3703         } else {
3704                 DO_ASSERT(get_jenv_res == JNI_OK);
3705         }
3706         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3707         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3708         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3709         CVec_u8Z_free(invoice_preimage_var);
3710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3711         CHECK(obj != NULL);
3712         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3713         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3714         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3715         if (get_jenv_res == JNI_EDETACHED) {
3716                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3717         }
3718         return ret_conv;
3719 }
3720 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3721         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3722         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3723         return (void*) this_arg;
3724 }
3725 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3726         jclass c = (*env)->GetObjectClass(env, o);
3727         CHECK(c != NULL);
3728         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3729         atomic_init(&calls->refcnt, 1);
3730         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3731         calls->o = (*env)->NewWeakGlobalRef(env, o);
3732         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3733         CHECK(calls->get_node_secret_meth != NULL);
3734         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3735         CHECK(calls->get_destination_script_meth != NULL);
3736         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3737         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3738         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3739         CHECK(calls->get_channel_signer_meth != NULL);
3740         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3741         CHECK(calls->get_secure_random_bytes_meth != NULL);
3742         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3743         CHECK(calls->read_chan_signer_meth != NULL);
3744         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3745         CHECK(calls->sign_invoice_meth != NULL);
3746
3747         LDKKeysInterface ret = {
3748                 .this_arg = (void*) calls,
3749                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3750                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3751                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3752                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3753                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3754                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3755                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3756                 .free = LDKKeysInterface_JCalls_free,
3757         };
3758         return ret;
3759 }
3760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3761         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3762         *res_ptr = LDKKeysInterface_init(env, clz, o);
3763         return (uint64_t)res_ptr;
3764 }
3765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3766         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3769         return ret_arr;
3770 }
3771
3772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3773         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3774         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3775         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3776         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3777         CVec_u8Z_free(ret_var);
3778         return ret_arr;
3779 }
3780
3781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3782         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3783         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3785         return ret_arr;
3786 }
3787
3788 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) {
3789         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3790         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3791         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3792         return (uint64_t)ret;
3793 }
3794
3795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3796         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3797         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3798         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3799         return ret_arr;
3800 }
3801
3802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3803         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3804         LDKu8slice reader_ref;
3805         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3806         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3807         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3808         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3809         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3810         return (uint64_t)ret_conv;
3811 }
3812
3813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3814         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3815         LDKCVec_u8Z invoice_preimage_ref;
3816         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3817         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3818         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3819         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3820         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3821         return (uint64_t)ret_conv;
3822 }
3823
3824 typedef struct LDKFeeEstimator_JCalls {
3825         atomic_size_t refcnt;
3826         JavaVM *vm;
3827         jweak o;
3828         jmethodID get_est_sat_per_1000_weight_meth;
3829 } LDKFeeEstimator_JCalls;
3830 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3831         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3832         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3833                 JNIEnv *env;
3834                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3835                 if (get_jenv_res == JNI_EDETACHED) {
3836                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3837                 } else {
3838                         DO_ASSERT(get_jenv_res == JNI_OK);
3839                 }
3840                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3841                 if (get_jenv_res == JNI_EDETACHED) {
3842                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3843                 }
3844                 FREE(j_calls);
3845         }
3846 }
3847 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3848         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_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         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
3857         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3858         CHECK(obj != NULL);
3859         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3860         if (get_jenv_res == JNI_EDETACHED) {
3861                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3862         }
3863         return ret;
3864 }
3865 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3866         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3867         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3868         return (void*) this_arg;
3869 }
3870 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
3871         jclass c = (*env)->GetObjectClass(env, o);
3872         CHECK(c != NULL);
3873         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3874         atomic_init(&calls->refcnt, 1);
3875         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3876         calls->o = (*env)->NewWeakGlobalRef(env, o);
3877         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
3878         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
3879
3880         LDKFeeEstimator ret = {
3881                 .this_arg = (void*) calls,
3882                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3883                 .free = LDKFeeEstimator_JCalls_free,
3884         };
3885         return ret;
3886 }
3887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
3888         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3889         *res_ptr = LDKFeeEstimator_init(env, clz, o);
3890         return (uint64_t)res_ptr;
3891 }
3892 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) {
3893         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3894         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
3895         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3896         return ret_val;
3897 }
3898
3899 typedef struct LDKLogger_JCalls {
3900         atomic_size_t refcnt;
3901         JavaVM *vm;
3902         jweak o;
3903         jmethodID log_meth;
3904 } LDKLogger_JCalls;
3905 static void LDKLogger_JCalls_free(void* this_arg) {
3906         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3907         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3908                 JNIEnv *env;
3909                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3910                 if (get_jenv_res == JNI_EDETACHED) {
3911                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3912                 } else {
3913                         DO_ASSERT(get_jenv_res == JNI_OK);
3914                 }
3915                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3916                 if (get_jenv_res == JNI_EDETACHED) {
3917                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3918                 }
3919                 FREE(j_calls);
3920         }
3921 }
3922 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3923         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3924         JNIEnv *env;
3925         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3926         if (get_jenv_res == JNI_EDETACHED) {
3927                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3928         } else {
3929                 DO_ASSERT(get_jenv_res == JNI_OK);
3930         }
3931         const char* record_str = record;
3932         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
3933         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3934         CHECK(obj != NULL);
3935         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
3936         if (get_jenv_res == JNI_EDETACHED) {
3937                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3938         }
3939 }
3940 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3941         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3942         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3943         return (void*) this_arg;
3944 }
3945 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3946         jclass c = (*env)->GetObjectClass(env, o);
3947         CHECK(c != NULL);
3948         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3949         atomic_init(&calls->refcnt, 1);
3950         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3951         calls->o = (*env)->NewWeakGlobalRef(env, o);
3952         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
3953         CHECK(calls->log_meth != NULL);
3954
3955         LDKLogger ret = {
3956                 .this_arg = (void*) calls,
3957                 .log = log_LDKLogger_jcall,
3958                 .free = LDKLogger_JCalls_free,
3959         };
3960         return ret;
3961 }
3962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3963         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3964         *res_ptr = LDKLogger_init(env, clz, o);
3965         return (uint64_t)res_ptr;
3966 }
3967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
3968         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3969         LDKThirtyTwoBytes a_ref;
3970         CHECK((*env)->GetArrayLength(env, a) == 32);
3971         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3972         ret->a = a_ref;
3973         LDKChannelManager b_conv;
3974         b_conv.inner = (void*)(b & (~1));
3975         b_conv.is_owned = (b & 1) || (b == 0);
3976         // Warning: we need a move here but no clone is available for LDKChannelManager
3977         ret->b = b_conv;
3978         return (uint64_t)ret;
3979 }
3980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3981         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3982         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3983         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3984         return a_arr;
3985 }
3986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3987         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3988         LDKChannelManager b_var = tuple->b;
3989         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3990         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3991         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3992         return b_ref;
3993 }
3994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3995         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3996 }
3997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3998         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3999         CHECK(val->result_ok);
4000         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4001         return res_ref;
4002 }
4003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4004         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4005         CHECK(!val->result_ok);
4006         LDKDecodeError err_var = (*val->contents.err);
4007         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4008         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4009         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4010         return err_ref;
4011 }
4012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4013         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4014 }
4015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4016         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4017         CHECK(val->result_ok);
4018         LDKChannelConfig res_var = (*val->contents.result);
4019         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4020         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4021         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4022         return res_ref;
4023 }
4024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4025         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4026         CHECK(!val->result_ok);
4027         LDKDecodeError err_var = (*val->contents.err);
4028         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4029         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4030         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4031         return err_ref;
4032 }
4033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4034         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4035 }
4036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4037         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4038         CHECK(val->result_ok);
4039         LDKOutPoint res_var = (*val->contents.result);
4040         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4041         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4042         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4043         return res_ref;
4044 }
4045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4046         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4047         CHECK(!val->result_ok);
4048         LDKDecodeError err_var = (*val->contents.err);
4049         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4050         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4051         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4052         return err_ref;
4053 }
4054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4055         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4056 }
4057 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4058         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4059         CHECK(val->result_ok);
4060         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4061         return res_conv;
4062 }
4063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4064         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4065         CHECK(!val->result_ok);
4066         return *val->contents.err;
4067 }
4068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4069         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4070 }
4071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4072         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4073         CHECK(val->result_ok);
4074         LDKInvoice res_var = (*val->contents.result);
4075         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4076         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4077         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4078         return res_ref;
4079 }
4080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4081         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4082         CHECK(!val->result_ok);
4083         return *val->contents.err;
4084 }
4085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4086         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4087 }
4088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4089         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4090         CHECK(val->result_ok);
4091         LDKSignedRawInvoice res_var = (*val->contents.result);
4092         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4093         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4094         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4095         return res_ref;
4096 }
4097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4098         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4099         CHECK(!val->result_ok);
4100         return *val->contents.err;
4101 }
4102 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) {
4103         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4104         LDKRawInvoice a_conv;
4105         a_conv.inner = (void*)(a & (~1));
4106         a_conv.is_owned = (a & 1) || (a == 0);
4107         a_conv = RawInvoice_clone(&a_conv);
4108         ret->a = a_conv;
4109         LDKThirtyTwoBytes b_ref;
4110         CHECK((*env)->GetArrayLength(env, b) == 32);
4111         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4112         ret->b = b_ref;
4113         LDKInvoiceSignature c_conv;
4114         c_conv.inner = (void*)(c & (~1));
4115         c_conv.is_owned = (c & 1) || (c == 0);
4116         c_conv = InvoiceSignature_clone(&c_conv);
4117         ret->c = c_conv;
4118         return (uint64_t)ret;
4119 }
4120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4121         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4122         LDKRawInvoice a_var = tuple->a;
4123         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4124         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4125         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4126         return a_ref;
4127 }
4128 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4129         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4130         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4131         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4132         return b_arr;
4133 }
4134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4135         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4136         LDKInvoiceSignature c_var = tuple->c;
4137         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4138         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4139         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4140         return c_ref;
4141 }
4142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4143         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4144 }
4145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4146         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4147         CHECK(val->result_ok);
4148         LDKPayeePubKey res_var = (*val->contents.result);
4149         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4150         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4151         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4152         return res_ref;
4153 }
4154 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4155         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4156         CHECK(!val->result_ok);
4157         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4158         return err_conv;
4159 }
4160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4161         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4162         ret->datalen = (*env)->GetArrayLength(env, elems);
4163         if (ret->datalen == 0) {
4164                 ret->data = NULL;
4165         } else {
4166                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4167                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4168                 for (size_t i = 0; i < ret->datalen; i++) {
4169                         int64_t arr_elem = java_elems[i];
4170                         LDKPrivateRoute arr_elem_conv;
4171                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4172                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4173                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4174                         ret->data[i] = arr_elem_conv;
4175                 }
4176                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4177         }
4178         return (uint64_t)ret;
4179 }
4180 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4181         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4182         for (size_t i = 0; i < ret.datalen; i++) {
4183                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4184         }
4185         return ret;
4186 }
4187 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4188         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4189 }
4190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4191         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4192         CHECK(val->result_ok);
4193         LDKPositiveTimestamp res_var = (*val->contents.result);
4194         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4195         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4196         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4197         return res_ref;
4198 }
4199 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4200         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4201         CHECK(!val->result_ok);
4202         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4203         return err_conv;
4204 }
4205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4206         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4207 }
4208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4209         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4210         CHECK(val->result_ok);
4211         return *val->contents.result;
4212 }
4213 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4214         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4215         CHECK(!val->result_ok);
4216         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4217         return err_conv;
4218 }
4219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4220         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4221 }
4222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4223         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4224         CHECK(val->result_ok);
4225         LDKInvoice res_var = (*val->contents.result);
4226         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4227         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4228         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4229         return res_ref;
4230 }
4231 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4232         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4233         CHECK(!val->result_ok);
4234         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4235         return err_conv;
4236 }
4237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4238         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4239 }
4240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4241         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4242         CHECK(val->result_ok);
4243         LDKDescription res_var = (*val->contents.result);
4244         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4245         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4246         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4247         return res_ref;
4248 }
4249 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4250         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4251         CHECK(!val->result_ok);
4252         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4253         return err_conv;
4254 }
4255 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4256         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4257 }
4258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4259         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4260         CHECK(val->result_ok);
4261         LDKExpiryTime res_var = (*val->contents.result);
4262         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4263         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4264         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4265         return res_ref;
4266 }
4267 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4268         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4269         CHECK(!val->result_ok);
4270         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4271         return err_conv;
4272 }
4273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4274         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4275 }
4276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4277         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4278         CHECK(val->result_ok);
4279         LDKPrivateRoute res_var = (*val->contents.result);
4280         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4281         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4282         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4283         return res_ref;
4284 }
4285 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4286         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4287         CHECK(!val->result_ok);
4288         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4289         return err_conv;
4290 }
4291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4292         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4293 }
4294 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4295         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4296         CHECK(val->result_ok);
4297         LDKStr res_str = (*val->contents.result);
4298         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4299         return res_conv;
4300 }
4301 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4302         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4303         CHECK(!val->result_ok);
4304         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4305         return err_conv;
4306 }
4307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4308         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4309 }
4310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4311         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4312         CHECK(val->result_ok);
4313         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4314         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4315         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4316         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4317         return res_ref;
4318 }
4319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4320         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4321         CHECK(!val->result_ok);
4322         LDKDecodeError err_var = (*val->contents.err);
4323         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4324         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4325         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4326         return err_ref;
4327 }
4328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4329         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4330 }
4331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4332         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4333         CHECK(val->result_ok);
4334         LDKHTLCUpdate res_var = (*val->contents.result);
4335         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4336         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4337         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4338         return res_ref;
4339 }
4340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4341         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4342         CHECK(!val->result_ok);
4343         LDKDecodeError err_var = (*val->contents.err);
4344         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4345         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4346         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4347         return err_ref;
4348 }
4349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4350         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4351 }
4352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4353         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4354         CHECK(val->result_ok);
4355         return *val->contents.result;
4356 }
4357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4358         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4359         CHECK(!val->result_ok);
4360         LDKMonitorUpdateError err_var = (*val->contents.err);
4361         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4362         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4363         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4364         return err_ref;
4365 }
4366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4367         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4368         LDKOutPoint a_conv;
4369         a_conv.inner = (void*)(a & (~1));
4370         a_conv.is_owned = (a & 1) || (a == 0);
4371         a_conv = OutPoint_clone(&a_conv);
4372         ret->a = a_conv;
4373         LDKCVec_u8Z b_ref;
4374         b_ref.datalen = (*env)->GetArrayLength(env, b);
4375         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4376         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4377         ret->b = b_ref;
4378         return (uint64_t)ret;
4379 }
4380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4381         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4382         LDKOutPoint a_var = tuple->a;
4383         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4384         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4385         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4386         return a_ref;
4387 }
4388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4389         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4390         LDKCVec_u8Z b_var = tuple->b;
4391         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4392         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4393         return b_arr;
4394 }
4395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4396         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4397         ret->a = a;
4398         LDKCVec_u8Z b_ref;
4399         b_ref.datalen = (*env)->GetArrayLength(env, b);
4400         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4401         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4402         ret->b = b_ref;
4403         return (uint64_t)ret;
4404 }
4405 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4406         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4407         return tuple->a;
4408 }
4409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4410         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4411         LDKCVec_u8Z b_var = tuple->b;
4412         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4413         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4414         return b_arr;
4415 }
4416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4417         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4418         ret->datalen = (*env)->GetArrayLength(env, elems);
4419         if (ret->datalen == 0) {
4420                 ret->data = NULL;
4421         } else {
4422                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4423                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4424                 for (size_t i = 0; i < ret->datalen; i++) {
4425                         int64_t arr_elem = java_elems[i];
4426                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4427                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4428                         ret->data[i] = arr_elem_conv;
4429                 }
4430                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4431         }
4432         return (uint64_t)ret;
4433 }
4434 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4435         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4436         for (size_t i = 0; i < ret.datalen; i++) {
4437                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4438         }
4439         return ret;
4440 }
4441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4442         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4443         LDKThirtyTwoBytes a_ref;
4444         CHECK((*env)->GetArrayLength(env, a) == 32);
4445         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4446         ret->a = a_ref;
4447         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4448         b_constr.datalen = (*env)->GetArrayLength(env, b);
4449         if (b_constr.datalen > 0)
4450                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4451         else
4452                 b_constr.data = NULL;
4453         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4454         for (size_t b = 0; b < b_constr.datalen; b++) {
4455                 int64_t b_conv_27 = b_vals[b];
4456                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4457                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4458                 b_constr.data[b] = b_conv_27_conv;
4459         }
4460         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4461         ret->b = b_constr;
4462         return (uint64_t)ret;
4463 }
4464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4465         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4466         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4467         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4468         return a_arr;
4469 }
4470 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4471         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4472         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4473         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4474         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4475         for (size_t b = 0; b < b_var.datalen; b++) {
4476                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4477                 b_arr_ptr[b] = b_conv_27_ref;
4478         }
4479         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4480         return b_arr;
4481 }
4482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4483         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4484         ret->datalen = (*env)->GetArrayLength(env, elems);
4485         if (ret->datalen == 0) {
4486                 ret->data = NULL;
4487         } else {
4488                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4489                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4490                 for (size_t i = 0; i < ret->datalen; i++) {
4491                         int64_t arr_elem = java_elems[i];
4492                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4493                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4494                         ret->data[i] = arr_elem_conv;
4495                 }
4496                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4497         }
4498         return (uint64_t)ret;
4499 }
4500 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4501         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 };
4502         for (size_t i = 0; i < ret.datalen; i++) {
4503                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4504         }
4505         return ret;
4506 }
4507 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4508 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4509 static jclass LDKEvent_PaymentReceived_class = NULL;
4510 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4511 static jclass LDKEvent_PaymentSent_class = NULL;
4512 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4513 static jclass LDKEvent_PaymentFailed_class = NULL;
4514 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4515 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4516 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4517 static jclass LDKEvent_SpendableOutputs_class = NULL;
4518 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4520         LDKEvent_FundingGenerationReady_class =
4521                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4522         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4523         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4524         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4525         LDKEvent_PaymentReceived_class =
4526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4527         CHECK(LDKEvent_PaymentReceived_class != NULL);
4528         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4529         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4530         LDKEvent_PaymentSent_class =
4531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4532         CHECK(LDKEvent_PaymentSent_class != NULL);
4533         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4534         CHECK(LDKEvent_PaymentSent_meth != NULL);
4535         LDKEvent_PaymentFailed_class =
4536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4537         CHECK(LDKEvent_PaymentFailed_class != NULL);
4538         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4539         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4540         LDKEvent_PendingHTLCsForwardable_class =
4541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4542         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4543         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4544         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4545         LDKEvent_SpendableOutputs_class =
4546                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4547         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4548         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4549         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4550 }
4551 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4552         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4553         switch(obj->tag) {
4554                 case LDKEvent_FundingGenerationReady: {
4555                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4556                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4557                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4558                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4559                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4560                         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);
4561                 }
4562                 case LDKEvent_PaymentReceived: {
4563                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4564                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4565                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4566                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4567                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4568                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4569                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_preimage_arr, payment_secret_arr, obj->payment_received.amt, obj->payment_received.user_payment_id);
4570                 }
4571                 case LDKEvent_PaymentSent: {
4572                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4573                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4574                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4575                 }
4576                 case LDKEvent_PaymentFailed: {
4577                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4578                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4579                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4580                 }
4581                 case LDKEvent_PendingHTLCsForwardable: {
4582                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4583                 }
4584                 case LDKEvent_SpendableOutputs: {
4585                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4586                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4587                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4588                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4589                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4590                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4591                         }
4592                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4593                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4594                 }
4595                 default: abort();
4596         }
4597 }
4598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4599         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4600         ret->datalen = (*env)->GetArrayLength(env, elems);
4601         if (ret->datalen == 0) {
4602                 ret->data = NULL;
4603         } else {
4604                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4605                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4606                 for (size_t i = 0; i < ret->datalen; i++) {
4607                         int64_t arr_elem = java_elems[i];
4608                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4609                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4610                         ret->data[i] = arr_elem_conv;
4611                 }
4612                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4613         }
4614         return (uint64_t)ret;
4615 }
4616 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4617         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4618         for (size_t i = 0; i < ret.datalen; i++) {
4619                 ret.data[i] = Event_clone(&orig->data[i]);
4620         }
4621         return ret;
4622 }
4623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4624         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4625         ret->a = a;
4626         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4627         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4628         ret->b = b_conv;
4629         return (uint64_t)ret;
4630 }
4631 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4632         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4633         return tuple->a;
4634 }
4635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4636         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4637         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4638         return (uint64_t)b_ref;
4639 }
4640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4641         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4642         ret->datalen = (*env)->GetArrayLength(env, elems);
4643         if (ret->datalen == 0) {
4644                 ret->data = NULL;
4645         } else {
4646                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4647                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4648                 for (size_t i = 0; i < ret->datalen; i++) {
4649                         int64_t arr_elem = java_elems[i];
4650                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4651                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4652                         ret->data[i] = arr_elem_conv;
4653                 }
4654                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4655         }
4656         return (uint64_t)ret;
4657 }
4658 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4659         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4660         for (size_t i = 0; i < ret.datalen; i++) {
4661                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4662         }
4663         return ret;
4664 }
4665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4666         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4667         LDKThirtyTwoBytes a_ref;
4668         CHECK((*env)->GetArrayLength(env, a) == 32);
4669         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4670         ret->a = a_ref;
4671         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4672         b_constr.datalen = (*env)->GetArrayLength(env, b);
4673         if (b_constr.datalen > 0)
4674                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4675         else
4676                 b_constr.data = NULL;
4677         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4678         for (size_t a = 0; a < b_constr.datalen; a++) {
4679                 int64_t b_conv_26 = b_vals[a];
4680                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4681                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4682                 b_constr.data[a] = b_conv_26_conv;
4683         }
4684         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4685         ret->b = b_constr;
4686         return (uint64_t)ret;
4687 }
4688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4689         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4690         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4691         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4692         return a_arr;
4693 }
4694 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4695         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4696         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4697         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4698         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4699         for (size_t a = 0; a < b_var.datalen; a++) {
4700                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4701                 b_arr_ptr[a] = b_conv_26_ref;
4702         }
4703         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4704         return b_arr;
4705 }
4706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4707         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4708         ret->datalen = (*env)->GetArrayLength(env, elems);
4709         if (ret->datalen == 0) {
4710                 ret->data = NULL;
4711         } else {
4712                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4713                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4714                 for (size_t i = 0; i < ret->datalen; i++) {
4715                         int64_t arr_elem = java_elems[i];
4716                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4717                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4718                         ret->data[i] = arr_elem_conv;
4719                 }
4720                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4721         }
4722         return (uint64_t)ret;
4723 }
4724 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4725         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 };
4726         for (size_t i = 0; i < ret.datalen; i++) {
4727                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4728         }
4729         return ret;
4730 }
4731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4732         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4733 }
4734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4735         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4736         CHECK(val->result_ok);
4737         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4738         return res_ref;
4739 }
4740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4741         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4742         CHECK(!val->result_ok);
4743         LDKDecodeError err_var = (*val->contents.err);
4744         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4745         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4746         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4747         return err_ref;
4748 }
4749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4750         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4751 }
4752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4753         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4754         CHECK(val->result_ok);
4755         return *val->contents.result;
4756 }
4757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4758         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4759         CHECK(!val->result_ok);
4760         LDKLightningError err_var = (*val->contents.err);
4761         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4762         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4763         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4764         return err_ref;
4765 }
4766 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) {
4767         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4768         LDKChannelAnnouncement a_conv;
4769         a_conv.inner = (void*)(a & (~1));
4770         a_conv.is_owned = (a & 1) || (a == 0);
4771         a_conv = ChannelAnnouncement_clone(&a_conv);
4772         ret->a = a_conv;
4773         LDKChannelUpdate b_conv;
4774         b_conv.inner = (void*)(b & (~1));
4775         b_conv.is_owned = (b & 1) || (b == 0);
4776         b_conv = ChannelUpdate_clone(&b_conv);
4777         ret->b = b_conv;
4778         LDKChannelUpdate c_conv;
4779         c_conv.inner = (void*)(c & (~1));
4780         c_conv.is_owned = (c & 1) || (c == 0);
4781         c_conv = ChannelUpdate_clone(&c_conv);
4782         ret->c = c_conv;
4783         return (uint64_t)ret;
4784 }
4785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4786         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4787         LDKChannelAnnouncement a_var = tuple->a;
4788         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4789         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4790         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4791         return a_ref;
4792 }
4793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4794         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4795         LDKChannelUpdate b_var = tuple->b;
4796         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4797         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4798         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4799         return b_ref;
4800 }
4801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4802         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4803         LDKChannelUpdate c_var = tuple->c;
4804         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4805         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4806         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4807         return c_ref;
4808 }
4809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4810         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4811         ret->datalen = (*env)->GetArrayLength(env, elems);
4812         if (ret->datalen == 0) {
4813                 ret->data = NULL;
4814         } else {
4815                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4816                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4817                 for (size_t i = 0; i < ret->datalen; i++) {
4818                         int64_t arr_elem = java_elems[i];
4819                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4820                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4821                         ret->data[i] = arr_elem_conv;
4822                 }
4823                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4824         }
4825         return (uint64_t)ret;
4826 }
4827 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4828         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4829         for (size_t i = 0; i < ret.datalen; i++) {
4830                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4831         }
4832         return ret;
4833 }
4834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4835         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4836         ret->datalen = (*env)->GetArrayLength(env, elems);
4837         if (ret->datalen == 0) {
4838                 ret->data = NULL;
4839         } else {
4840                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4841                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4842                 for (size_t i = 0; i < ret->datalen; i++) {
4843                         int64_t arr_elem = java_elems[i];
4844                         LDKNodeAnnouncement arr_elem_conv;
4845                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4846                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4847                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4848                         ret->data[i] = arr_elem_conv;
4849                 }
4850                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4851         }
4852         return (uint64_t)ret;
4853 }
4854 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4855         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4856         for (size_t i = 0; i < ret.datalen; i++) {
4857                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4858         }
4859         return ret;
4860 }
4861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4862         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
4863 }
4864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4865         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4866         CHECK(val->result_ok);
4867         return *val->contents.result;
4868 }
4869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4870         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4871         CHECK(!val->result_ok);
4872         LDKLightningError err_var = (*val->contents.err);
4873         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4874         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4875         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4876         return err_ref;
4877 }
4878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4879         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4880 }
4881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4882         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4883         CHECK(val->result_ok);
4884         LDKCVec_u8Z res_var = (*val->contents.result);
4885         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
4886         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
4887         return res_arr;
4888 }
4889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4890         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4891         CHECK(!val->result_ok);
4892         LDKPeerHandleError err_var = (*val->contents.err);
4893         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4894         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4895         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4896         return err_ref;
4897 }
4898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4899         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4900 }
4901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4902         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4903         CHECK(val->result_ok);
4904         return *val->contents.result;
4905 }
4906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4907         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4908         CHECK(!val->result_ok);
4909         LDKPeerHandleError err_var = (*val->contents.err);
4910         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4911         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4912         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4913         return err_ref;
4914 }
4915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4916         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4917 }
4918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4919         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4920         CHECK(val->result_ok);
4921         return *val->contents.result;
4922 }
4923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4924         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4925         CHECK(!val->result_ok);
4926         LDKPeerHandleError err_var = (*val->contents.err);
4927         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4928         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4929         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4930         return err_ref;
4931 }
4932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4933         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4934 }
4935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4936         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4937         CHECK(val->result_ok);
4938         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4939         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4940         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4941         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4942         return res_ref;
4943 }
4944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4945         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4946         CHECK(!val->result_ok);
4947         LDKDecodeError err_var = (*val->contents.err);
4948         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4949         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4950         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4951         return err_ref;
4952 }
4953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4954         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4955 }
4956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4957         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4958         CHECK(val->result_ok);
4959         LDKChannelInfo res_var = (*val->contents.result);
4960         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4961         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4962         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4963         return res_ref;
4964 }
4965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4966         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4967         CHECK(!val->result_ok);
4968         LDKDecodeError err_var = (*val->contents.err);
4969         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4970         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4971         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4972         return err_ref;
4973 }
4974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4975         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4976 }
4977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4978         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4979         CHECK(val->result_ok);
4980         LDKRoutingFees res_var = (*val->contents.result);
4981         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4982         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4983         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4984         return res_ref;
4985 }
4986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4987         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4988         CHECK(!val->result_ok);
4989         LDKDecodeError err_var = (*val->contents.err);
4990         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4991         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4992         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4993         return err_ref;
4994 }
4995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4996         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4997 }
4998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4999         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5000         CHECK(val->result_ok);
5001         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5002         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5003         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5004         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5005         return res_ref;
5006 }
5007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5008         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5009         CHECK(!val->result_ok);
5010         LDKDecodeError err_var = (*val->contents.err);
5011         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5012         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5013         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5014         return err_ref;
5015 }
5016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5017         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5018         ret->datalen = (*env)->GetArrayLength(env, elems);
5019         if (ret->datalen == 0) {
5020                 ret->data = NULL;
5021         } else {
5022                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5023                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5024                 for (size_t i = 0; i < ret->datalen; i++) {
5025                         ret->data[i] = java_elems[i];
5026                 }
5027                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5028         }
5029         return (uint64_t)ret;
5030 }
5031 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5032         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5033         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5034         return ret;
5035 }
5036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5037         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5038 }
5039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5040         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5041         CHECK(val->result_ok);
5042         LDKNodeInfo res_var = (*val->contents.result);
5043         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5044         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5045         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5046         return res_ref;
5047 }
5048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5049         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5050         CHECK(!val->result_ok);
5051         LDKDecodeError err_var = (*val->contents.err);
5052         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5053         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5054         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5055         return err_ref;
5056 }
5057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5058         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5059 }
5060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5061         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5062         CHECK(val->result_ok);
5063         LDKNetworkGraph res_var = (*val->contents.result);
5064         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5065         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5066         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5067         return res_ref;
5068 }
5069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5070         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5071         CHECK(!val->result_ok);
5072         LDKDecodeError err_var = (*val->contents.err);
5073         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5074         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5075         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5076         return err_ref;
5077 }
5078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5079         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5080 }
5081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5082         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5083         CHECK(val->result_ok);
5084         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5085         return res_ref;
5086 }
5087 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5088         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5089         CHECK(!val->result_ok);
5090         return *val->contents.err;
5091 }
5092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5093         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5094 }
5095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5096         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5097         CHECK(val->result_ok);
5098         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5099         *res_conv = (*val->contents.result);
5100         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5101         return (uint64_t)res_conv;
5102 }
5103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5104         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5105         CHECK(!val->result_ok);
5106         LDKDecodeError err_var = (*val->contents.err);
5107         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5108         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5109         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5110         return err_ref;
5111 }
5112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5113         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5114 }
5115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5116         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5117         CHECK(val->result_ok);
5118         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5119         return res_ref;
5120 }
5121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5122         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5123         CHECK(!val->result_ok);
5124         LDKDecodeError err_var = (*val->contents.err);
5125         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5126         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5127         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5128         return err_ref;
5129 }
5130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5131         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5132         ret->datalen = (*env)->GetArrayLength(env, elems);
5133         if (ret->datalen == 0) {
5134                 ret->data = NULL;
5135         } else {
5136                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5137                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5138                 for (size_t i = 0; i < ret->datalen; i++) {
5139                         int64_t arr_elem = java_elems[i];
5140                         LDKUpdateAddHTLC arr_elem_conv;
5141                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5142                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5143                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5144                         ret->data[i] = arr_elem_conv;
5145                 }
5146                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5147         }
5148         return (uint64_t)ret;
5149 }
5150 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5151         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5152         for (size_t i = 0; i < ret.datalen; i++) {
5153                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5154         }
5155         return ret;
5156 }
5157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5158         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5159         ret->datalen = (*env)->GetArrayLength(env, elems);
5160         if (ret->datalen == 0) {
5161                 ret->data = NULL;
5162         } else {
5163                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5164                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5165                 for (size_t i = 0; i < ret->datalen; i++) {
5166                         int64_t arr_elem = java_elems[i];
5167                         LDKUpdateFulfillHTLC arr_elem_conv;
5168                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5169                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5170                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5171                         ret->data[i] = arr_elem_conv;
5172                 }
5173                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5174         }
5175         return (uint64_t)ret;
5176 }
5177 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5178         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5179         for (size_t i = 0; i < ret.datalen; i++) {
5180                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5181         }
5182         return ret;
5183 }
5184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5185         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5186         ret->datalen = (*env)->GetArrayLength(env, elems);
5187         if (ret->datalen == 0) {
5188                 ret->data = NULL;
5189         } else {
5190                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5191                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5192                 for (size_t i = 0; i < ret->datalen; i++) {
5193                         int64_t arr_elem = java_elems[i];
5194                         LDKUpdateFailHTLC arr_elem_conv;
5195                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5196                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5197                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5198                         ret->data[i] = arr_elem_conv;
5199                 }
5200                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5201         }
5202         return (uint64_t)ret;
5203 }
5204 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5205         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5206         for (size_t i = 0; i < ret.datalen; i++) {
5207                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5208         }
5209         return ret;
5210 }
5211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5212         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5213         ret->datalen = (*env)->GetArrayLength(env, elems);
5214         if (ret->datalen == 0) {
5215                 ret->data = NULL;
5216         } else {
5217                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5218                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5219                 for (size_t i = 0; i < ret->datalen; i++) {
5220                         int64_t arr_elem = java_elems[i];
5221                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5222                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5223                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5224                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5225                         ret->data[i] = arr_elem_conv;
5226                 }
5227                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5228         }
5229         return (uint64_t)ret;
5230 }
5231 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5232         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5233         for (size_t i = 0; i < ret.datalen; i++) {
5234                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5235         }
5236         return ret;
5237 }
5238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5239         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5240 }
5241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5242         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5243         CHECK(val->result_ok);
5244         LDKAcceptChannel res_var = (*val->contents.result);
5245         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5246         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5247         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5248         return res_ref;
5249 }
5250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5251         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5252         CHECK(!val->result_ok);
5253         LDKDecodeError err_var = (*val->contents.err);
5254         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5255         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5256         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5257         return err_ref;
5258 }
5259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5260         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5261 }
5262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5263         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5264         CHECK(val->result_ok);
5265         LDKAnnouncementSignatures res_var = (*val->contents.result);
5266         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5267         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5268         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5269         return res_ref;
5270 }
5271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5272         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5273         CHECK(!val->result_ok);
5274         LDKDecodeError err_var = (*val->contents.err);
5275         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5276         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5277         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5278         return err_ref;
5279 }
5280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5281         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5282 }
5283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5284         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5285         CHECK(val->result_ok);
5286         LDKChannelReestablish res_var = (*val->contents.result);
5287         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5288         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5289         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5290         return res_ref;
5291 }
5292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5293         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5294         CHECK(!val->result_ok);
5295         LDKDecodeError err_var = (*val->contents.err);
5296         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5297         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5298         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5299         return err_ref;
5300 }
5301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5302         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5303 }
5304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5305         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5306         CHECK(val->result_ok);
5307         LDKClosingSigned res_var = (*val->contents.result);
5308         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5309         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5310         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5311         return res_ref;
5312 }
5313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5314         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5315         CHECK(!val->result_ok);
5316         LDKDecodeError err_var = (*val->contents.err);
5317         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5318         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5319         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5320         return err_ref;
5321 }
5322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5323         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5324 }
5325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5326         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5327         CHECK(val->result_ok);
5328         LDKCommitmentSigned res_var = (*val->contents.result);
5329         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5330         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5331         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5332         return res_ref;
5333 }
5334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5335         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5336         CHECK(!val->result_ok);
5337         LDKDecodeError err_var = (*val->contents.err);
5338         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5339         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5340         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5341         return err_ref;
5342 }
5343 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5344         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5345 }
5346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5347         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5348         CHECK(val->result_ok);
5349         LDKFundingCreated res_var = (*val->contents.result);
5350         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5351         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5352         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5353         return res_ref;
5354 }
5355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5356         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5357         CHECK(!val->result_ok);
5358         LDKDecodeError err_var = (*val->contents.err);
5359         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5360         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5361         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5362         return err_ref;
5363 }
5364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5365         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5366 }
5367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5368         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5369         CHECK(val->result_ok);
5370         LDKFundingSigned res_var = (*val->contents.result);
5371         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5372         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5373         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5374         return res_ref;
5375 }
5376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5377         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5378         CHECK(!val->result_ok);
5379         LDKDecodeError err_var = (*val->contents.err);
5380         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5381         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5382         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5383         return err_ref;
5384 }
5385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5386         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5387 }
5388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5389         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5390         CHECK(val->result_ok);
5391         LDKFundingLocked res_var = (*val->contents.result);
5392         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5395         return res_ref;
5396 }
5397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5398         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5399         CHECK(!val->result_ok);
5400         LDKDecodeError err_var = (*val->contents.err);
5401         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5402         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5403         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5404         return err_ref;
5405 }
5406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5407         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5408 }
5409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5410         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5411         CHECK(val->result_ok);
5412         LDKInit res_var = (*val->contents.result);
5413         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5414         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5415         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5416         return res_ref;
5417 }
5418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5419         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5420         CHECK(!val->result_ok);
5421         LDKDecodeError err_var = (*val->contents.err);
5422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5425         return err_ref;
5426 }
5427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5428         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5429 }
5430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5431         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5432         CHECK(val->result_ok);
5433         LDKOpenChannel res_var = (*val->contents.result);
5434         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5435         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5436         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5437         return res_ref;
5438 }
5439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5440         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5441         CHECK(!val->result_ok);
5442         LDKDecodeError err_var = (*val->contents.err);
5443         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5444         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5445         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5446         return err_ref;
5447 }
5448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5449         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5450 }
5451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5452         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5453         CHECK(val->result_ok);
5454         LDKRevokeAndACK res_var = (*val->contents.result);
5455         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5456         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5457         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5458         return res_ref;
5459 }
5460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5461         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5462         CHECK(!val->result_ok);
5463         LDKDecodeError err_var = (*val->contents.err);
5464         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5465         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5466         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5467         return err_ref;
5468 }
5469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5470         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5471 }
5472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5473         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5474         CHECK(val->result_ok);
5475         LDKShutdown res_var = (*val->contents.result);
5476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5478         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5479         return res_ref;
5480 }
5481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5482         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5483         CHECK(!val->result_ok);
5484         LDKDecodeError err_var = (*val->contents.err);
5485         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5486         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5487         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5488         return err_ref;
5489 }
5490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5491         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5492 }
5493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5494         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5495         CHECK(val->result_ok);
5496         LDKUpdateFailHTLC res_var = (*val->contents.result);
5497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5499         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5500         return res_ref;
5501 }
5502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5503         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5504         CHECK(!val->result_ok);
5505         LDKDecodeError err_var = (*val->contents.err);
5506         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5507         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5508         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5509         return err_ref;
5510 }
5511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5512         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5513 }
5514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5515         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5516         CHECK(val->result_ok);
5517         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5518         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5519         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5520         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5521         return res_ref;
5522 }
5523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5524         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5525         CHECK(!val->result_ok);
5526         LDKDecodeError err_var = (*val->contents.err);
5527         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5528         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5529         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5530         return err_ref;
5531 }
5532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5533         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5534 }
5535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5536         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5537         CHECK(val->result_ok);
5538         LDKUpdateFee res_var = (*val->contents.result);
5539         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5540         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5541         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5542         return res_ref;
5543 }
5544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5545         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5546         CHECK(!val->result_ok);
5547         LDKDecodeError err_var = (*val->contents.err);
5548         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5549         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5550         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5551         return err_ref;
5552 }
5553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5554         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5555 }
5556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5557         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5558         CHECK(val->result_ok);
5559         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5562         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5563         return res_ref;
5564 }
5565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5566         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5567         CHECK(!val->result_ok);
5568         LDKDecodeError err_var = (*val->contents.err);
5569         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5570         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5571         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5572         return err_ref;
5573 }
5574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5575         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5576 }
5577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5578         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5579         CHECK(val->result_ok);
5580         LDKUpdateAddHTLC res_var = (*val->contents.result);
5581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5583         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5584         return res_ref;
5585 }
5586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5587         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5588         CHECK(!val->result_ok);
5589         LDKDecodeError err_var = (*val->contents.err);
5590         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5591         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5592         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5593         return err_ref;
5594 }
5595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5596         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5597 }
5598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5599         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5600         CHECK(val->result_ok);
5601         LDKPing res_var = (*val->contents.result);
5602         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5603         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5604         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5605         return res_ref;
5606 }
5607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5608         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5609         CHECK(!val->result_ok);
5610         LDKDecodeError err_var = (*val->contents.err);
5611         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5612         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5613         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5614         return err_ref;
5615 }
5616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5617         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5618 }
5619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5620         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5621         CHECK(val->result_ok);
5622         LDKPong res_var = (*val->contents.result);
5623         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5624         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5625         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5626         return res_ref;
5627 }
5628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5629         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5630         CHECK(!val->result_ok);
5631         LDKDecodeError err_var = (*val->contents.err);
5632         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5633         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5634         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5635         return err_ref;
5636 }
5637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5638         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5639 }
5640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5641         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5642         CHECK(val->result_ok);
5643         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5644         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5647         return res_ref;
5648 }
5649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5650         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5651         CHECK(!val->result_ok);
5652         LDKDecodeError err_var = (*val->contents.err);
5653         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5654         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5655         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5656         return err_ref;
5657 }
5658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5659         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5660 }
5661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5662         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5663         CHECK(val->result_ok);
5664         LDKChannelAnnouncement res_var = (*val->contents.result);
5665         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5666         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5667         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5668         return res_ref;
5669 }
5670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5671         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5672         CHECK(!val->result_ok);
5673         LDKDecodeError err_var = (*val->contents.err);
5674         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5675         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5676         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5677         return err_ref;
5678 }
5679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5680         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5681 }
5682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5683         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5684         CHECK(val->result_ok);
5685         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5686         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5687         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5688         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5689         return res_ref;
5690 }
5691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5692         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5693         CHECK(!val->result_ok);
5694         LDKDecodeError err_var = (*val->contents.err);
5695         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5696         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5697         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5698         return err_ref;
5699 }
5700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5701         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5702 }
5703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5704         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5705         CHECK(val->result_ok);
5706         LDKChannelUpdate res_var = (*val->contents.result);
5707         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5708         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5709         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5710         return res_ref;
5711 }
5712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5713         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5714         CHECK(!val->result_ok);
5715         LDKDecodeError err_var = (*val->contents.err);
5716         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5717         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5718         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5719         return err_ref;
5720 }
5721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5722         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5725         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5726         CHECK(val->result_ok);
5727         LDKErrorMessage res_var = (*val->contents.result);
5728         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5729         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5730         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5731         return res_ref;
5732 }
5733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5734         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5735         CHECK(!val->result_ok);
5736         LDKDecodeError err_var = (*val->contents.err);
5737         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5738         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5739         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5740         return err_ref;
5741 }
5742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5743         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5744 }
5745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5746         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5747         CHECK(val->result_ok);
5748         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5749         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5750         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5751         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5752         return res_ref;
5753 }
5754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5755         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5756         CHECK(!val->result_ok);
5757         LDKDecodeError err_var = (*val->contents.err);
5758         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5759         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5760         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5761         return err_ref;
5762 }
5763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5764         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5765 }
5766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5767         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5768         CHECK(val->result_ok);
5769         LDKNodeAnnouncement res_var = (*val->contents.result);
5770         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5771         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5772         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5773         return res_ref;
5774 }
5775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5776         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5777         CHECK(!val->result_ok);
5778         LDKDecodeError err_var = (*val->contents.err);
5779         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5780         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5781         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5782         return err_ref;
5783 }
5784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5785         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5786 }
5787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5788         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5789         CHECK(val->result_ok);
5790         LDKQueryShortChannelIds res_var = (*val->contents.result);
5791         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5792         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5793         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5794         return res_ref;
5795 }
5796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5797         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5798         CHECK(!val->result_ok);
5799         LDKDecodeError err_var = (*val->contents.err);
5800         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5801         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5802         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5803         return err_ref;
5804 }
5805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5806         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5807 }
5808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5809         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5810         CHECK(val->result_ok);
5811         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5812         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5813         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5814         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5815         return res_ref;
5816 }
5817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5818         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5819         CHECK(!val->result_ok);
5820         LDKDecodeError err_var = (*val->contents.err);
5821         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5822         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5823         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5824         return err_ref;
5825 }
5826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5827         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5828 }
5829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5830         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5831         CHECK(val->result_ok);
5832         LDKQueryChannelRange res_var = (*val->contents.result);
5833         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5834         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5835         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5836         return res_ref;
5837 }
5838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5839         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5840         CHECK(!val->result_ok);
5841         LDKDecodeError err_var = (*val->contents.err);
5842         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5843         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5844         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5845         return err_ref;
5846 }
5847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5848         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5849 }
5850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5851         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5852         CHECK(val->result_ok);
5853         LDKReplyChannelRange res_var = (*val->contents.result);
5854         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5855         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5856         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5857         return res_ref;
5858 }
5859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5860         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5861         CHECK(!val->result_ok);
5862         LDKDecodeError err_var = (*val->contents.err);
5863         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5864         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5865         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5866         return err_ref;
5867 }
5868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5869         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5870 }
5871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5872         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5873         CHECK(val->result_ok);
5874         LDKGossipTimestampFilter res_var = (*val->contents.result);
5875         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5876         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5877         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5878         return res_ref;
5879 }
5880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5881         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5882         CHECK(!val->result_ok);
5883         LDKDecodeError err_var = (*val->contents.err);
5884         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5885         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5886         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5887         return err_ref;
5888 }
5889 static jclass LDKSignOrCreationError_SignError_class = NULL;
5890 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
5891 static jclass LDKSignOrCreationError_CreationError_class = NULL;
5892 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
5893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
5894         LDKSignOrCreationError_SignError_class =
5895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
5896         CHECK(LDKSignOrCreationError_SignError_class != NULL);
5897         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
5898         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
5899         LDKSignOrCreationError_CreationError_class =
5900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
5901         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
5902         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
5903         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
5904 }
5905 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5906         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5907         switch(obj->tag) {
5908                 case LDKSignOrCreationError_SignError: {
5909                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
5910                 }
5911                 case LDKSignOrCreationError_CreationError: {
5912                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
5913                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
5914                 }
5915                 default: abort();
5916         }
5917 }
5918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5919         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5920 }
5921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5922         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5923         CHECK(val->result_ok);
5924         LDKInvoice res_var = (*val->contents.result);
5925         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5926         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5927         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5928         return res_ref;
5929 }
5930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5931         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5932         CHECK(!val->result_ok);
5933         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5934         return err_ref;
5935 }
5936 typedef struct LDKMessageSendEventsProvider_JCalls {
5937         atomic_size_t refcnt;
5938         JavaVM *vm;
5939         jweak o;
5940         jmethodID get_and_clear_pending_msg_events_meth;
5941 } LDKMessageSendEventsProvider_JCalls;
5942 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5943         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5944         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5945                 JNIEnv *env;
5946                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5947                 if (get_jenv_res == JNI_EDETACHED) {
5948                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5949                 } else {
5950                         DO_ASSERT(get_jenv_res == JNI_OK);
5951                 }
5952                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5953                 if (get_jenv_res == JNI_EDETACHED) {
5954                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5955                 }
5956                 FREE(j_calls);
5957         }
5958 }
5959 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5960         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5961         JNIEnv *env;
5962         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5963         if (get_jenv_res == JNI_EDETACHED) {
5964                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5965         } else {
5966                 DO_ASSERT(get_jenv_res == JNI_OK);
5967         }
5968         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5969         CHECK(obj != NULL);
5970         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
5971         LDKCVec_MessageSendEventZ ret_constr;
5972         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5973         if (ret_constr.datalen > 0)
5974                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5975         else
5976                 ret_constr.data = NULL;
5977         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5978         for (size_t s = 0; s < ret_constr.datalen; s++) {
5979                 int64_t ret_conv_18 = ret_vals[s];
5980                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
5981                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5982                 ret_constr.data[s] = ret_conv_18_conv;
5983         }
5984         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5985         if (get_jenv_res == JNI_EDETACHED) {
5986                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5987         }
5988         return ret_constr;
5989 }
5990 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
5991         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5992         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5993         return (void*) this_arg;
5994 }
5995 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
5996         jclass c = (*env)->GetObjectClass(env, o);
5997         CHECK(c != NULL);
5998         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5999         atomic_init(&calls->refcnt, 1);
6000         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6001         calls->o = (*env)->NewWeakGlobalRef(env, o);
6002         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6003         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6004
6005         LDKMessageSendEventsProvider ret = {
6006                 .this_arg = (void*) calls,
6007                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6008                 .free = LDKMessageSendEventsProvider_JCalls_free,
6009         };
6010         return ret;
6011 }
6012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6013         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6014         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6015         return (uint64_t)res_ptr;
6016 }
6017 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6018         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6019         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6020         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6021         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6022         for (size_t s = 0; s < ret_var.datalen; s++) {
6023                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6024                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6025                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6026                 ret_arr_ptr[s] = ret_conv_18_ref;
6027         }
6028         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6029         FREE(ret_var.data);
6030         return ret_arr;
6031 }
6032
6033 typedef struct LDKEventHandler_JCalls {
6034         atomic_size_t refcnt;
6035         JavaVM *vm;
6036         jweak o;
6037         jmethodID handle_event_meth;
6038 } LDKEventHandler_JCalls;
6039 static void LDKEventHandler_JCalls_free(void* this_arg) {
6040         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6041         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6042                 JNIEnv *env;
6043                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6044                 if (get_jenv_res == JNI_EDETACHED) {
6045                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6046                 } else {
6047                         DO_ASSERT(get_jenv_res == JNI_OK);
6048                 }
6049                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6050                 if (get_jenv_res == JNI_EDETACHED) {
6051                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6052                 }
6053                 FREE(j_calls);
6054         }
6055 }
6056 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6057         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6058         JNIEnv *env;
6059         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6060         if (get_jenv_res == JNI_EDETACHED) {
6061                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6062         } else {
6063                 DO_ASSERT(get_jenv_res == JNI_OK);
6064         }
6065         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6066         *event_copy = event;
6067         uint64_t event_ref = (uint64_t)event_copy;
6068         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6069         CHECK(obj != NULL);
6070         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6071         if (get_jenv_res == JNI_EDETACHED) {
6072                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6073         }
6074 }
6075 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
6076         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6077         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6078         return (void*) this_arg;
6079 }
6080 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6081         jclass c = (*env)->GetObjectClass(env, o);
6082         CHECK(c != NULL);
6083         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6084         atomic_init(&calls->refcnt, 1);
6085         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6086         calls->o = (*env)->NewWeakGlobalRef(env, o);
6087         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6088         CHECK(calls->handle_event_meth != NULL);
6089
6090         LDKEventHandler ret = {
6091                 .this_arg = (void*) calls,
6092                 .handle_event = handle_event_LDKEventHandler_jcall,
6093                 .free = LDKEventHandler_JCalls_free,
6094         };
6095         return ret;
6096 }
6097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6098         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6099         *res_ptr = LDKEventHandler_init(env, clz, o);
6100         return (uint64_t)res_ptr;
6101 }
6102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6103         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6104         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6105         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6106 }
6107
6108 typedef struct LDKEventsProvider_JCalls {
6109         atomic_size_t refcnt;
6110         JavaVM *vm;
6111         jweak o;
6112         jmethodID process_pending_events_meth;
6113 } LDKEventsProvider_JCalls;
6114 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6115         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6116         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6117                 JNIEnv *env;
6118                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6119                 if (get_jenv_res == JNI_EDETACHED) {
6120                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6121                 } else {
6122                         DO_ASSERT(get_jenv_res == JNI_OK);
6123                 }
6124                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6125                 if (get_jenv_res == JNI_EDETACHED) {
6126                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6127                 }
6128                 FREE(j_calls);
6129         }
6130 }
6131 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6132         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6133         JNIEnv *env;
6134         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6135         if (get_jenv_res == JNI_EDETACHED) {
6136                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6137         } else {
6138                 DO_ASSERT(get_jenv_res == JNI_OK);
6139         }
6140         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6141         *ret = handler;
6142         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6143         CHECK(obj != NULL);
6144         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6145         if (get_jenv_res == JNI_EDETACHED) {
6146                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6147         }
6148 }
6149 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
6150         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6151         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6152         return (void*) this_arg;
6153 }
6154 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6155         jclass c = (*env)->GetObjectClass(env, o);
6156         CHECK(c != NULL);
6157         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6158         atomic_init(&calls->refcnt, 1);
6159         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6160         calls->o = (*env)->NewWeakGlobalRef(env, o);
6161         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6162         CHECK(calls->process_pending_events_meth != NULL);
6163
6164         LDKEventsProvider ret = {
6165                 .this_arg = (void*) calls,
6166                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6167                 .free = LDKEventsProvider_JCalls_free,
6168         };
6169         return ret;
6170 }
6171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6172         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6173         *res_ptr = LDKEventsProvider_init(env, clz, o);
6174         return (uint64_t)res_ptr;
6175 }
6176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6177         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6178         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6179         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6181                 LDKEventHandler_JCalls_clone(handler_conv.this_arg);
6182         }
6183         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6184 }
6185
6186 typedef struct LDKAccess_JCalls {
6187         atomic_size_t refcnt;
6188         JavaVM *vm;
6189         jweak o;
6190         jmethodID get_utxo_meth;
6191 } LDKAccess_JCalls;
6192 static void LDKAccess_JCalls_free(void* this_arg) {
6193         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6194         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6195                 JNIEnv *env;
6196                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6197                 if (get_jenv_res == JNI_EDETACHED) {
6198                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6199                 } else {
6200                         DO_ASSERT(get_jenv_res == JNI_OK);
6201                 }
6202                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6203                 if (get_jenv_res == JNI_EDETACHED) {
6204                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6205                 }
6206                 FREE(j_calls);
6207         }
6208 }
6209 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6210         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6211         JNIEnv *env;
6212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6213         if (get_jenv_res == JNI_EDETACHED) {
6214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6215         } else {
6216                 DO_ASSERT(get_jenv_res == JNI_OK);
6217         }
6218         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6219         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6220         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6221         CHECK(obj != NULL);
6222         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6223         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6224         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6225         if (get_jenv_res == JNI_EDETACHED) {
6226                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6227         }
6228         return ret_conv;
6229 }
6230 static void* LDKAccess_JCalls_clone(const void* this_arg) {
6231         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6232         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6233         return (void*) this_arg;
6234 }
6235 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6236         jclass c = (*env)->GetObjectClass(env, o);
6237         CHECK(c != NULL);
6238         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6239         atomic_init(&calls->refcnt, 1);
6240         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6241         calls->o = (*env)->NewWeakGlobalRef(env, o);
6242         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6243         CHECK(calls->get_utxo_meth != NULL);
6244
6245         LDKAccess ret = {
6246                 .this_arg = (void*) calls,
6247                 .get_utxo = get_utxo_LDKAccess_jcall,
6248                 .free = LDKAccess_JCalls_free,
6249         };
6250         return ret;
6251 }
6252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6253         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6254         *res_ptr = LDKAccess_init(env, clz, o);
6255         return (uint64_t)res_ptr;
6256 }
6257 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) {
6258         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6259         unsigned char genesis_hash_arr[32];
6260         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6261         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6262         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6263         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6264         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6265         return (uint64_t)ret_conv;
6266 }
6267
6268 typedef struct LDKListen_JCalls {
6269         atomic_size_t refcnt;
6270         JavaVM *vm;
6271         jweak o;
6272         jmethodID block_connected_meth;
6273         jmethodID block_disconnected_meth;
6274 } LDKListen_JCalls;
6275 static void LDKListen_JCalls_free(void* this_arg) {
6276         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6277         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6278                 JNIEnv *env;
6279                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6280                 if (get_jenv_res == JNI_EDETACHED) {
6281                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6282                 } else {
6283                         DO_ASSERT(get_jenv_res == JNI_OK);
6284                 }
6285                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6286                 if (get_jenv_res == JNI_EDETACHED) {
6287                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6288                 }
6289                 FREE(j_calls);
6290         }
6291 }
6292 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6293         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6294         JNIEnv *env;
6295         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6296         if (get_jenv_res == JNI_EDETACHED) {
6297                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6298         } else {
6299                 DO_ASSERT(get_jenv_res == JNI_OK);
6300         }
6301         LDKu8slice block_var = block;
6302         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6303         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6305         CHECK(obj != NULL);
6306         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6307         if (get_jenv_res == JNI_EDETACHED) {
6308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6309         }
6310 }
6311 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6312         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6313         JNIEnv *env;
6314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6315         if (get_jenv_res == JNI_EDETACHED) {
6316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6317         } else {
6318                 DO_ASSERT(get_jenv_res == JNI_OK);
6319         }
6320         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6321         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6323         CHECK(obj != NULL);
6324         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6325         if (get_jenv_res == JNI_EDETACHED) {
6326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6327         }
6328 }
6329 static void* LDKListen_JCalls_clone(const void* this_arg) {
6330         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6331         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6332         return (void*) this_arg;
6333 }
6334 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6335         jclass c = (*env)->GetObjectClass(env, o);
6336         CHECK(c != NULL);
6337         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6338         atomic_init(&calls->refcnt, 1);
6339         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6340         calls->o = (*env)->NewWeakGlobalRef(env, o);
6341         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6342         CHECK(calls->block_connected_meth != NULL);
6343         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6344         CHECK(calls->block_disconnected_meth != NULL);
6345
6346         LDKListen ret = {
6347                 .this_arg = (void*) calls,
6348                 .block_connected = block_connected_LDKListen_jcall,
6349                 .block_disconnected = block_disconnected_LDKListen_jcall,
6350                 .free = LDKListen_JCalls_free,
6351         };
6352         return ret;
6353 }
6354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6355         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6356         *res_ptr = LDKListen_init(env, clz, o);
6357         return (uint64_t)res_ptr;
6358 }
6359 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) {
6360         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6361         LDKu8slice block_ref;
6362         block_ref.datalen = (*env)->GetArrayLength(env, block);
6363         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6364         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6365         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6366 }
6367
6368 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) {
6369         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6370         unsigned char header_arr[80];
6371         CHECK((*env)->GetArrayLength(env, header) == 80);
6372         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6373         unsigned char (*header_ref)[80] = &header_arr;
6374         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6375 }
6376
6377 typedef struct LDKConfirm_JCalls {
6378         atomic_size_t refcnt;
6379         JavaVM *vm;
6380         jweak o;
6381         jmethodID transactions_confirmed_meth;
6382         jmethodID transaction_unconfirmed_meth;
6383         jmethodID best_block_updated_meth;
6384         jmethodID get_relevant_txids_meth;
6385 } LDKConfirm_JCalls;
6386 static void LDKConfirm_JCalls_free(void* this_arg) {
6387         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6388         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6389                 JNIEnv *env;
6390                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6391                 if (get_jenv_res == JNI_EDETACHED) {
6392                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6393                 } else {
6394                         DO_ASSERT(get_jenv_res == JNI_OK);
6395                 }
6396                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6397                 if (get_jenv_res == JNI_EDETACHED) {
6398                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6399                 }
6400                 FREE(j_calls);
6401         }
6402 }
6403 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6404         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6405         JNIEnv *env;
6406         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6407         if (get_jenv_res == JNI_EDETACHED) {
6408                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6409         } else {
6410                 DO_ASSERT(get_jenv_res == JNI_OK);
6411         }
6412         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6413         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6414         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6415         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6416         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6417         for (size_t y = 0; y < txdata_var.datalen; y++) {
6418                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6419                 *txdata_conv_24_ref = txdata_var.data[y];
6420                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6421         }
6422         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6423         FREE(txdata_var.data);
6424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6425         CHECK(obj != NULL);
6426         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6427         if (get_jenv_res == JNI_EDETACHED) {
6428                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6429         }
6430 }
6431 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6432         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6433         JNIEnv *env;
6434         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6435         if (get_jenv_res == JNI_EDETACHED) {
6436                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6437         } else {
6438                 DO_ASSERT(get_jenv_res == JNI_OK);
6439         }
6440         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6441         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6442         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6443         CHECK(obj != NULL);
6444         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6445         if (get_jenv_res == JNI_EDETACHED) {
6446                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6447         }
6448 }
6449 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6450         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6451         JNIEnv *env;
6452         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6453         if (get_jenv_res == JNI_EDETACHED) {
6454                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6455         } else {
6456                 DO_ASSERT(get_jenv_res == JNI_OK);
6457         }
6458         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6459         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6460         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6461         CHECK(obj != NULL);
6462         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6463         if (get_jenv_res == JNI_EDETACHED) {
6464                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6465         }
6466 }
6467 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6468         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6469         JNIEnv *env;
6470         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6471         if (get_jenv_res == JNI_EDETACHED) {
6472                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6473         } else {
6474                 DO_ASSERT(get_jenv_res == JNI_OK);
6475         }
6476         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6477         CHECK(obj != NULL);
6478         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6479         LDKCVec_TxidZ ret_constr;
6480         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6481         if (ret_constr.datalen > 0)
6482                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6483         else
6484                 ret_constr.data = NULL;
6485         for (size_t i = 0; i < ret_constr.datalen; i++) {
6486                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6487                 LDKThirtyTwoBytes ret_conv_8_ref;
6488                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6489                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6490                 ret_constr.data[i] = ret_conv_8_ref;
6491         }
6492         if (get_jenv_res == JNI_EDETACHED) {
6493                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6494         }
6495         return ret_constr;
6496 }
6497 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
6498         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6499         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6500         return (void*) this_arg;
6501 }
6502 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6503         jclass c = (*env)->GetObjectClass(env, o);
6504         CHECK(c != NULL);
6505         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6506         atomic_init(&calls->refcnt, 1);
6507         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6508         calls->o = (*env)->NewWeakGlobalRef(env, o);
6509         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6510         CHECK(calls->transactions_confirmed_meth != NULL);
6511         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6512         CHECK(calls->transaction_unconfirmed_meth != NULL);
6513         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6514         CHECK(calls->best_block_updated_meth != NULL);
6515         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6516         CHECK(calls->get_relevant_txids_meth != NULL);
6517
6518         LDKConfirm ret = {
6519                 .this_arg = (void*) calls,
6520                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6521                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6522                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6523                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6524                 .free = LDKConfirm_JCalls_free,
6525         };
6526         return ret;
6527 }
6528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6529         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6530         *res_ptr = LDKConfirm_init(env, clz, o);
6531         return (uint64_t)res_ptr;
6532 }
6533 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) {
6534         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6535         unsigned char header_arr[80];
6536         CHECK((*env)->GetArrayLength(env, header) == 80);
6537         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6538         unsigned char (*header_ref)[80] = &header_arr;
6539         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6540         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6541         if (txdata_constr.datalen > 0)
6542                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6543         else
6544                 txdata_constr.data = NULL;
6545         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6546         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6547                 int64_t txdata_conv_24 = txdata_vals[y];
6548                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6549                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6550                 txdata_constr.data[y] = txdata_conv_24_conv;
6551         }
6552         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6553         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6554 }
6555
6556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6557         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6558         unsigned char txid_arr[32];
6559         CHECK((*env)->GetArrayLength(env, txid) == 32);
6560         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6561         unsigned char (*txid_ref)[32] = &txid_arr;
6562         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6563 }
6564
6565 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) {
6566         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6567         unsigned char header_arr[80];
6568         CHECK((*env)->GetArrayLength(env, header) == 80);
6569         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6570         unsigned char (*header_ref)[80] = &header_arr;
6571         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6572 }
6573
6574 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6575         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6576         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6577         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6578         ;
6579         for (size_t i = 0; i < ret_var.datalen; i++) {
6580                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6581                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6582                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6583         }
6584         FREE(ret_var.data);
6585         return ret_arr;
6586 }
6587
6588 typedef struct LDKFilter_JCalls {
6589         atomic_size_t refcnt;
6590         JavaVM *vm;
6591         jweak o;
6592         jmethodID register_tx_meth;
6593         jmethodID register_output_meth;
6594 } LDKFilter_JCalls;
6595 static void LDKFilter_JCalls_free(void* this_arg) {
6596         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6597         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6598                 JNIEnv *env;
6599                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6600                 if (get_jenv_res == JNI_EDETACHED) {
6601                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6602                 } else {
6603                         DO_ASSERT(get_jenv_res == JNI_OK);
6604                 }
6605                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6606                 if (get_jenv_res == JNI_EDETACHED) {
6607                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6608                 }
6609                 FREE(j_calls);
6610         }
6611 }
6612 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6613         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6614         JNIEnv *env;
6615         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6616         if (get_jenv_res == JNI_EDETACHED) {
6617                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6618         } else {
6619                 DO_ASSERT(get_jenv_res == JNI_OK);
6620         }
6621         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6622         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6623         LDKu8slice script_pubkey_var = script_pubkey;
6624         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6625         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6626         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6627         CHECK(obj != NULL);
6628         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6629         if (get_jenv_res == JNI_EDETACHED) {
6630                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6631         }
6632 }
6633 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6634         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6635         JNIEnv *env;
6636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6637         if (get_jenv_res == JNI_EDETACHED) {
6638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6639         } else {
6640                 DO_ASSERT(get_jenv_res == JNI_OK);
6641         }
6642         LDKWatchedOutput output_var = output;
6643         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6644         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6645         uint64_t output_ref = (uint64_t)output_var.inner;
6646         if (output_var.is_owned) {
6647                 output_ref |= 1;
6648         }
6649         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6650         CHECK(obj != NULL);
6651         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6652         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6653         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6654         if (get_jenv_res == JNI_EDETACHED) {
6655                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6656         }
6657         return ret_conv;
6658 }
6659 static void* LDKFilter_JCalls_clone(const void* this_arg) {
6660         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6661         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6662         return (void*) this_arg;
6663 }
6664 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6665         jclass c = (*env)->GetObjectClass(env, o);
6666         CHECK(c != NULL);
6667         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6668         atomic_init(&calls->refcnt, 1);
6669         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6670         calls->o = (*env)->NewWeakGlobalRef(env, o);
6671         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6672         CHECK(calls->register_tx_meth != NULL);
6673         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6674         CHECK(calls->register_output_meth != NULL);
6675
6676         LDKFilter ret = {
6677                 .this_arg = (void*) calls,
6678                 .register_tx = register_tx_LDKFilter_jcall,
6679                 .register_output = register_output_LDKFilter_jcall,
6680                 .free = LDKFilter_JCalls_free,
6681         };
6682         return ret;
6683 }
6684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6685         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6686         *res_ptr = LDKFilter_init(env, clz, o);
6687         return (uint64_t)res_ptr;
6688 }
6689 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) {
6690         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6691         unsigned char txid_arr[32];
6692         CHECK((*env)->GetArrayLength(env, txid) == 32);
6693         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6694         unsigned char (*txid_ref)[32] = &txid_arr;
6695         LDKu8slice script_pubkey_ref;
6696         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6697         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6698         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6699         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6700 }
6701
6702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6703         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6704         LDKWatchedOutput output_conv;
6705         output_conv.inner = (void*)(output & (~1));
6706         output_conv.is_owned = (output & 1) || (output == 0);
6707         output_conv = WatchedOutput_clone(&output_conv);
6708         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6709         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6710         uint64_t ret_ref = (uint64_t)ret_copy;
6711         return ret_ref;
6712 }
6713
6714 typedef struct LDKPersist_JCalls {
6715         atomic_size_t refcnt;
6716         JavaVM *vm;
6717         jweak o;
6718         jmethodID persist_new_channel_meth;
6719         jmethodID update_persisted_channel_meth;
6720 } LDKPersist_JCalls;
6721 static void LDKPersist_JCalls_free(void* this_arg) {
6722         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6723         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6732                 if (get_jenv_res == JNI_EDETACHED) {
6733                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6734                 }
6735                 FREE(j_calls);
6736         }
6737 }
6738 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6739         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6740         JNIEnv *env;
6741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6742         if (get_jenv_res == JNI_EDETACHED) {
6743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6744         } else {
6745                 DO_ASSERT(get_jenv_res == JNI_OK);
6746         }
6747         LDKOutPoint id_var = id;
6748         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6749         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6750         uint64_t id_ref = (uint64_t)id_var.inner;
6751         if (id_var.is_owned) {
6752                 id_ref |= 1;
6753         }
6754         LDKChannelMonitor data_var = *data;
6755         data_var = ChannelMonitor_clone(data);
6756         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6757         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6758         uint64_t data_ref = (uint64_t)data_var.inner;
6759         if (data_var.is_owned) {
6760                 data_ref |= 1;
6761         }
6762         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6763         CHECK(obj != NULL);
6764         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6765         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6766         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6767         if (get_jenv_res == JNI_EDETACHED) {
6768                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6769         }
6770         return ret_conv;
6771 }
6772 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6773         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6774         JNIEnv *env;
6775         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6776         if (get_jenv_res == JNI_EDETACHED) {
6777                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6778         } else {
6779                 DO_ASSERT(get_jenv_res == JNI_OK);
6780         }
6781         LDKOutPoint id_var = id;
6782         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6783         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6784         uint64_t id_ref = (uint64_t)id_var.inner;
6785         if (id_var.is_owned) {
6786                 id_ref |= 1;
6787         }
6788         LDKChannelMonitorUpdate update_var = *update;
6789         update_var = ChannelMonitorUpdate_clone(update);
6790         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6791         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6792         uint64_t update_ref = (uint64_t)update_var.inner;
6793         if (update_var.is_owned) {
6794                 update_ref |= 1;
6795         }
6796         LDKChannelMonitor data_var = *data;
6797         data_var = ChannelMonitor_clone(data);
6798         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6799         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6800         uint64_t data_ref = (uint64_t)data_var.inner;
6801         if (data_var.is_owned) {
6802                 data_ref |= 1;
6803         }
6804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6805         CHECK(obj != NULL);
6806         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
6807         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6808         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6809         if (get_jenv_res == JNI_EDETACHED) {
6810                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6811         }
6812         return ret_conv;
6813 }
6814 static void* LDKPersist_JCalls_clone(const void* this_arg) {
6815         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6816         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6817         return (void*) this_arg;
6818 }
6819 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
6820         jclass c = (*env)->GetObjectClass(env, o);
6821         CHECK(c != NULL);
6822         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
6823         atomic_init(&calls->refcnt, 1);
6824         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6825         calls->o = (*env)->NewWeakGlobalRef(env, o);
6826         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
6827         CHECK(calls->persist_new_channel_meth != NULL);
6828         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
6829         CHECK(calls->update_persisted_channel_meth != NULL);
6830
6831         LDKPersist ret = {
6832                 .this_arg = (void*) calls,
6833                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
6834                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
6835                 .free = LDKPersist_JCalls_free,
6836         };
6837         return ret;
6838 }
6839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
6840         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
6841         *res_ptr = LDKPersist_init(env, clz, o);
6842         return (uint64_t)res_ptr;
6843 }
6844 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) {
6845         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6846         LDKOutPoint id_conv;
6847         id_conv.inner = (void*)(id & (~1));
6848         id_conv.is_owned = (id & 1) || (id == 0);
6849         id_conv = OutPoint_clone(&id_conv);
6850         LDKChannelMonitor data_conv;
6851         data_conv.inner = (void*)(data & (~1));
6852         data_conv.is_owned = false;
6853         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6854         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
6855         return (uint64_t)ret_conv;
6856 }
6857
6858 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) {
6859         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6860         LDKOutPoint id_conv;
6861         id_conv.inner = (void*)(id & (~1));
6862         id_conv.is_owned = (id & 1) || (id == 0);
6863         id_conv = OutPoint_clone(&id_conv);
6864         LDKChannelMonitorUpdate update_conv;
6865         update_conv.inner = (void*)(update & (~1));
6866         update_conv.is_owned = false;
6867         LDKChannelMonitor data_conv;
6868         data_conv.inner = (void*)(data & (~1));
6869         data_conv.is_owned = false;
6870         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6871         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
6872         return (uint64_t)ret_conv;
6873 }
6874
6875 typedef struct LDKChannelMessageHandler_JCalls {
6876         atomic_size_t refcnt;
6877         JavaVM *vm;
6878         jweak o;
6879         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6880         jmethodID handle_open_channel_meth;
6881         jmethodID handle_accept_channel_meth;
6882         jmethodID handle_funding_created_meth;
6883         jmethodID handle_funding_signed_meth;
6884         jmethodID handle_funding_locked_meth;
6885         jmethodID handle_shutdown_meth;
6886         jmethodID handle_closing_signed_meth;
6887         jmethodID handle_update_add_htlc_meth;
6888         jmethodID handle_update_fulfill_htlc_meth;
6889         jmethodID handle_update_fail_htlc_meth;
6890         jmethodID handle_update_fail_malformed_htlc_meth;
6891         jmethodID handle_commitment_signed_meth;
6892         jmethodID handle_revoke_and_ack_meth;
6893         jmethodID handle_update_fee_meth;
6894         jmethodID handle_announcement_signatures_meth;
6895         jmethodID peer_disconnected_meth;
6896         jmethodID peer_connected_meth;
6897         jmethodID handle_channel_reestablish_meth;
6898         jmethodID handle_channel_update_meth;
6899         jmethodID handle_error_meth;
6900 } LDKChannelMessageHandler_JCalls;
6901 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
6902         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6903         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6904                 JNIEnv *env;
6905                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6906                 if (get_jenv_res == JNI_EDETACHED) {
6907                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6908                 } else {
6909                         DO_ASSERT(get_jenv_res == JNI_OK);
6910                 }
6911                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6912                 if (get_jenv_res == JNI_EDETACHED) {
6913                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6914                 }
6915                 FREE(j_calls);
6916         }
6917 }
6918 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
6919         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6920         JNIEnv *env;
6921         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6922         if (get_jenv_res == JNI_EDETACHED) {
6923                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6924         } else {
6925                 DO_ASSERT(get_jenv_res == JNI_OK);
6926         }
6927         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6928         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6929         LDKInitFeatures their_features_var = their_features;
6930         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6931         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6932         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6933         if (their_features_var.is_owned) {
6934                 their_features_ref |= 1;
6935         }
6936         LDKOpenChannel msg_var = *msg;
6937         msg_var = OpenChannel_clone(msg);
6938         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6939         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6940         uint64_t msg_ref = (uint64_t)msg_var.inner;
6941         if (msg_var.is_owned) {
6942                 msg_ref |= 1;
6943         }
6944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6945         CHECK(obj != NULL);
6946         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6947         if (get_jenv_res == JNI_EDETACHED) {
6948                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6949         }
6950 }
6951 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6952         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6953         JNIEnv *env;
6954         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6955         if (get_jenv_res == JNI_EDETACHED) {
6956                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6957         } else {
6958                 DO_ASSERT(get_jenv_res == JNI_OK);
6959         }
6960         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6961         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6962         LDKInitFeatures their_features_var = their_features;
6963         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6964         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6965         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6966         if (their_features_var.is_owned) {
6967                 their_features_ref |= 1;
6968         }
6969         LDKAcceptChannel msg_var = *msg;
6970         msg_var = AcceptChannel_clone(msg);
6971         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6972         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6973         uint64_t msg_ref = (uint64_t)msg_var.inner;
6974         if (msg_var.is_owned) {
6975                 msg_ref |= 1;
6976         }
6977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6978         CHECK(obj != NULL);
6979         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6980         if (get_jenv_res == JNI_EDETACHED) {
6981                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6982         }
6983 }
6984 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6985         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6986         JNIEnv *env;
6987         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6988         if (get_jenv_res == JNI_EDETACHED) {
6989                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6990         } else {
6991                 DO_ASSERT(get_jenv_res == JNI_OK);
6992         }
6993         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
6994         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
6995         LDKFundingCreated msg_var = *msg;
6996         msg_var = FundingCreated_clone(msg);
6997         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6998         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6999         uint64_t msg_ref = (uint64_t)msg_var.inner;
7000         if (msg_var.is_owned) {
7001                 msg_ref |= 1;
7002         }
7003         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7004         CHECK(obj != NULL);
7005         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7006         if (get_jenv_res == JNI_EDETACHED) {
7007                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7008         }
7009 }
7010 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7011         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7012         JNIEnv *env;
7013         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7014         if (get_jenv_res == JNI_EDETACHED) {
7015                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7016         } else {
7017                 DO_ASSERT(get_jenv_res == JNI_OK);
7018         }
7019         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7020         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7021         LDKFundingSigned msg_var = *msg;
7022         msg_var = FundingSigned_clone(msg);
7023         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7024         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7025         uint64_t msg_ref = (uint64_t)msg_var.inner;
7026         if (msg_var.is_owned) {
7027                 msg_ref |= 1;
7028         }
7029         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7030         CHECK(obj != NULL);
7031         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7032         if (get_jenv_res == JNI_EDETACHED) {
7033                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7034         }
7035 }
7036 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7037         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7038         JNIEnv *env;
7039         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7040         if (get_jenv_res == JNI_EDETACHED) {
7041                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7042         } else {
7043                 DO_ASSERT(get_jenv_res == JNI_OK);
7044         }
7045         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7046         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7047         LDKFundingLocked msg_var = *msg;
7048         msg_var = FundingLocked_clone(msg);
7049         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7050         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7051         uint64_t msg_ref = (uint64_t)msg_var.inner;
7052         if (msg_var.is_owned) {
7053                 msg_ref |= 1;
7054         }
7055         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7056         CHECK(obj != NULL);
7057         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7058         if (get_jenv_res == JNI_EDETACHED) {
7059                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7060         }
7061 }
7062 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7063         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7064         JNIEnv *env;
7065         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7066         if (get_jenv_res == JNI_EDETACHED) {
7067                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7068         } else {
7069                 DO_ASSERT(get_jenv_res == JNI_OK);
7070         }
7071         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7072         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7073         LDKInitFeatures their_features_var = *their_features;
7074         their_features_var = InitFeatures_clone(their_features);
7075         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7076         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7077         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7078         if (their_features_var.is_owned) {
7079                 their_features_ref |= 1;
7080         }
7081         LDKShutdown msg_var = *msg;
7082         msg_var = Shutdown_clone(msg);
7083         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7084         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7085         uint64_t msg_ref = (uint64_t)msg_var.inner;
7086         if (msg_var.is_owned) {
7087                 msg_ref |= 1;
7088         }
7089         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7090         CHECK(obj != NULL);
7091         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7092         if (get_jenv_res == JNI_EDETACHED) {
7093                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7094         }
7095 }
7096 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7097         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7098         JNIEnv *env;
7099         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7100         if (get_jenv_res == JNI_EDETACHED) {
7101                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7102         } else {
7103                 DO_ASSERT(get_jenv_res == JNI_OK);
7104         }
7105         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7106         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7107         LDKClosingSigned msg_var = *msg;
7108         msg_var = ClosingSigned_clone(msg);
7109         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7110         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7111         uint64_t msg_ref = (uint64_t)msg_var.inner;
7112         if (msg_var.is_owned) {
7113                 msg_ref |= 1;
7114         }
7115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7116         CHECK(obj != NULL);
7117         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7118         if (get_jenv_res == JNI_EDETACHED) {
7119                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7120         }
7121 }
7122 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7123         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7124         JNIEnv *env;
7125         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7126         if (get_jenv_res == JNI_EDETACHED) {
7127                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7128         } else {
7129                 DO_ASSERT(get_jenv_res == JNI_OK);
7130         }
7131         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7132         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7133         LDKUpdateAddHTLC msg_var = *msg;
7134         msg_var = UpdateAddHTLC_clone(msg);
7135         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7136         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7137         uint64_t msg_ref = (uint64_t)msg_var.inner;
7138         if (msg_var.is_owned) {
7139                 msg_ref |= 1;
7140         }
7141         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7142         CHECK(obj != NULL);
7143         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7144         if (get_jenv_res == JNI_EDETACHED) {
7145                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7146         }
7147 }
7148 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7149         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7150         JNIEnv *env;
7151         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7152         if (get_jenv_res == JNI_EDETACHED) {
7153                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7154         } else {
7155                 DO_ASSERT(get_jenv_res == JNI_OK);
7156         }
7157         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7158         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7159         LDKUpdateFulfillHTLC msg_var = *msg;
7160         msg_var = UpdateFulfillHTLC_clone(msg);
7161         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7162         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7163         uint64_t msg_ref = (uint64_t)msg_var.inner;
7164         if (msg_var.is_owned) {
7165                 msg_ref |= 1;
7166         }
7167         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7168         CHECK(obj != NULL);
7169         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7170         if (get_jenv_res == JNI_EDETACHED) {
7171                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7172         }
7173 }
7174 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7175         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7176         JNIEnv *env;
7177         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7178         if (get_jenv_res == JNI_EDETACHED) {
7179                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7180         } else {
7181                 DO_ASSERT(get_jenv_res == JNI_OK);
7182         }
7183         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7184         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7185         LDKUpdateFailHTLC msg_var = *msg;
7186         msg_var = UpdateFailHTLC_clone(msg);
7187         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7188         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7189         uint64_t msg_ref = (uint64_t)msg_var.inner;
7190         if (msg_var.is_owned) {
7191                 msg_ref |= 1;
7192         }
7193         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7194         CHECK(obj != NULL);
7195         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7196         if (get_jenv_res == JNI_EDETACHED) {
7197                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7198         }
7199 }
7200 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7201         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7202         JNIEnv *env;
7203         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7204         if (get_jenv_res == JNI_EDETACHED) {
7205                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7206         } else {
7207                 DO_ASSERT(get_jenv_res == JNI_OK);
7208         }
7209         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7210         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7211         LDKUpdateFailMalformedHTLC msg_var = *msg;
7212         msg_var = UpdateFailMalformedHTLC_clone(msg);
7213         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7214         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7215         uint64_t msg_ref = (uint64_t)msg_var.inner;
7216         if (msg_var.is_owned) {
7217                 msg_ref |= 1;
7218         }
7219         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7220         CHECK(obj != NULL);
7221         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7222         if (get_jenv_res == JNI_EDETACHED) {
7223                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7224         }
7225 }
7226 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7227         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7228         JNIEnv *env;
7229         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7230         if (get_jenv_res == JNI_EDETACHED) {
7231                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7232         } else {
7233                 DO_ASSERT(get_jenv_res == JNI_OK);
7234         }
7235         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7236         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7237         LDKCommitmentSigned msg_var = *msg;
7238         msg_var = CommitmentSigned_clone(msg);
7239         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7240         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7241         uint64_t msg_ref = (uint64_t)msg_var.inner;
7242         if (msg_var.is_owned) {
7243                 msg_ref |= 1;
7244         }
7245         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7246         CHECK(obj != NULL);
7247         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7248         if (get_jenv_res == JNI_EDETACHED) {
7249                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7250         }
7251 }
7252 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7253         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7254         JNIEnv *env;
7255         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7256         if (get_jenv_res == JNI_EDETACHED) {
7257                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7258         } else {
7259                 DO_ASSERT(get_jenv_res == JNI_OK);
7260         }
7261         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7262         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7263         LDKRevokeAndACK msg_var = *msg;
7264         msg_var = RevokeAndACK_clone(msg);
7265         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7266         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7267         uint64_t msg_ref = (uint64_t)msg_var.inner;
7268         if (msg_var.is_owned) {
7269                 msg_ref |= 1;
7270         }
7271         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7272         CHECK(obj != NULL);
7273         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7274         if (get_jenv_res == JNI_EDETACHED) {
7275                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7276         }
7277 }
7278 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7279         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7280         JNIEnv *env;
7281         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7282         if (get_jenv_res == JNI_EDETACHED) {
7283                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7284         } else {
7285                 DO_ASSERT(get_jenv_res == JNI_OK);
7286         }
7287         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7288         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7289         LDKUpdateFee msg_var = *msg;
7290         msg_var = UpdateFee_clone(msg);
7291         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7292         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7293         uint64_t msg_ref = (uint64_t)msg_var.inner;
7294         if (msg_var.is_owned) {
7295                 msg_ref |= 1;
7296         }
7297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7298         CHECK(obj != NULL);
7299         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7300         if (get_jenv_res == JNI_EDETACHED) {
7301                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7302         }
7303 }
7304 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7305         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7306         JNIEnv *env;
7307         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7308         if (get_jenv_res == JNI_EDETACHED) {
7309                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7310         } else {
7311                 DO_ASSERT(get_jenv_res == JNI_OK);
7312         }
7313         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7314         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7315         LDKAnnouncementSignatures msg_var = *msg;
7316         msg_var = AnnouncementSignatures_clone(msg);
7317         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7318         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7319         uint64_t msg_ref = (uint64_t)msg_var.inner;
7320         if (msg_var.is_owned) {
7321                 msg_ref |= 1;
7322         }
7323         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7324         CHECK(obj != NULL);
7325         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7326         if (get_jenv_res == JNI_EDETACHED) {
7327                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7328         }
7329 }
7330 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7331         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7332         JNIEnv *env;
7333         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7334         if (get_jenv_res == JNI_EDETACHED) {
7335                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7336         } else {
7337                 DO_ASSERT(get_jenv_res == JNI_OK);
7338         }
7339         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7340         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7341         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7342         CHECK(obj != NULL);
7343         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7344         if (get_jenv_res == JNI_EDETACHED) {
7345                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7346         }
7347 }
7348 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7349         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7350         JNIEnv *env;
7351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7352         if (get_jenv_res == JNI_EDETACHED) {
7353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7354         } else {
7355                 DO_ASSERT(get_jenv_res == JNI_OK);
7356         }
7357         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7358         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7359         LDKInit msg_var = *msg;
7360         msg_var = Init_clone(msg);
7361         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7362         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7363         uint64_t msg_ref = (uint64_t)msg_var.inner;
7364         if (msg_var.is_owned) {
7365                 msg_ref |= 1;
7366         }
7367         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7368         CHECK(obj != NULL);
7369         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7370         if (get_jenv_res == JNI_EDETACHED) {
7371                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7372         }
7373 }
7374 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7375         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7376         JNIEnv *env;
7377         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7378         if (get_jenv_res == JNI_EDETACHED) {
7379                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7380         } else {
7381                 DO_ASSERT(get_jenv_res == JNI_OK);
7382         }
7383         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7384         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7385         LDKChannelReestablish msg_var = *msg;
7386         msg_var = ChannelReestablish_clone(msg);
7387         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7388         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7389         uint64_t msg_ref = (uint64_t)msg_var.inner;
7390         if (msg_var.is_owned) {
7391                 msg_ref |= 1;
7392         }
7393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7394         CHECK(obj != NULL);
7395         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7396         if (get_jenv_res == JNI_EDETACHED) {
7397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7398         }
7399 }
7400 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * 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         LDKChannelUpdate msg_var = *msg;
7412         msg_var = ChannelUpdate_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_channel_update_meth, their_node_id_arr, msg_ref);
7422         if (get_jenv_res == JNI_EDETACHED) {
7423                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7424         }
7425 }
7426 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7427         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7428         JNIEnv *env;
7429         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7430         if (get_jenv_res == JNI_EDETACHED) {
7431                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7432         } else {
7433                 DO_ASSERT(get_jenv_res == JNI_OK);
7434         }
7435         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7436         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7437         LDKErrorMessage msg_var = *msg;
7438         msg_var = ErrorMessage_clone(msg);
7439         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7440         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7441         uint64_t msg_ref = (uint64_t)msg_var.inner;
7442         if (msg_var.is_owned) {
7443                 msg_ref |= 1;
7444         }
7445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7446         CHECK(obj != NULL);
7447         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7448         if (get_jenv_res == JNI_EDETACHED) {
7449                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7450         }
7451 }
7452 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
7453         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7454         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7455         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7456         return (void*) this_arg;
7457 }
7458 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7459         jclass c = (*env)->GetObjectClass(env, o);
7460         CHECK(c != NULL);
7461         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7462         atomic_init(&calls->refcnt, 1);
7463         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7464         calls->o = (*env)->NewWeakGlobalRef(env, o);
7465         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7466         CHECK(calls->handle_open_channel_meth != NULL);
7467         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7468         CHECK(calls->handle_accept_channel_meth != NULL);
7469         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7470         CHECK(calls->handle_funding_created_meth != NULL);
7471         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7472         CHECK(calls->handle_funding_signed_meth != NULL);
7473         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7474         CHECK(calls->handle_funding_locked_meth != NULL);
7475         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7476         CHECK(calls->handle_shutdown_meth != NULL);
7477         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7478         CHECK(calls->handle_closing_signed_meth != NULL);
7479         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7480         CHECK(calls->handle_update_add_htlc_meth != NULL);
7481         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7482         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7483         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7484         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7485         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7486         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7487         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7488         CHECK(calls->handle_commitment_signed_meth != NULL);
7489         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7490         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7491         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7492         CHECK(calls->handle_update_fee_meth != NULL);
7493         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7494         CHECK(calls->handle_announcement_signatures_meth != NULL);
7495         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7496         CHECK(calls->peer_disconnected_meth != NULL);
7497         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7498         CHECK(calls->peer_connected_meth != NULL);
7499         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7500         CHECK(calls->handle_channel_reestablish_meth != NULL);
7501         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7502         CHECK(calls->handle_channel_update_meth != NULL);
7503         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7504         CHECK(calls->handle_error_meth != NULL);
7505
7506         LDKChannelMessageHandler ret = {
7507                 .this_arg = (void*) calls,
7508                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7509                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7510                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7511                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7512                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7513                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7514                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7515                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7516                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7517                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7518                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7519                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7520                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7521                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7522                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7523                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7524                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7525                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7526                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7527                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7528                 .free = LDKChannelMessageHandler_JCalls_free,
7529                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7530         };
7531         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7532         return ret;
7533 }
7534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7535         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7536         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7537         return (uint64_t)res_ptr;
7538 }
7539 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) {
7540         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7541         LDKPublicKey their_node_id_ref;
7542         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7543         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7544         LDKInitFeatures their_features_conv;
7545         their_features_conv.inner = (void*)(their_features & (~1));
7546         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7547         their_features_conv = InitFeatures_clone(&their_features_conv);
7548         LDKOpenChannel msg_conv;
7549         msg_conv.inner = (void*)(msg & (~1));
7550         msg_conv.is_owned = false;
7551         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7552 }
7553
7554 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) {
7555         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7556         LDKPublicKey their_node_id_ref;
7557         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7558         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7559         LDKInitFeatures their_features_conv;
7560         their_features_conv.inner = (void*)(their_features & (~1));
7561         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7562         their_features_conv = InitFeatures_clone(&their_features_conv);
7563         LDKAcceptChannel msg_conv;
7564         msg_conv.inner = (void*)(msg & (~1));
7565         msg_conv.is_owned = false;
7566         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7567 }
7568
7569 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) {
7570         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7571         LDKPublicKey their_node_id_ref;
7572         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7573         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7574         LDKFundingCreated msg_conv;
7575         msg_conv.inner = (void*)(msg & (~1));
7576         msg_conv.is_owned = false;
7577         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7578 }
7579
7580 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) {
7581         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7582         LDKPublicKey their_node_id_ref;
7583         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7584         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7585         LDKFundingSigned msg_conv;
7586         msg_conv.inner = (void*)(msg & (~1));
7587         msg_conv.is_owned = false;
7588         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7589 }
7590
7591 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) {
7592         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7593         LDKPublicKey their_node_id_ref;
7594         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7595         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7596         LDKFundingLocked msg_conv;
7597         msg_conv.inner = (void*)(msg & (~1));
7598         msg_conv.is_owned = false;
7599         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7600 }
7601
7602 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) {
7603         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7604         LDKPublicKey their_node_id_ref;
7605         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7606         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7607         LDKInitFeatures their_features_conv;
7608         their_features_conv.inner = (void*)(their_features & (~1));
7609         their_features_conv.is_owned = false;
7610         LDKShutdown msg_conv;
7611         msg_conv.inner = (void*)(msg & (~1));
7612         msg_conv.is_owned = false;
7613         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7614 }
7615
7616 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) {
7617         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7618         LDKPublicKey their_node_id_ref;
7619         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7620         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7621         LDKClosingSigned msg_conv;
7622         msg_conv.inner = (void*)(msg & (~1));
7623         msg_conv.is_owned = false;
7624         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7625 }
7626
7627 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) {
7628         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7629         LDKPublicKey their_node_id_ref;
7630         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7631         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7632         LDKUpdateAddHTLC msg_conv;
7633         msg_conv.inner = (void*)(msg & (~1));
7634         msg_conv.is_owned = false;
7635         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7636 }
7637
7638 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) {
7639         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7640         LDKPublicKey their_node_id_ref;
7641         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7642         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7643         LDKUpdateFulfillHTLC msg_conv;
7644         msg_conv.inner = (void*)(msg & (~1));
7645         msg_conv.is_owned = false;
7646         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7647 }
7648
7649 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) {
7650         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7651         LDKPublicKey their_node_id_ref;
7652         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7653         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7654         LDKUpdateFailHTLC msg_conv;
7655         msg_conv.inner = (void*)(msg & (~1));
7656         msg_conv.is_owned = false;
7657         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7658 }
7659
7660 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) {
7661         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7662         LDKPublicKey their_node_id_ref;
7663         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7664         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7665         LDKUpdateFailMalformedHTLC msg_conv;
7666         msg_conv.inner = (void*)(msg & (~1));
7667         msg_conv.is_owned = false;
7668         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7669 }
7670
7671 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) {
7672         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7673         LDKPublicKey their_node_id_ref;
7674         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7675         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7676         LDKCommitmentSigned msg_conv;
7677         msg_conv.inner = (void*)(msg & (~1));
7678         msg_conv.is_owned = false;
7679         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7680 }
7681
7682 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) {
7683         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7684         LDKPublicKey their_node_id_ref;
7685         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7686         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7687         LDKRevokeAndACK msg_conv;
7688         msg_conv.inner = (void*)(msg & (~1));
7689         msg_conv.is_owned = false;
7690         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7691 }
7692
7693 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) {
7694         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7695         LDKPublicKey their_node_id_ref;
7696         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7697         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7698         LDKUpdateFee msg_conv;
7699         msg_conv.inner = (void*)(msg & (~1));
7700         msg_conv.is_owned = false;
7701         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7702 }
7703
7704 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) {
7705         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7706         LDKPublicKey their_node_id_ref;
7707         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7708         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7709         LDKAnnouncementSignatures msg_conv;
7710         msg_conv.inner = (void*)(msg & (~1));
7711         msg_conv.is_owned = false;
7712         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7713 }
7714
7715 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) {
7716         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7717         LDKPublicKey their_node_id_ref;
7718         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7719         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7720         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7721 }
7722
7723 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) {
7724         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7725         LDKPublicKey their_node_id_ref;
7726         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7727         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7728         LDKInit msg_conv;
7729         msg_conv.inner = (void*)(msg & (~1));
7730         msg_conv.is_owned = false;
7731         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7732 }
7733
7734 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) {
7735         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7736         LDKPublicKey their_node_id_ref;
7737         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7738         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7739         LDKChannelReestablish msg_conv;
7740         msg_conv.inner = (void*)(msg & (~1));
7741         msg_conv.is_owned = false;
7742         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7743 }
7744
7745 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) {
7746         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7747         LDKPublicKey their_node_id_ref;
7748         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7749         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7750         LDKChannelUpdate msg_conv;
7751         msg_conv.inner = (void*)(msg & (~1));
7752         msg_conv.is_owned = false;
7753         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7754 }
7755
7756 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) {
7757         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7758         LDKPublicKey their_node_id_ref;
7759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7761         LDKErrorMessage msg_conv;
7762         msg_conv.inner = (void*)(msg & (~1));
7763         msg_conv.is_owned = false;
7764         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7765 }
7766
7767 typedef struct LDKRoutingMessageHandler_JCalls {
7768         atomic_size_t refcnt;
7769         JavaVM *vm;
7770         jweak o;
7771         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7772         jmethodID handle_node_announcement_meth;
7773         jmethodID handle_channel_announcement_meth;
7774         jmethodID handle_channel_update_meth;
7775         jmethodID handle_htlc_fail_channel_update_meth;
7776         jmethodID get_next_channel_announcements_meth;
7777         jmethodID get_next_node_announcements_meth;
7778         jmethodID sync_routing_table_meth;
7779         jmethodID handle_reply_channel_range_meth;
7780         jmethodID handle_reply_short_channel_ids_end_meth;
7781         jmethodID handle_query_channel_range_meth;
7782         jmethodID handle_query_short_channel_ids_meth;
7783 } LDKRoutingMessageHandler_JCalls;
7784 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
7785         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7786         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7787                 JNIEnv *env;
7788                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7789                 if (get_jenv_res == JNI_EDETACHED) {
7790                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7791                 } else {
7792                         DO_ASSERT(get_jenv_res == JNI_OK);
7793                 }
7794                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7795                 if (get_jenv_res == JNI_EDETACHED) {
7796                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7797                 }
7798                 FREE(j_calls);
7799         }
7800 }
7801 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
7802         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7803         JNIEnv *env;
7804         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7805         if (get_jenv_res == JNI_EDETACHED) {
7806                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7807         } else {
7808                 DO_ASSERT(get_jenv_res == JNI_OK);
7809         }
7810         LDKNodeAnnouncement msg_var = *msg;
7811         msg_var = NodeAnnouncement_clone(msg);
7812         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7813         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7814         uint64_t msg_ref = (uint64_t)msg_var.inner;
7815         if (msg_var.is_owned) {
7816                 msg_ref |= 1;
7817         }
7818         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7819         CHECK(obj != NULL);
7820         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
7821         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7822         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7823         if (get_jenv_res == JNI_EDETACHED) {
7824                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7825         }
7826         return ret_conv;
7827 }
7828 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
7829         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7830         JNIEnv *env;
7831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7832         if (get_jenv_res == JNI_EDETACHED) {
7833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7834         } else {
7835                 DO_ASSERT(get_jenv_res == JNI_OK);
7836         }
7837         LDKChannelAnnouncement msg_var = *msg;
7838         msg_var = ChannelAnnouncement_clone(msg);
7839         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7840         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7841         uint64_t msg_ref = (uint64_t)msg_var.inner;
7842         if (msg_var.is_owned) {
7843                 msg_ref |= 1;
7844         }
7845         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7846         CHECK(obj != NULL);
7847         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
7848         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7849         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7850         if (get_jenv_res == JNI_EDETACHED) {
7851                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7852         }
7853         return ret_conv;
7854 }
7855 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
7856         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7857         JNIEnv *env;
7858         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7859         if (get_jenv_res == JNI_EDETACHED) {
7860                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7861         } else {
7862                 DO_ASSERT(get_jenv_res == JNI_OK);
7863         }
7864         LDKChannelUpdate msg_var = *msg;
7865         msg_var = ChannelUpdate_clone(msg);
7866         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7867         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7868         uint64_t msg_ref = (uint64_t)msg_var.inner;
7869         if (msg_var.is_owned) {
7870                 msg_ref |= 1;
7871         }
7872         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7873         CHECK(obj != NULL);
7874         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
7875         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
7876         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7877         if (get_jenv_res == JNI_EDETACHED) {
7878                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7879         }
7880         return ret_conv;
7881 }
7882 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
7883         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7884         JNIEnv *env;
7885         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7886         if (get_jenv_res == JNI_EDETACHED) {
7887                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7888         } else {
7889                 DO_ASSERT(get_jenv_res == JNI_OK);
7890         }
7891         uint64_t ret_update = (uint64_t)update;
7892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7893         CHECK(obj != NULL);
7894         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
7895         if (get_jenv_res == JNI_EDETACHED) {
7896                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7897         }
7898 }
7899 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
7900         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7901         JNIEnv *env;
7902         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7903         if (get_jenv_res == JNI_EDETACHED) {
7904                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7905         } else {
7906                 DO_ASSERT(get_jenv_res == JNI_OK);
7907         }
7908         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7909         CHECK(obj != NULL);
7910         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
7911         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
7912         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7913         if (ret_constr.datalen > 0)
7914                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
7915         else
7916                 ret_constr.data = NULL;
7917         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7918         for (size_t l = 0; l < ret_constr.datalen; l++) {
7919                 int64_t ret_conv_63 = ret_vals[l];
7920                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
7921                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
7922                 ret_constr.data[l] = ret_conv_63_conv;
7923         }
7924         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7925         if (get_jenv_res == JNI_EDETACHED) {
7926                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7927         }
7928         return ret_constr;
7929 }
7930 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
7931         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7932         JNIEnv *env;
7933         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7934         if (get_jenv_res == JNI_EDETACHED) {
7935                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7936         } else {
7937                 DO_ASSERT(get_jenv_res == JNI_OK);
7938         }
7939         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
7940         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
7941         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7942         CHECK(obj != NULL);
7943         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
7944         LDKCVec_NodeAnnouncementZ ret_constr;
7945         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7946         if (ret_constr.datalen > 0)
7947                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
7948         else
7949                 ret_constr.data = NULL;
7950         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7951         for (size_t s = 0; s < ret_constr.datalen; s++) {
7952                 int64_t ret_conv_18 = ret_vals[s];
7953                 LDKNodeAnnouncement ret_conv_18_conv;
7954                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
7955                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
7956                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
7957                 ret_constr.data[s] = ret_conv_18_conv;
7958         }
7959         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7960         if (get_jenv_res == JNI_EDETACHED) {
7961                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7962         }
7963         return ret_constr;
7964 }
7965 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
7966         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7967         JNIEnv *env;
7968         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7969         if (get_jenv_res == JNI_EDETACHED) {
7970                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7971         } else {
7972                 DO_ASSERT(get_jenv_res == JNI_OK);
7973         }
7974         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7975         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7976         LDKInit init_var = *init;
7977         init_var = Init_clone(init);
7978         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7979         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7980         uint64_t init_ref = (uint64_t)init_var.inner;
7981         if (init_var.is_owned) {
7982                 init_ref |= 1;
7983         }
7984         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7985         CHECK(obj != NULL);
7986         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
7987         if (get_jenv_res == JNI_EDETACHED) {
7988                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7989         }
7990 }
7991 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
7992         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7993         JNIEnv *env;
7994         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7995         if (get_jenv_res == JNI_EDETACHED) {
7996                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7997         } else {
7998                 DO_ASSERT(get_jenv_res == JNI_OK);
7999         }
8000         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8001         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8002         LDKReplyChannelRange msg_var = msg;
8003         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8004         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8005         uint64_t msg_ref = (uint64_t)msg_var.inner;
8006         if (msg_var.is_owned) {
8007                 msg_ref |= 1;
8008         }
8009         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8010         CHECK(obj != NULL);
8011         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8012         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8013         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8014         if (get_jenv_res == JNI_EDETACHED) {
8015                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8016         }
8017         return ret_conv;
8018 }
8019 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8020         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8021         JNIEnv *env;
8022         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8023         if (get_jenv_res == JNI_EDETACHED) {
8024                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8025         } else {
8026                 DO_ASSERT(get_jenv_res == JNI_OK);
8027         }
8028         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8029         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8030         LDKReplyShortChannelIdsEnd msg_var = msg;
8031         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8032         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8033         uint64_t msg_ref = (uint64_t)msg_var.inner;
8034         if (msg_var.is_owned) {
8035                 msg_ref |= 1;
8036         }
8037         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8038         CHECK(obj != NULL);
8039         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8040         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8041         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8042         if (get_jenv_res == JNI_EDETACHED) {
8043                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8044         }
8045         return ret_conv;
8046 }
8047 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8048         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8049         JNIEnv *env;
8050         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8051         if (get_jenv_res == JNI_EDETACHED) {
8052                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8053         } else {
8054                 DO_ASSERT(get_jenv_res == JNI_OK);
8055         }
8056         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8057         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8058         LDKQueryChannelRange msg_var = msg;
8059         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8060         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8061         uint64_t msg_ref = (uint64_t)msg_var.inner;
8062         if (msg_var.is_owned) {
8063                 msg_ref |= 1;
8064         }
8065         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8066         CHECK(obj != NULL);
8067         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8068         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8069         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8070         if (get_jenv_res == JNI_EDETACHED) {
8071                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8072         }
8073         return ret_conv;
8074 }
8075 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8076         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8077         JNIEnv *env;
8078         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8079         if (get_jenv_res == JNI_EDETACHED) {
8080                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8081         } else {
8082                 DO_ASSERT(get_jenv_res == JNI_OK);
8083         }
8084         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8085         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8086         LDKQueryShortChannelIds msg_var = msg;
8087         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8088         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8089         uint64_t msg_ref = (uint64_t)msg_var.inner;
8090         if (msg_var.is_owned) {
8091                 msg_ref |= 1;
8092         }
8093         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8094         CHECK(obj != NULL);
8095         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8096         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8097         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8098         if (get_jenv_res == JNI_EDETACHED) {
8099                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8100         }
8101         return ret_conv;
8102 }
8103 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
8104         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8105         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8106         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8107         return (void*) this_arg;
8108 }
8109 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8110         jclass c = (*env)->GetObjectClass(env, o);
8111         CHECK(c != NULL);
8112         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8113         atomic_init(&calls->refcnt, 1);
8114         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8115         calls->o = (*env)->NewWeakGlobalRef(env, o);
8116         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8117         CHECK(calls->handle_node_announcement_meth != NULL);
8118         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8119         CHECK(calls->handle_channel_announcement_meth != NULL);
8120         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8121         CHECK(calls->handle_channel_update_meth != NULL);
8122         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8123         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8124         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8125         CHECK(calls->get_next_channel_announcements_meth != NULL);
8126         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8127         CHECK(calls->get_next_node_announcements_meth != NULL);
8128         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8129         CHECK(calls->sync_routing_table_meth != NULL);
8130         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8131         CHECK(calls->handle_reply_channel_range_meth != NULL);
8132         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8133         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8134         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8135         CHECK(calls->handle_query_channel_range_meth != NULL);
8136         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8137         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8138
8139         LDKRoutingMessageHandler ret = {
8140                 .this_arg = (void*) calls,
8141                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8142                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8143                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8144                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8145                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8146                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8147                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8148                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8149                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8150                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8151                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8152                 .free = LDKRoutingMessageHandler_JCalls_free,
8153                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8154         };
8155         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8156         return ret;
8157 }
8158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8159         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8160         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8161         return (uint64_t)res_ptr;
8162 }
8163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8164         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8165         LDKNodeAnnouncement msg_conv;
8166         msg_conv.inner = (void*)(msg & (~1));
8167         msg_conv.is_owned = false;
8168         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8169         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8170         return (uint64_t)ret_conv;
8171 }
8172
8173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8174         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8175         LDKChannelAnnouncement msg_conv;
8176         msg_conv.inner = (void*)(msg & (~1));
8177         msg_conv.is_owned = false;
8178         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8179         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8180         return (uint64_t)ret_conv;
8181 }
8182
8183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8184         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8185         LDKChannelUpdate msg_conv;
8186         msg_conv.inner = (void*)(msg & (~1));
8187         msg_conv.is_owned = false;
8188         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8189         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8190         return (uint64_t)ret_conv;
8191 }
8192
8193 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) {
8194         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8195         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8196         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8197 }
8198
8199 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) {
8200         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8201         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8202         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8203         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8204         for (size_t l = 0; l < ret_var.datalen; l++) {
8205                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8206                 *ret_conv_63_ref = ret_var.data[l];
8207                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8208         }
8209         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8210         FREE(ret_var.data);
8211         return ret_arr;
8212 }
8213
8214 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) {
8215         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8216         LDKPublicKey starting_point_ref;
8217         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8218         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8219         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8220         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8221         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8222         for (size_t s = 0; s < ret_var.datalen; s++) {
8223                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8224                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8225                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8226                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8227                 if (ret_conv_18_var.is_owned) {
8228                         ret_conv_18_ref |= 1;
8229                 }
8230                 ret_arr_ptr[s] = ret_conv_18_ref;
8231         }
8232         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8233         FREE(ret_var.data);
8234         return ret_arr;
8235 }
8236
8237 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) {
8238         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8239         LDKPublicKey their_node_id_ref;
8240         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8241         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8242         LDKInit init_conv;
8243         init_conv.inner = (void*)(init & (~1));
8244         init_conv.is_owned = false;
8245         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8246 }
8247
8248 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) {
8249         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8250         LDKPublicKey their_node_id_ref;
8251         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8252         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8253         LDKReplyChannelRange msg_conv;
8254         msg_conv.inner = (void*)(msg & (~1));
8255         msg_conv.is_owned = (msg & 1) || (msg == 0);
8256         msg_conv = ReplyChannelRange_clone(&msg_conv);
8257         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8258         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8259         return (uint64_t)ret_conv;
8260 }
8261
8262 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) {
8263         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8264         LDKPublicKey their_node_id_ref;
8265         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8266         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8267         LDKReplyShortChannelIdsEnd msg_conv;
8268         msg_conv.inner = (void*)(msg & (~1));
8269         msg_conv.is_owned = (msg & 1) || (msg == 0);
8270         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8271         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8272         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8273         return (uint64_t)ret_conv;
8274 }
8275
8276 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) {
8277         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8278         LDKPublicKey their_node_id_ref;
8279         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8280         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8281         LDKQueryChannelRange msg_conv;
8282         msg_conv.inner = (void*)(msg & (~1));
8283         msg_conv.is_owned = (msg & 1) || (msg == 0);
8284         msg_conv = QueryChannelRange_clone(&msg_conv);
8285         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8286         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8287         return (uint64_t)ret_conv;
8288 }
8289
8290 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) {
8291         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8292         LDKPublicKey their_node_id_ref;
8293         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8294         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8295         LDKQueryShortChannelIds msg_conv;
8296         msg_conv.inner = (void*)(msg & (~1));
8297         msg_conv.is_owned = (msg & 1) || (msg == 0);
8298         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8299         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8300         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8301         return (uint64_t)ret_conv;
8302 }
8303
8304 typedef struct LDKSocketDescriptor_JCalls {
8305         atomic_size_t refcnt;
8306         JavaVM *vm;
8307         jweak o;
8308         jmethodID send_data_meth;
8309         jmethodID disconnect_socket_meth;
8310         jmethodID eq_meth;
8311         jmethodID hash_meth;
8312 } LDKSocketDescriptor_JCalls;
8313 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8314         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8315         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8316                 JNIEnv *env;
8317                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8318                 if (get_jenv_res == JNI_EDETACHED) {
8319                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8320                 } else {
8321                         DO_ASSERT(get_jenv_res == JNI_OK);
8322                 }
8323                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8324                 if (get_jenv_res == JNI_EDETACHED) {
8325                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8326                 }
8327                 FREE(j_calls);
8328         }
8329 }
8330 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8331         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8332         JNIEnv *env;
8333         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8334         if (get_jenv_res == JNI_EDETACHED) {
8335                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8336         } else {
8337                 DO_ASSERT(get_jenv_res == JNI_OK);
8338         }
8339         LDKu8slice data_var = data;
8340         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8341         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8342         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8343         CHECK(obj != NULL);
8344         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8345         if (get_jenv_res == JNI_EDETACHED) {
8346                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8347         }
8348         return ret;
8349 }
8350 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8351         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8352         JNIEnv *env;
8353         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8354         if (get_jenv_res == JNI_EDETACHED) {
8355                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8356         } else {
8357                 DO_ASSERT(get_jenv_res == JNI_OK);
8358         }
8359         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8360         CHECK(obj != NULL);
8361         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8362         if (get_jenv_res == JNI_EDETACHED) {
8363                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8364         }
8365 }
8366 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8367         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8368         JNIEnv *env;
8369         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8370         if (get_jenv_res == JNI_EDETACHED) {
8371                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8372         } else {
8373                 DO_ASSERT(get_jenv_res == JNI_OK);
8374         }
8375         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8376         *other_arg_clone = SocketDescriptor_clone(other_arg);
8377         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8378         CHECK(obj != NULL);
8379         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8380         if (get_jenv_res == JNI_EDETACHED) {
8381                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8382         }
8383         return ret;
8384 }
8385 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8386         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8387         JNIEnv *env;
8388         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8389         if (get_jenv_res == JNI_EDETACHED) {
8390                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8391         } else {
8392                 DO_ASSERT(get_jenv_res == JNI_OK);
8393         }
8394         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8395         CHECK(obj != NULL);
8396         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8397         if (get_jenv_res == JNI_EDETACHED) {
8398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8399         }
8400         return ret;
8401 }
8402 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
8403         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8404         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8405         return (void*) this_arg;
8406 }
8407 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8408         jclass c = (*env)->GetObjectClass(env, o);
8409         CHECK(c != NULL);
8410         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8411         atomic_init(&calls->refcnt, 1);
8412         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8413         calls->o = (*env)->NewWeakGlobalRef(env, o);
8414         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8415         CHECK(calls->send_data_meth != NULL);
8416         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8417         CHECK(calls->disconnect_socket_meth != NULL);
8418         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8419         CHECK(calls->eq_meth != NULL);
8420         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8421         CHECK(calls->hash_meth != NULL);
8422
8423         LDKSocketDescriptor ret = {
8424                 .this_arg = (void*) calls,
8425                 .send_data = send_data_LDKSocketDescriptor_jcall,
8426                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8427                 .eq = eq_LDKSocketDescriptor_jcall,
8428                 .hash = hash_LDKSocketDescriptor_jcall,
8429                 .clone = LDKSocketDescriptor_JCalls_clone,
8430                 .free = LDKSocketDescriptor_JCalls_free,
8431         };
8432         return ret;
8433 }
8434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8435         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8436         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8437         return (uint64_t)res_ptr;
8438 }
8439 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) {
8440         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8441         LDKu8slice data_ref;
8442         data_ref.datalen = (*env)->GetArrayLength(env, data);
8443         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8444         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8445         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8446         return ret_val;
8447 }
8448
8449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8450         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8451         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8452 }
8453
8454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8455         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8456         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8457         return ret_val;
8458 }
8459
8460 typedef struct LDKChannelManagerPersister_JCalls {
8461         atomic_size_t refcnt;
8462         JavaVM *vm;
8463         jweak o;
8464         jmethodID persist_manager_meth;
8465 } LDKChannelManagerPersister_JCalls;
8466 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8467         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8468         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8469                 JNIEnv *env;
8470                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8471                 if (get_jenv_res == JNI_EDETACHED) {
8472                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8473                 } else {
8474                         DO_ASSERT(get_jenv_res == JNI_OK);
8475                 }
8476                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8477                 if (get_jenv_res == JNI_EDETACHED) {
8478                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8479                 }
8480                 FREE(j_calls);
8481         }
8482 }
8483 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8484         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8485         JNIEnv *env;
8486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8487         if (get_jenv_res == JNI_EDETACHED) {
8488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8489         } else {
8490                 DO_ASSERT(get_jenv_res == JNI_OK);
8491         }
8492         LDKChannelManager channel_manager_var = *channel_manager;
8493         // Warning: we may need a move here but no clone is available for LDKChannelManager
8494         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8495         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8496         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8497         if (channel_manager_var.is_owned) {
8498                 channel_manager_ref |= 1;
8499         }
8500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8501         CHECK(obj != NULL);
8502         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8503         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8504         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8505         if (get_jenv_res == JNI_EDETACHED) {
8506                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8507         }
8508         return ret_conv;
8509 }
8510 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
8511         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8512         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8513         return (void*) this_arg;
8514 }
8515 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8516         jclass c = (*env)->GetObjectClass(env, o);
8517         CHECK(c != NULL);
8518         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8519         atomic_init(&calls->refcnt, 1);
8520         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8521         calls->o = (*env)->NewWeakGlobalRef(env, o);
8522         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8523         CHECK(calls->persist_manager_meth != NULL);
8524
8525         LDKChannelManagerPersister ret = {
8526                 .this_arg = (void*) calls,
8527                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8528                 .free = LDKChannelManagerPersister_JCalls_free,
8529         };
8530         return ret;
8531 }
8532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8533         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8534         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8535         return (uint64_t)res_ptr;
8536 }
8537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8538         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8539         LDKChannelManager channel_manager_conv;
8540         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8541         channel_manager_conv.is_owned = false;
8542         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8543         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8544         return (uint64_t)ret_conv;
8545 }
8546
8547 static jclass LDKFallback_SegWitProgram_class = NULL;
8548 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8549 static jclass LDKFallback_PubKeyHash_class = NULL;
8550 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8551 static jclass LDKFallback_ScriptHash_class = NULL;
8552 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8554         LDKFallback_SegWitProgram_class =
8555                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8556         CHECK(LDKFallback_SegWitProgram_class != NULL);
8557         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8558         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8559         LDKFallback_PubKeyHash_class =
8560                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8561         CHECK(LDKFallback_PubKeyHash_class != NULL);
8562         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8563         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8564         LDKFallback_ScriptHash_class =
8565                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8566         CHECK(LDKFallback_ScriptHash_class != NULL);
8567         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8568         CHECK(LDKFallback_ScriptHash_meth != NULL);
8569 }
8570 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8571         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8572         switch(obj->tag) {
8573                 case LDKFallback_SegWitProgram: {
8574                         uint8_t version_val = obj->seg_wit_program.version._0;
8575                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8576                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8577                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8578                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8579                 }
8580                 case LDKFallback_PubKeyHash: {
8581                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8582                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8583                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8584                 }
8585                 case LDKFallback_ScriptHash: {
8586                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8587                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8588                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8589                 }
8590                 default: abort();
8591         }
8592 }
8593 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8594         LDKStr ret_str = _ldk_get_compiled_version();
8595         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8596         return ret_conv;
8597 }
8598
8599 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8600         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8601         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8602         return ret_conv;
8603 }
8604
8605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8606         LDKTransaction _res_ref;
8607         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8608         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8609         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8610         _res_ref.data_is_owned = true;
8611         Transaction_free(_res_ref);
8612 }
8613
8614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8615         if ((_res & 1) != 0) return;
8616         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8617         FREE((void*)_res);
8618         TxOut_free(_res_conv);
8619 }
8620
8621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8622         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8623         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8624         *ret_ref = TxOut_clone(orig_conv);
8625         return (uint64_t)ret_ref;
8626 }
8627
8628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
8629         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8630         Str_free(dummy);
8631 }
8632
8633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8634         LDKSecretKey o_ref;
8635         CHECK((*env)->GetArrayLength(env, o) == 32);
8636         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
8637         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8638         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8639         return (uint64_t)ret_conv;
8640 }
8641
8642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8643         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8644         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8645         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8646         return (uint64_t)ret_conv;
8647 }
8648
8649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8650         if ((_res & 1) != 0) return;
8651         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
8652         FREE((void*)_res);
8653         CResult_SecretKeyErrorZ_free(_res_conv);
8654 }
8655
8656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
8657         LDKPublicKey o_ref;
8658         CHECK((*env)->GetArrayLength(env, o) == 33);
8659         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
8660         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8661         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
8662         return (uint64_t)ret_conv;
8663 }
8664
8665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8666         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8667         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8668         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
8669         return (uint64_t)ret_conv;
8670 }
8671
8672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8673         if ((_res & 1) != 0) return;
8674         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
8675         FREE((void*)_res);
8676         CResult_PublicKeyErrorZ_free(_res_conv);
8677 }
8678
8679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8680         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
8681         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8682         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
8683         return (uint64_t)ret_conv;
8684 }
8685
8686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8687         LDKTxCreationKeys o_conv;
8688         o_conv.inner = (void*)(o & (~1));
8689         o_conv.is_owned = (o & 1) || (o == 0);
8690         o_conv = TxCreationKeys_clone(&o_conv);
8691         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8692         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
8693         return (uint64_t)ret_conv;
8694 }
8695
8696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8697         LDKDecodeError e_conv;
8698         e_conv.inner = (void*)(e & (~1));
8699         e_conv.is_owned = (e & 1) || (e == 0);
8700         e_conv = DecodeError_clone(&e_conv);
8701         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8702         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
8703         return (uint64_t)ret_conv;
8704 }
8705
8706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8707         if ((_res & 1) != 0) return;
8708         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
8709         FREE((void*)_res);
8710         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
8711 }
8712
8713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8714         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
8715         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8716         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
8717         return (uint64_t)ret_conv;
8718 }
8719
8720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8721         LDKChannelPublicKeys o_conv;
8722         o_conv.inner = (void*)(o & (~1));
8723         o_conv.is_owned = (o & 1) || (o == 0);
8724         o_conv = ChannelPublicKeys_clone(&o_conv);
8725         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8726         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
8727         return (uint64_t)ret_conv;
8728 }
8729
8730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8731         LDKDecodeError e_conv;
8732         e_conv.inner = (void*)(e & (~1));
8733         e_conv.is_owned = (e & 1) || (e == 0);
8734         e_conv = DecodeError_clone(&e_conv);
8735         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8736         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
8737         return (uint64_t)ret_conv;
8738 }
8739
8740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8741         if ((_res & 1) != 0) return;
8742         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
8743         FREE((void*)_res);
8744         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
8745 }
8746
8747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8748         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
8749         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8750         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
8751         return (uint64_t)ret_conv;
8752 }
8753
8754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8755         LDKTxCreationKeys o_conv;
8756         o_conv.inner = (void*)(o & (~1));
8757         o_conv.is_owned = (o & 1) || (o == 0);
8758         o_conv = TxCreationKeys_clone(&o_conv);
8759         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8760         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
8761         return (uint64_t)ret_conv;
8762 }
8763
8764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
8765         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
8766         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8767         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
8768         return (uint64_t)ret_conv;
8769 }
8770
8771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8772         if ((_res & 1) != 0) return;
8773         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
8774         FREE((void*)_res);
8775         CResult_TxCreationKeysErrorZ_free(_res_conv);
8776 }
8777
8778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8779         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
8780         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8781         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
8782         return (uint64_t)ret_conv;
8783 }
8784
8785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
8786         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8787         *ret_copy = COption_u32Z_some(o);
8788         uint64_t ret_ref = (uint64_t)ret_copy;
8789         return ret_ref;
8790 }
8791
8792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
8793         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8794         *ret_copy = COption_u32Z_none();
8795         uint64_t ret_ref = (uint64_t)ret_copy;
8796         return ret_ref;
8797 }
8798
8799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
8800         if ((_res & 1) != 0) return;
8801         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
8802         FREE((void*)_res);
8803         COption_u32Z_free(_res_conv);
8804 }
8805
8806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8807         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
8808         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8809         *ret_copy = COption_u32Z_clone(orig_conv);
8810         uint64_t ret_ref = (uint64_t)ret_copy;
8811         return ret_ref;
8812 }
8813
8814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8815         LDKHTLCOutputInCommitment o_conv;
8816         o_conv.inner = (void*)(o & (~1));
8817         o_conv.is_owned = (o & 1) || (o == 0);
8818         o_conv = HTLCOutputInCommitment_clone(&o_conv);
8819         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8820         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
8821         return (uint64_t)ret_conv;
8822 }
8823
8824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8825         LDKDecodeError e_conv;
8826         e_conv.inner = (void*)(e & (~1));
8827         e_conv.is_owned = (e & 1) || (e == 0);
8828         e_conv = DecodeError_clone(&e_conv);
8829         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8830         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
8831         return (uint64_t)ret_conv;
8832 }
8833
8834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8835         if ((_res & 1) != 0) return;
8836         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
8837         FREE((void*)_res);
8838         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
8839 }
8840
8841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8842         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
8843         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8844         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
8845         return (uint64_t)ret_conv;
8846 }
8847
8848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8849         LDKCounterpartyChannelTransactionParameters o_conv;
8850         o_conv.inner = (void*)(o & (~1));
8851         o_conv.is_owned = (o & 1) || (o == 0);
8852         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
8853         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8854         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8855         return (uint64_t)ret_conv;
8856 }
8857
8858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8859         LDKDecodeError e_conv;
8860         e_conv.inner = (void*)(e & (~1));
8861         e_conv.is_owned = (e & 1) || (e == 0);
8862         e_conv = DecodeError_clone(&e_conv);
8863         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8864         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
8865         return (uint64_t)ret_conv;
8866 }
8867
8868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8869         if ((_res & 1) != 0) return;
8870         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
8871         FREE((void*)_res);
8872         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8873 }
8874
8875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8876         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8877         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8878         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8879         return (uint64_t)ret_conv;
8880 }
8881
8882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8883         LDKChannelTransactionParameters o_conv;
8884         o_conv.inner = (void*)(o & (~1));
8885         o_conv.is_owned = (o & 1) || (o == 0);
8886         o_conv = ChannelTransactionParameters_clone(&o_conv);
8887         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8888         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8889         return (uint64_t)ret_conv;
8890 }
8891
8892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8893         LDKDecodeError e_conv;
8894         e_conv.inner = (void*)(e & (~1));
8895         e_conv.is_owned = (e & 1) || (e == 0);
8896         e_conv = DecodeError_clone(&e_conv);
8897         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8898         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
8899         return (uint64_t)ret_conv;
8900 }
8901
8902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8903         if ((_res & 1) != 0) return;
8904         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
8905         FREE((void*)_res);
8906         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8907 }
8908
8909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8910         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8911         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8912         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8913         return (uint64_t)ret_conv;
8914 }
8915
8916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
8917         LDKCVec_SignatureZ _res_constr;
8918         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
8919         if (_res_constr.datalen > 0)
8920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8921         else
8922                 _res_constr.data = NULL;
8923         for (size_t i = 0; i < _res_constr.datalen; i++) {
8924                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
8925                 LDKSignature _res_conv_8_ref;
8926                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
8927                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
8928                 _res_constr.data[i] = _res_conv_8_ref;
8929         }
8930         CVec_SignatureZ_free(_res_constr);
8931 }
8932
8933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8934         LDKHolderCommitmentTransaction o_conv;
8935         o_conv.inner = (void*)(o & (~1));
8936         o_conv.is_owned = (o & 1) || (o == 0);
8937         o_conv = HolderCommitmentTransaction_clone(&o_conv);
8938         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8939         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
8940         return (uint64_t)ret_conv;
8941 }
8942
8943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8944         LDKDecodeError e_conv;
8945         e_conv.inner = (void*)(e & (~1));
8946         e_conv.is_owned = (e & 1) || (e == 0);
8947         e_conv = DecodeError_clone(&e_conv);
8948         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8949         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
8950         return (uint64_t)ret_conv;
8951 }
8952
8953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8954         if ((_res & 1) != 0) return;
8955         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
8956         FREE((void*)_res);
8957         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
8958 }
8959
8960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8961         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8962         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8963         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8964         return (uint64_t)ret_conv;
8965 }
8966
8967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
8968         LDKBuiltCommitmentTransaction o_conv;
8969         o_conv.inner = (void*)(o & (~1));
8970         o_conv.is_owned = (o & 1) || (o == 0);
8971         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
8972         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8973         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
8974         return (uint64_t)ret_conv;
8975 }
8976
8977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
8978         LDKDecodeError e_conv;
8979         e_conv.inner = (void*)(e & (~1));
8980         e_conv.is_owned = (e & 1) || (e == 0);
8981         e_conv = DecodeError_clone(&e_conv);
8982         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8983         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
8984         return (uint64_t)ret_conv;
8985 }
8986
8987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
8988         if ((_res & 1) != 0) return;
8989         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
8990         FREE((void*)_res);
8991         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
8992 }
8993
8994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8995         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8996         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8997         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8998         return (uint64_t)ret_conv;
8999 }
9000
9001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9002         LDKCommitmentTransaction o_conv;
9003         o_conv.inner = (void*)(o & (~1));
9004         o_conv.is_owned = (o & 1) || (o == 0);
9005         o_conv = CommitmentTransaction_clone(&o_conv);
9006         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9007         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9008         return (uint64_t)ret_conv;
9009 }
9010
9011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9012         LDKDecodeError e_conv;
9013         e_conv.inner = (void*)(e & (~1));
9014         e_conv.is_owned = (e & 1) || (e == 0);
9015         e_conv = DecodeError_clone(&e_conv);
9016         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9017         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9018         return (uint64_t)ret_conv;
9019 }
9020
9021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9022         if ((_res & 1) != 0) return;
9023         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9024         FREE((void*)_res);
9025         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9026 }
9027
9028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9029         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9030         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9031         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9032         return (uint64_t)ret_conv;
9033 }
9034
9035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9036         LDKTrustedCommitmentTransaction o_conv;
9037         o_conv.inner = (void*)(o & (~1));
9038         o_conv.is_owned = (o & 1) || (o == 0);
9039         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9040         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9041         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9042         return (uint64_t)ret_conv;
9043 }
9044
9045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9046         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9047         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9048         return (uint64_t)ret_conv;
9049 }
9050
9051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9052         if ((_res & 1) != 0) return;
9053         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9054         FREE((void*)_res);
9055         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9056 }
9057
9058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9059         LDKCVec_SignatureZ o_constr;
9060         o_constr.datalen = (*env)->GetArrayLength(env, o);
9061         if (o_constr.datalen > 0)
9062                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9063         else
9064                 o_constr.data = NULL;
9065         for (size_t i = 0; i < o_constr.datalen; i++) {
9066                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9067                 LDKSignature o_conv_8_ref;
9068                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9069                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9070                 o_constr.data[i] = o_conv_8_ref;
9071         }
9072         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9073         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9074         return (uint64_t)ret_conv;
9075 }
9076
9077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9078         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9079         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9080         return (uint64_t)ret_conv;
9081 }
9082
9083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9084         if ((_res & 1) != 0) return;
9085         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9086         FREE((void*)_res);
9087         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9088 }
9089
9090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9091         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9092         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9093         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9094         return (uint64_t)ret_conv;
9095 }
9096
9097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9098         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9099         *ret_conv = CResult_NoneErrorZ_ok();
9100         return (uint64_t)ret_conv;
9101 }
9102
9103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9104         LDKIOError e_conv = LDKIOError_from_java(env, e);
9105         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9106         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9107         return (uint64_t)ret_conv;
9108 }
9109
9110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9111         if ((_res & 1) != 0) return;
9112         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9113         FREE((void*)_res);
9114         CResult_NoneErrorZ_free(_res_conv);
9115 }
9116
9117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9118         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9119         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9120         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9121         return (uint64_t)ret_conv;
9122 }
9123
9124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9125         LDKRouteHop o_conv;
9126         o_conv.inner = (void*)(o & (~1));
9127         o_conv.is_owned = (o & 1) || (o == 0);
9128         o_conv = RouteHop_clone(&o_conv);
9129         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9130         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9131         return (uint64_t)ret_conv;
9132 }
9133
9134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9135         LDKDecodeError e_conv;
9136         e_conv.inner = (void*)(e & (~1));
9137         e_conv.is_owned = (e & 1) || (e == 0);
9138         e_conv = DecodeError_clone(&e_conv);
9139         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9140         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9141         return (uint64_t)ret_conv;
9142 }
9143
9144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9145         if ((_res & 1) != 0) return;
9146         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9147         FREE((void*)_res);
9148         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9149 }
9150
9151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9152         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9153         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9154         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9155         return (uint64_t)ret_conv;
9156 }
9157
9158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9159         LDKCVec_RouteHopZ _res_constr;
9160         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9161         if (_res_constr.datalen > 0)
9162                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9163         else
9164                 _res_constr.data = NULL;
9165         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9166         for (size_t k = 0; k < _res_constr.datalen; k++) {
9167                 int64_t _res_conv_10 = _res_vals[k];
9168                 LDKRouteHop _res_conv_10_conv;
9169                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9170                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9171                 _res_constr.data[k] = _res_conv_10_conv;
9172         }
9173         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9174         CVec_RouteHopZ_free(_res_constr);
9175 }
9176
9177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9178         LDKCVec_CVec_RouteHopZZ _res_constr;
9179         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9180         if (_res_constr.datalen > 0)
9181                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9182         else
9183                 _res_constr.data = NULL;
9184         for (size_t m = 0; m < _res_constr.datalen; m++) {
9185                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9186                 LDKCVec_RouteHopZ _res_conv_12_constr;
9187                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9188                 if (_res_conv_12_constr.datalen > 0)
9189                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9190                 else
9191                         _res_conv_12_constr.data = NULL;
9192                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9193                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9194                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9195                         LDKRouteHop _res_conv_12_conv_10_conv;
9196                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9197                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9198                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9199                 }
9200                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9201                 _res_constr.data[m] = _res_conv_12_constr;
9202         }
9203         CVec_CVec_RouteHopZZ_free(_res_constr);
9204 }
9205
9206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9207         LDKRoute o_conv;
9208         o_conv.inner = (void*)(o & (~1));
9209         o_conv.is_owned = (o & 1) || (o == 0);
9210         o_conv = Route_clone(&o_conv);
9211         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9212         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9213         return (uint64_t)ret_conv;
9214 }
9215
9216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9217         LDKDecodeError e_conv;
9218         e_conv.inner = (void*)(e & (~1));
9219         e_conv.is_owned = (e & 1) || (e == 0);
9220         e_conv = DecodeError_clone(&e_conv);
9221         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9222         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9223         return (uint64_t)ret_conv;
9224 }
9225
9226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9227         if ((_res & 1) != 0) return;
9228         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9229         FREE((void*)_res);
9230         CResult_RouteDecodeErrorZ_free(_res_conv);
9231 }
9232
9233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9234         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9235         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9236         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9237         return (uint64_t)ret_conv;
9238 }
9239
9240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9241         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9242         *ret_copy = COption_u64Z_some(o);
9243         uint64_t ret_ref = (uint64_t)ret_copy;
9244         return ret_ref;
9245 }
9246
9247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9248         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9249         *ret_copy = COption_u64Z_none();
9250         uint64_t ret_ref = (uint64_t)ret_copy;
9251         return ret_ref;
9252 }
9253
9254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9255         if ((_res & 1) != 0) return;
9256         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9257         FREE((void*)_res);
9258         COption_u64Z_free(_res_conv);
9259 }
9260
9261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9262         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9263         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9264         *ret_copy = COption_u64Z_clone(orig_conv);
9265         uint64_t ret_ref = (uint64_t)ret_copy;
9266         return ret_ref;
9267 }
9268
9269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9270         LDKCVec_ChannelDetailsZ _res_constr;
9271         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9272         if (_res_constr.datalen > 0)
9273                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9274         else
9275                 _res_constr.data = NULL;
9276         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9277         for (size_t q = 0; q < _res_constr.datalen; q++) {
9278                 int64_t _res_conv_16 = _res_vals[q];
9279                 LDKChannelDetails _res_conv_16_conv;
9280                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9281                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9282                 _res_constr.data[q] = _res_conv_16_conv;
9283         }
9284         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9285         CVec_ChannelDetailsZ_free(_res_constr);
9286 }
9287
9288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9289         LDKCVec_RouteHintZ _res_constr;
9290         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9291         if (_res_constr.datalen > 0)
9292                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9293         else
9294                 _res_constr.data = NULL;
9295         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9296         for (size_t l = 0; l < _res_constr.datalen; l++) {
9297                 int64_t _res_conv_11 = _res_vals[l];
9298                 LDKRouteHint _res_conv_11_conv;
9299                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9300                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9301                 _res_constr.data[l] = _res_conv_11_conv;
9302         }
9303         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9304         CVec_RouteHintZ_free(_res_constr);
9305 }
9306
9307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9308         LDKRoute o_conv;
9309         o_conv.inner = (void*)(o & (~1));
9310         o_conv.is_owned = (o & 1) || (o == 0);
9311         o_conv = Route_clone(&o_conv);
9312         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9313         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9314         return (uint64_t)ret_conv;
9315 }
9316
9317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9318         LDKLightningError e_conv;
9319         e_conv.inner = (void*)(e & (~1));
9320         e_conv.is_owned = (e & 1) || (e == 0);
9321         e_conv = LightningError_clone(&e_conv);
9322         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9323         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9324         return (uint64_t)ret_conv;
9325 }
9326
9327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9328         if ((_res & 1) != 0) return;
9329         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9330         FREE((void*)_res);
9331         CResult_RouteLightningErrorZ_free(_res_conv);
9332 }
9333
9334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9335         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9336         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9337         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9338         return (uint64_t)ret_conv;
9339 }
9340
9341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9342         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9343         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9344         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9345         return (uint64_t)ret_conv;
9346 }
9347
9348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9349         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9350         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9351         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9352         return (uint64_t)ret_conv;
9353 }
9354
9355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9356         if ((_res & 1) != 0) return;
9357         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9358         FREE((void*)_res);
9359         CResult_TxOutAccessErrorZ_free(_res_conv);
9360 }
9361
9362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9363         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9364         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9365         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9366         return (uint64_t)ret_conv;
9367 }
9368
9369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9370         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9371         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9372         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9373         return (uint64_t)ret_ref;
9374 }
9375
9376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9377         LDKTransaction b_ref;
9378         b_ref.datalen = (*env)->GetArrayLength(env, b);
9379         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9380         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9381         b_ref.data_is_owned = true;
9382         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9383         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9384         return (uint64_t)ret_ref;
9385 }
9386
9387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9388         if ((_res & 1) != 0) return;
9389         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9390         FREE((void*)_res);
9391         C2Tuple_usizeTransactionZ_free(_res_conv);
9392 }
9393
9394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9395         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9396         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9397         if (_res_constr.datalen > 0)
9398                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9399         else
9400                 _res_constr.data = NULL;
9401         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9402         for (size_t y = 0; y < _res_constr.datalen; y++) {
9403                 int64_t _res_conv_24 = _res_vals[y];
9404                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9405                 FREE((void*)_res_conv_24);
9406                 _res_constr.data[y] = _res_conv_24_conv;
9407         }
9408         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9409         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9410 }
9411
9412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9413         LDKCVec_TxidZ _res_constr;
9414         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9415         if (_res_constr.datalen > 0)
9416                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9417         else
9418                 _res_constr.data = NULL;
9419         for (size_t i = 0; i < _res_constr.datalen; i++) {
9420                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9421                 LDKThirtyTwoBytes _res_conv_8_ref;
9422                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9423                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9424                 _res_constr.data[i] = _res_conv_8_ref;
9425         }
9426         CVec_TxidZ_free(_res_constr);
9427 }
9428
9429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9430         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9431         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9432         return (uint64_t)ret_conv;
9433 }
9434
9435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9436         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9437         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9438         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9439         return (uint64_t)ret_conv;
9440 }
9441
9442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9443         if ((_res & 1) != 0) return;
9444         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9445         FREE((void*)_res);
9446         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9447 }
9448
9449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9450         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9451         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9452         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9453         return (uint64_t)ret_conv;
9454 }
9455
9456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9457         LDKCVec_MonitorEventZ _res_constr;
9458         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9459         if (_res_constr.datalen > 0)
9460                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9461         else
9462                 _res_constr.data = NULL;
9463         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9464         for (size_t o = 0; o < _res_constr.datalen; o++) {
9465                 int64_t _res_conv_14 = _res_vals[o];
9466                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9467                 FREE((void*)_res_conv_14);
9468                 _res_constr.data[o] = _res_conv_14_conv;
9469         }
9470         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9471         CVec_MonitorEventZ_free(_res_constr);
9472 }
9473
9474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9475         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9476         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9477         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9478         uint64_t ret_ref = (uint64_t)ret_copy;
9479         return ret_ref;
9480 }
9481
9482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9483         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9484         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9485         uint64_t ret_ref = (uint64_t)ret_copy;
9486         return ret_ref;
9487 }
9488
9489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9490         if ((_res & 1) != 0) return;
9491         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9492         FREE((void*)_res);
9493         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9494 }
9495
9496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9497         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9498         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9499         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9500         uint64_t ret_ref = (uint64_t)ret_copy;
9501         return ret_ref;
9502 }
9503
9504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9505         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9506         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9507         if (_res_constr.datalen > 0)
9508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9509         else
9510                 _res_constr.data = NULL;
9511         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9512         for (size_t b = 0; b < _res_constr.datalen; b++) {
9513                 int64_t _res_conv_27 = _res_vals[b];
9514                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9515                 FREE((void*)_res_conv_27);
9516                 _res_constr.data[b] = _res_conv_27_conv;
9517         }
9518         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9519         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9520 }
9521
9522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9523         LDKCVec_MessageSendEventZ _res_constr;
9524         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9525         if (_res_constr.datalen > 0)
9526                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9527         else
9528                 _res_constr.data = NULL;
9529         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9530         for (size_t s = 0; s < _res_constr.datalen; s++) {
9531                 int64_t _res_conv_18 = _res_vals[s];
9532                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9533                 FREE((void*)_res_conv_18);
9534                 _res_constr.data[s] = _res_conv_18_conv;
9535         }
9536         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9537         CVec_MessageSendEventZ_free(_res_constr);
9538 }
9539
9540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9541         LDKInitFeatures o_conv;
9542         o_conv.inner = (void*)(o & (~1));
9543         o_conv.is_owned = (o & 1) || (o == 0);
9544         o_conv = InitFeatures_clone(&o_conv);
9545         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9546         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9547         return (uint64_t)ret_conv;
9548 }
9549
9550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9551         LDKDecodeError e_conv;
9552         e_conv.inner = (void*)(e & (~1));
9553         e_conv.is_owned = (e & 1) || (e == 0);
9554         e_conv = DecodeError_clone(&e_conv);
9555         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9556         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9557         return (uint64_t)ret_conv;
9558 }
9559
9560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9561         if ((_res & 1) != 0) return;
9562         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9563         FREE((void*)_res);
9564         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9565 }
9566
9567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9568         LDKNodeFeatures o_conv;
9569         o_conv.inner = (void*)(o & (~1));
9570         o_conv.is_owned = (o & 1) || (o == 0);
9571         o_conv = NodeFeatures_clone(&o_conv);
9572         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9573         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9574         return (uint64_t)ret_conv;
9575 }
9576
9577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9578         LDKDecodeError e_conv;
9579         e_conv.inner = (void*)(e & (~1));
9580         e_conv.is_owned = (e & 1) || (e == 0);
9581         e_conv = DecodeError_clone(&e_conv);
9582         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9583         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9584         return (uint64_t)ret_conv;
9585 }
9586
9587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9588         if ((_res & 1) != 0) return;
9589         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9590         FREE((void*)_res);
9591         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9592 }
9593
9594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9595         LDKChannelFeatures o_conv;
9596         o_conv.inner = (void*)(o & (~1));
9597         o_conv.is_owned = (o & 1) || (o == 0);
9598         o_conv = ChannelFeatures_clone(&o_conv);
9599         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9600         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9601         return (uint64_t)ret_conv;
9602 }
9603
9604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9605         LDKDecodeError e_conv;
9606         e_conv.inner = (void*)(e & (~1));
9607         e_conv.is_owned = (e & 1) || (e == 0);
9608         e_conv = DecodeError_clone(&e_conv);
9609         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9610         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9611         return (uint64_t)ret_conv;
9612 }
9613
9614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9615         if ((_res & 1) != 0) return;
9616         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9617         FREE((void*)_res);
9618         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9619 }
9620
9621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9622         LDKInvoiceFeatures o_conv;
9623         o_conv.inner = (void*)(o & (~1));
9624         o_conv.is_owned = (o & 1) || (o == 0);
9625         o_conv = InvoiceFeatures_clone(&o_conv);
9626         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9627         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9628         return (uint64_t)ret_conv;
9629 }
9630
9631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9632         LDKDecodeError e_conv;
9633         e_conv.inner = (void*)(e & (~1));
9634         e_conv.is_owned = (e & 1) || (e == 0);
9635         e_conv = DecodeError_clone(&e_conv);
9636         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9637         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
9638         return (uint64_t)ret_conv;
9639 }
9640
9641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9642         if ((_res & 1) != 0) return;
9643         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9644         FREE((void*)_res);
9645         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
9646 }
9647
9648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9649         LDKDelayedPaymentOutputDescriptor o_conv;
9650         o_conv.inner = (void*)(o & (~1));
9651         o_conv.is_owned = (o & 1) || (o == 0);
9652         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
9653         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9654         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9655         return (uint64_t)ret_conv;
9656 }
9657
9658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9659         LDKDecodeError e_conv;
9660         e_conv.inner = (void*)(e & (~1));
9661         e_conv.is_owned = (e & 1) || (e == 0);
9662         e_conv = DecodeError_clone(&e_conv);
9663         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9664         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9665         return (uint64_t)ret_conv;
9666 }
9667
9668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9669         if ((_res & 1) != 0) return;
9670         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9671         FREE((void*)_res);
9672         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9673 }
9674
9675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9676         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9677         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9678         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9679         return (uint64_t)ret_conv;
9680 }
9681
9682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9683         LDKStaticPaymentOutputDescriptor o_conv;
9684         o_conv.inner = (void*)(o & (~1));
9685         o_conv.is_owned = (o & 1) || (o == 0);
9686         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
9687         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9688         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9689         return (uint64_t)ret_conv;
9690 }
9691
9692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9693         LDKDecodeError e_conv;
9694         e_conv.inner = (void*)(e & (~1));
9695         e_conv.is_owned = (e & 1) || (e == 0);
9696         e_conv = DecodeError_clone(&e_conv);
9697         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9698         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9699         return (uint64_t)ret_conv;
9700 }
9701
9702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9703         if ((_res & 1) != 0) return;
9704         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9705         FREE((void*)_res);
9706         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9707 }
9708
9709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9710         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9711         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9712         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9713         return (uint64_t)ret_conv;
9714 }
9715
9716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9717         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
9718         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9719         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
9720         return (uint64_t)ret_conv;
9721 }
9722
9723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9724         LDKDecodeError e_conv;
9725         e_conv.inner = (void*)(e & (~1));
9726         e_conv.is_owned = (e & 1) || (e == 0);
9727         e_conv = DecodeError_clone(&e_conv);
9728         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9729         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
9730         return (uint64_t)ret_conv;
9731 }
9732
9733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9734         if ((_res & 1) != 0) return;
9735         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
9736         FREE((void*)_res);
9737         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
9738 }
9739
9740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9741         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
9742         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9743         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
9744         return (uint64_t)ret_conv;
9745 }
9746
9747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9748         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
9749         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9750         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
9751         return (uint64_t)ret_ref;
9752 }
9753
9754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
9755         LDKSignature a_ref;
9756         CHECK((*env)->GetArrayLength(env, a) == 64);
9757         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
9758         LDKCVec_SignatureZ b_constr;
9759         b_constr.datalen = (*env)->GetArrayLength(env, b);
9760         if (b_constr.datalen > 0)
9761                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9762         else
9763                 b_constr.data = NULL;
9764         for (size_t i = 0; i < b_constr.datalen; i++) {
9765                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
9766                 LDKSignature b_conv_8_ref;
9767                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
9768                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
9769                 b_constr.data[i] = b_conv_8_ref;
9770         }
9771         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9772         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
9773         return (uint64_t)ret_ref;
9774 }
9775
9776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9777         if ((_res & 1) != 0) return;
9778         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
9779         FREE((void*)_res);
9780         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
9781 }
9782
9783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9784         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
9785         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9786         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
9787         return (uint64_t)ret_conv;
9788 }
9789
9790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
9791         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9792         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
9793         return (uint64_t)ret_conv;
9794 }
9795
9796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9797         if ((_res & 1) != 0) return;
9798         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
9799         FREE((void*)_res);
9800         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
9801 }
9802
9803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9804         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
9805         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
9806         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
9807         return (uint64_t)ret_conv;
9808 }
9809
9810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9811         LDKSignature o_ref;
9812         CHECK((*env)->GetArrayLength(env, o) == 64);
9813         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
9814         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9815         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
9816         return (uint64_t)ret_conv;
9817 }
9818
9819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9820         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9821         *ret_conv = CResult_SignatureNoneZ_err();
9822         return (uint64_t)ret_conv;
9823 }
9824
9825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9826         if ((_res & 1) != 0) return;
9827         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
9828         FREE((void*)_res);
9829         CResult_SignatureNoneZ_free(_res_conv);
9830 }
9831
9832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9833         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
9834         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
9835         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
9836         return (uint64_t)ret_conv;
9837 }
9838
9839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9840         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
9841         if (o_conv.free == LDKSign_JCalls_free) {
9842                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9843                 LDKSign_JCalls_clone(o_conv.this_arg);
9844         }
9845         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9846         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
9847         return (uint64_t)ret_conv;
9848 }
9849
9850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9851         LDKDecodeError e_conv;
9852         e_conv.inner = (void*)(e & (~1));
9853         e_conv.is_owned = (e & 1) || (e == 0);
9854         e_conv = DecodeError_clone(&e_conv);
9855         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9856         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
9857         return (uint64_t)ret_conv;
9858 }
9859
9860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9861         if ((_res & 1) != 0) return;
9862         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
9863         FREE((void*)_res);
9864         CResult_SignDecodeErrorZ_free(_res_conv);
9865 }
9866
9867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9868         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
9869         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
9870         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
9871         return (uint64_t)ret_conv;
9872 }
9873
9874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9875         LDKCVec_u8Z _res_ref;
9876         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9877         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
9878         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9879         CVec_u8Z_free(_res_ref);
9880 }
9881
9882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
9883         LDKRecoverableSignature arg_ref;
9884         CHECK((*env)->GetArrayLength(env, arg) == 68);
9885         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
9886         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9887         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
9888         return (uint64_t)ret_conv;
9889 }
9890
9891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
9892         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9893         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
9894         return (uint64_t)ret_conv;
9895 }
9896
9897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9898         if ((_res & 1) != 0) return;
9899         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
9900         FREE((void*)_res);
9901         CResult_RecoverableSignatureNoneZ_free(_res_conv);
9902 }
9903
9904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9905         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
9906         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
9907         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
9908         return (uint64_t)ret_conv;
9909 }
9910
9911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9912         LDKCVec_CVec_u8ZZ _res_constr;
9913         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9914         if (_res_constr.datalen > 0)
9915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9916         else
9917                 _res_constr.data = NULL;
9918         for (size_t i = 0; i < _res_constr.datalen; i++) {
9919                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9920                 LDKCVec_u8Z _res_conv_8_ref;
9921                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
9922                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9923                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
9924                 _res_constr.data[i] = _res_conv_8_ref;
9925         }
9926         CVec_CVec_u8ZZ_free(_res_constr);
9927 }
9928
9929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9930         LDKCVec_CVec_u8ZZ o_constr;
9931         o_constr.datalen = (*env)->GetArrayLength(env, o);
9932         if (o_constr.datalen > 0)
9933                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
9934         else
9935                 o_constr.data = NULL;
9936         for (size_t i = 0; i < o_constr.datalen; i++) {
9937                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9938                 LDKCVec_u8Z o_conv_8_ref;
9939                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
9940                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
9941                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
9942                 o_constr.data[i] = o_conv_8_ref;
9943         }
9944         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9945         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
9946         return (uint64_t)ret_conv;
9947 }
9948
9949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
9950         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9951         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
9952         return (uint64_t)ret_conv;
9953 }
9954
9955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9956         if ((_res & 1) != 0) return;
9957         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
9958         FREE((void*)_res);
9959         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
9960 }
9961
9962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9963         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
9964         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
9965         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
9966         return (uint64_t)ret_conv;
9967 }
9968
9969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9970         LDKInMemorySigner o_conv;
9971         o_conv.inner = (void*)(o & (~1));
9972         o_conv.is_owned = (o & 1) || (o == 0);
9973         o_conv = InMemorySigner_clone(&o_conv);
9974         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9975         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
9976         return (uint64_t)ret_conv;
9977 }
9978
9979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9980         LDKDecodeError e_conv;
9981         e_conv.inner = (void*)(e & (~1));
9982         e_conv.is_owned = (e & 1) || (e == 0);
9983         e_conv = DecodeError_clone(&e_conv);
9984         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9985         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
9986         return (uint64_t)ret_conv;
9987 }
9988
9989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9990         if ((_res & 1) != 0) return;
9991         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
9992         FREE((void*)_res);
9993         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
9994 }
9995
9996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9997         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
9998         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
9999         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10000         return (uint64_t)ret_conv;
10001 }
10002
10003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10004         LDKCVec_TxOutZ _res_constr;
10005         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10006         if (_res_constr.datalen > 0)
10007                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10008         else
10009                 _res_constr.data = NULL;
10010         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10011         for (size_t h = 0; h < _res_constr.datalen; h++) {
10012                 int64_t _res_conv_7 = _res_vals[h];
10013                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10014                 FREE((void*)_res_conv_7);
10015                 _res_constr.data[h] = _res_conv_7_conv;
10016         }
10017         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10018         CVec_TxOutZ_free(_res_constr);
10019 }
10020
10021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10022         LDKTransaction o_ref;
10023         o_ref.datalen = (*env)->GetArrayLength(env, o);
10024         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10025         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10026         o_ref.data_is_owned = true;
10027         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10028         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10029         return (uint64_t)ret_conv;
10030 }
10031
10032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10033         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10034         *ret_conv = CResult_TransactionNoneZ_err();
10035         return (uint64_t)ret_conv;
10036 }
10037
10038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10039         if ((_res & 1) != 0) return;
10040         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10041         FREE((void*)_res);
10042         CResult_TransactionNoneZ_free(_res_conv);
10043 }
10044
10045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10046         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10047         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10048         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10049         return (uint64_t)ret_conv;
10050 }
10051
10052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10053         LDKThirtyTwoBytes a_ref;
10054         CHECK((*env)->GetArrayLength(env, a) == 32);
10055         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10056         LDKChannelMonitor b_conv;
10057         b_conv.inner = (void*)(b & (~1));
10058         b_conv.is_owned = (b & 1) || (b == 0);
10059         b_conv = ChannelMonitor_clone(&b_conv);
10060         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10061         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10062         return (uint64_t)ret_ref;
10063 }
10064
10065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10066         if ((_res & 1) != 0) return;
10067         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10068         FREE((void*)_res);
10069         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10070 }
10071
10072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10073         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10074         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10075         if (_res_constr.datalen > 0)
10076                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10077         else
10078                 _res_constr.data = NULL;
10079         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10080         for (size_t i = 0; i < _res_constr.datalen; i++) {
10081                 int64_t _res_conv_34 = _res_vals[i];
10082                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10083                 FREE((void*)_res_conv_34);
10084                 _res_constr.data[i] = _res_conv_34_conv;
10085         }
10086         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10087         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10088 }
10089
10090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10091         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10092         o_constr.datalen = (*env)->GetArrayLength(env, o);
10093         if (o_constr.datalen > 0)
10094                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10095         else
10096                 o_constr.data = NULL;
10097         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10098         for (size_t i = 0; i < o_constr.datalen; i++) {
10099                 int64_t o_conv_34 = o_vals[i];
10100                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10101                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10102                 o_constr.data[i] = o_conv_34_conv;
10103         }
10104         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10105         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10106         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10107         return (uint64_t)ret_conv;
10108 }
10109
10110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10111         LDKIOError e_conv = LDKIOError_from_java(env, e);
10112         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10113         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10114         return (uint64_t)ret_conv;
10115 }
10116
10117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10118         if ((_res & 1) != 0) return;
10119         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10120         FREE((void*)_res);
10121         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10122 }
10123
10124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10125         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10126         *ret_conv = CResult_NoneAPIErrorZ_ok();
10127         return (uint64_t)ret_conv;
10128 }
10129
10130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10131         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10132         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10133         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10134         return (uint64_t)ret_conv;
10135 }
10136
10137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10138         if ((_res & 1) != 0) return;
10139         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10140         FREE((void*)_res);
10141         CResult_NoneAPIErrorZ_free(_res_conv);
10142 }
10143
10144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10145         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10146         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10147         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10148         return (uint64_t)ret_conv;
10149 }
10150
10151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10152         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10153         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10154         if (_res_constr.datalen > 0)
10155                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10156         else
10157                 _res_constr.data = NULL;
10158         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10159         for (size_t w = 0; w < _res_constr.datalen; w++) {
10160                 int64_t _res_conv_22 = _res_vals[w];
10161                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10162                 FREE((void*)_res_conv_22);
10163                 _res_constr.data[w] = _res_conv_22_conv;
10164         }
10165         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10166         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10167 }
10168
10169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10170         LDKCVec_APIErrorZ _res_constr;
10171         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10172         if (_res_constr.datalen > 0)
10173                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10174         else
10175                 _res_constr.data = NULL;
10176         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10177         for (size_t k = 0; k < _res_constr.datalen; k++) {
10178                 int64_t _res_conv_10 = _res_vals[k];
10179                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10180                 FREE((void*)_res_conv_10);
10181                 _res_constr.data[k] = _res_conv_10_conv;
10182         }
10183         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10184         CVec_APIErrorZ_free(_res_constr);
10185 }
10186
10187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10188         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10189         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10190         return (uint64_t)ret_conv;
10191 }
10192
10193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10194         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10195         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10196         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10197         return (uint64_t)ret_conv;
10198 }
10199
10200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10201         if ((_res & 1) != 0) return;
10202         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10203         FREE((void*)_res);
10204         CResult_NonePaymentSendFailureZ_free(_res_conv);
10205 }
10206
10207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10208         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10209         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10210         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10211         return (uint64_t)ret_conv;
10212 }
10213
10214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10215         LDKCVec_NetAddressZ _res_constr;
10216         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10217         if (_res_constr.datalen > 0)
10218                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10219         else
10220                 _res_constr.data = NULL;
10221         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10222         for (size_t m = 0; m < _res_constr.datalen; m++) {
10223                 int64_t _res_conv_12 = _res_vals[m];
10224                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10225                 FREE((void*)_res_conv_12);
10226                 _res_constr.data[m] = _res_conv_12_conv;
10227         }
10228         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10229         CVec_NetAddressZ_free(_res_constr);
10230 }
10231
10232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10233         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10234         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10235         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10236         return (uint64_t)ret_ref;
10237 }
10238
10239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10240         LDKThirtyTwoBytes a_ref;
10241         CHECK((*env)->GetArrayLength(env, a) == 32);
10242         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10243         LDKThirtyTwoBytes b_ref;
10244         CHECK((*env)->GetArrayLength(env, b) == 32);
10245         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10246         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10247         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10248         return (uint64_t)ret_ref;
10249 }
10250
10251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10252         if ((_res & 1) != 0) return;
10253         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10254         FREE((void*)_res);
10255         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10256 }
10257
10258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10259         LDKThirtyTwoBytes o_ref;
10260         CHECK((*env)->GetArrayLength(env, o) == 32);
10261         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10262         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10263         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10264         return (uint64_t)ret_conv;
10265 }
10266
10267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10268         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10269         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10270         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10271         return (uint64_t)ret_conv;
10272 }
10273
10274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10275         if ((_res & 1) != 0) return;
10276         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10277         FREE((void*)_res);
10278         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10279 }
10280
10281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10282         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10283         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10284         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10285         return (uint64_t)ret_conv;
10286 }
10287
10288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10289         LDKCVec_ChannelMonitorZ _res_constr;
10290         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10291         if (_res_constr.datalen > 0)
10292                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10293         else
10294                 _res_constr.data = NULL;
10295         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10296         for (size_t q = 0; q < _res_constr.datalen; q++) {
10297                 int64_t _res_conv_16 = _res_vals[q];
10298                 LDKChannelMonitor _res_conv_16_conv;
10299                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10300                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10301                 _res_constr.data[q] = _res_conv_16_conv;
10302         }
10303         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10304         CVec_ChannelMonitorZ_free(_res_constr);
10305 }
10306
10307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10308         LDKThirtyTwoBytes a_ref;
10309         CHECK((*env)->GetArrayLength(env, a) == 32);
10310         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10311         LDKChannelManager b_conv;
10312         b_conv.inner = (void*)(b & (~1));
10313         b_conv.is_owned = (b & 1) || (b == 0);
10314         // Warning: we need a move here but no clone is available for LDKChannelManager
10315         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10316         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10317         return (uint64_t)ret_ref;
10318 }
10319
10320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10321         if ((_res & 1) != 0) return;
10322         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10323         FREE((void*)_res);
10324         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10325 }
10326
10327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10328         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10329         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10330         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10331         return (uint64_t)ret_conv;
10332 }
10333
10334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10335         LDKDecodeError e_conv;
10336         e_conv.inner = (void*)(e & (~1));
10337         e_conv.is_owned = (e & 1) || (e == 0);
10338         e_conv = DecodeError_clone(&e_conv);
10339         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10340         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10341         return (uint64_t)ret_conv;
10342 }
10343
10344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10345         if ((_res & 1) != 0) return;
10346         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10347         FREE((void*)_res);
10348         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10349 }
10350
10351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10352         LDKChannelConfig o_conv;
10353         o_conv.inner = (void*)(o & (~1));
10354         o_conv.is_owned = (o & 1) || (o == 0);
10355         o_conv = ChannelConfig_clone(&o_conv);
10356         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10357         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10358         return (uint64_t)ret_conv;
10359 }
10360
10361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10362         LDKDecodeError e_conv;
10363         e_conv.inner = (void*)(e & (~1));
10364         e_conv.is_owned = (e & 1) || (e == 0);
10365         e_conv = DecodeError_clone(&e_conv);
10366         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10367         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10368         return (uint64_t)ret_conv;
10369 }
10370
10371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10372         if ((_res & 1) != 0) return;
10373         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10374         FREE((void*)_res);
10375         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10376 }
10377
10378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10379         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10380         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10381         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10382         return (uint64_t)ret_conv;
10383 }
10384
10385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10386         LDKOutPoint o_conv;
10387         o_conv.inner = (void*)(o & (~1));
10388         o_conv.is_owned = (o & 1) || (o == 0);
10389         o_conv = OutPoint_clone(&o_conv);
10390         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10391         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10392         return (uint64_t)ret_conv;
10393 }
10394
10395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10396         LDKDecodeError e_conv;
10397         e_conv.inner = (void*)(e & (~1));
10398         e_conv.is_owned = (e & 1) || (e == 0);
10399         e_conv = DecodeError_clone(&e_conv);
10400         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10401         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10402         return (uint64_t)ret_conv;
10403 }
10404
10405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10406         if ((_res & 1) != 0) return;
10407         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10408         FREE((void*)_res);
10409         CResult_OutPointDecodeErrorZ_free(_res_conv);
10410 }
10411
10412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10413         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10414         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10415         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10416         return (uint64_t)ret_conv;
10417 }
10418
10419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10420         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10421         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10422         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10423         return (uint64_t)ret_conv;
10424 }
10425
10426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10427         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10428         *ret_conv = CResult_SiPrefixNoneZ_err();
10429         return (uint64_t)ret_conv;
10430 }
10431
10432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10433         if ((_res & 1) != 0) return;
10434         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10435         FREE((void*)_res);
10436         CResult_SiPrefixNoneZ_free(_res_conv);
10437 }
10438
10439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10440         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10441         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10442         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10443         return (uint64_t)ret_conv;
10444 }
10445
10446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10447         LDKInvoice o_conv;
10448         o_conv.inner = (void*)(o & (~1));
10449         o_conv.is_owned = (o & 1) || (o == 0);
10450         o_conv = Invoice_clone(&o_conv);
10451         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10452         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10453         return (uint64_t)ret_conv;
10454 }
10455
10456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10457         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10458         *ret_conv = CResult_InvoiceNoneZ_err();
10459         return (uint64_t)ret_conv;
10460 }
10461
10462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10463         if ((_res & 1) != 0) return;
10464         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10465         FREE((void*)_res);
10466         CResult_InvoiceNoneZ_free(_res_conv);
10467 }
10468
10469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10470         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10471         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10472         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10473         return (uint64_t)ret_conv;
10474 }
10475
10476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10477         LDKSignedRawInvoice o_conv;
10478         o_conv.inner = (void*)(o & (~1));
10479         o_conv.is_owned = (o & 1) || (o == 0);
10480         o_conv = SignedRawInvoice_clone(&o_conv);
10481         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10482         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10483         return (uint64_t)ret_conv;
10484 }
10485
10486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10487         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10488         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10489         return (uint64_t)ret_conv;
10490 }
10491
10492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10493         if ((_res & 1) != 0) return;
10494         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10495         FREE((void*)_res);
10496         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10497 }
10498
10499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10500         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10501         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10502         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10503         return (uint64_t)ret_conv;
10504 }
10505
10506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10507         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10508         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10509         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10510         return (uint64_t)ret_ref;
10511 }
10512
10513 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) {
10514         LDKRawInvoice a_conv;
10515         a_conv.inner = (void*)(a & (~1));
10516         a_conv.is_owned = (a & 1) || (a == 0);
10517         a_conv = RawInvoice_clone(&a_conv);
10518         LDKThirtyTwoBytes b_ref;
10519         CHECK((*env)->GetArrayLength(env, b) == 32);
10520         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10521         LDKInvoiceSignature c_conv;
10522         c_conv.inner = (void*)(c & (~1));
10523         c_conv.is_owned = (c & 1) || (c == 0);
10524         c_conv = InvoiceSignature_clone(&c_conv);
10525         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10526         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10527         return (uint64_t)ret_ref;
10528 }
10529
10530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10531         if ((_res & 1) != 0) return;
10532         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10533         FREE((void*)_res);
10534         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10535 }
10536
10537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10538         LDKPayeePubKey o_conv;
10539         o_conv.inner = (void*)(o & (~1));
10540         o_conv.is_owned = (o & 1) || (o == 0);
10541         o_conv = PayeePubKey_clone(&o_conv);
10542         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10543         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10544         return (uint64_t)ret_conv;
10545 }
10546
10547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10548         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10549         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10550         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10551         return (uint64_t)ret_conv;
10552 }
10553
10554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10555         if ((_res & 1) != 0) return;
10556         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10557         FREE((void*)_res);
10558         CResult_PayeePubKeyErrorZ_free(_res_conv);
10559 }
10560
10561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10562         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10563         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10564         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10565         return (uint64_t)ret_conv;
10566 }
10567
10568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10569         LDKCVec_PrivateRouteZ _res_constr;
10570         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10571         if (_res_constr.datalen > 0)
10572                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10573         else
10574                 _res_constr.data = NULL;
10575         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10576         for (size_t o = 0; o < _res_constr.datalen; o++) {
10577                 int64_t _res_conv_14 = _res_vals[o];
10578                 LDKPrivateRoute _res_conv_14_conv;
10579                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10580                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10581                 _res_constr.data[o] = _res_conv_14_conv;
10582         }
10583         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10584         CVec_PrivateRouteZ_free(_res_constr);
10585 }
10586
10587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10588         LDKPositiveTimestamp o_conv;
10589         o_conv.inner = (void*)(o & (~1));
10590         o_conv.is_owned = (o & 1) || (o == 0);
10591         o_conv = PositiveTimestamp_clone(&o_conv);
10592         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10593         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10594         return (uint64_t)ret_conv;
10595 }
10596
10597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10598         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10599         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10600         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
10601         return (uint64_t)ret_conv;
10602 }
10603
10604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10605         if ((_res & 1) != 0) return;
10606         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
10607         FREE((void*)_res);
10608         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
10609 }
10610
10611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10612         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
10613         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10614         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
10615         return (uint64_t)ret_conv;
10616 }
10617
10618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
10619         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10620         *ret_conv = CResult_NoneSemanticErrorZ_ok();
10621         return (uint64_t)ret_conv;
10622 }
10623
10624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10625         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
10626         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10627         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
10628         return (uint64_t)ret_conv;
10629 }
10630
10631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10632         if ((_res & 1) != 0) return;
10633         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
10634         FREE((void*)_res);
10635         CResult_NoneSemanticErrorZ_free(_res_conv);
10636 }
10637
10638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10639         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
10640         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
10641         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
10642         return (uint64_t)ret_conv;
10643 }
10644
10645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10646         LDKInvoice o_conv;
10647         o_conv.inner = (void*)(o & (~1));
10648         o_conv.is_owned = (o & 1) || (o == 0);
10649         o_conv = Invoice_clone(&o_conv);
10650         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10651         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
10652         return (uint64_t)ret_conv;
10653 }
10654
10655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10656         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
10657         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10658         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
10659         return (uint64_t)ret_conv;
10660 }
10661
10662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10663         if ((_res & 1) != 0) return;
10664         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
10665         FREE((void*)_res);
10666         CResult_InvoiceSemanticErrorZ_free(_res_conv);
10667 }
10668
10669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10670         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
10671         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
10672         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
10673         return (uint64_t)ret_conv;
10674 }
10675
10676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10677         LDKDescription o_conv;
10678         o_conv.inner = (void*)(o & (~1));
10679         o_conv.is_owned = (o & 1) || (o == 0);
10680         o_conv = Description_clone(&o_conv);
10681         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10682         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
10683         return (uint64_t)ret_conv;
10684 }
10685
10686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10687         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10688         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10689         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
10690         return (uint64_t)ret_conv;
10691 }
10692
10693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10694         if ((_res & 1) != 0) return;
10695         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
10696         FREE((void*)_res);
10697         CResult_DescriptionCreationErrorZ_free(_res_conv);
10698 }
10699
10700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10701         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
10702         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
10703         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
10704         return (uint64_t)ret_conv;
10705 }
10706
10707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10708         LDKExpiryTime o_conv;
10709         o_conv.inner = (void*)(o & (~1));
10710         o_conv.is_owned = (o & 1) || (o == 0);
10711         o_conv = ExpiryTime_clone(&o_conv);
10712         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10713         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
10714         return (uint64_t)ret_conv;
10715 }
10716
10717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10718         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10719         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10720         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
10721         return (uint64_t)ret_conv;
10722 }
10723
10724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10725         if ((_res & 1) != 0) return;
10726         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
10727         FREE((void*)_res);
10728         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
10729 }
10730
10731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10732         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
10733         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
10734         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
10735         return (uint64_t)ret_conv;
10736 }
10737
10738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10739         LDKPrivateRoute o_conv;
10740         o_conv.inner = (void*)(o & (~1));
10741         o_conv.is_owned = (o & 1) || (o == 0);
10742         o_conv = PrivateRoute_clone(&o_conv);
10743         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10744         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
10745         return (uint64_t)ret_conv;
10746 }
10747
10748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10749         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10750         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10751         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
10752         return (uint64_t)ret_conv;
10753 }
10754
10755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10756         if ((_res & 1) != 0) return;
10757         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
10758         FREE((void*)_res);
10759         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
10760 }
10761
10762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10763         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
10764         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10765         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
10766         return (uint64_t)ret_conv;
10767 }
10768
10769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
10770         LDKStr o_conv = java_to_owned_str(env, o);
10771         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10772         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10773         return (uint64_t)ret_conv;
10774 }
10775
10776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10777         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10778         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10779         *ret_conv = CResult_StringErrorZ_err(e_conv);
10780         return (uint64_t)ret_conv;
10781 }
10782
10783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10784         if ((_res & 1) != 0) return;
10785         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
10786         FREE((void*)_res);
10787         CResult_StringErrorZ_free(_res_conv);
10788 }
10789
10790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10791         LDKChannelMonitorUpdate o_conv;
10792         o_conv.inner = (void*)(o & (~1));
10793         o_conv.is_owned = (o & 1) || (o == 0);
10794         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10795         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10796         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10797         return (uint64_t)ret_conv;
10798 }
10799
10800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10801         LDKDecodeError e_conv;
10802         e_conv.inner = (void*)(e & (~1));
10803         e_conv.is_owned = (e & 1) || (e == 0);
10804         e_conv = DecodeError_clone(&e_conv);
10805         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10806         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10807         return (uint64_t)ret_conv;
10808 }
10809
10810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10811         if ((_res & 1) != 0) return;
10812         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10813         FREE((void*)_res);
10814         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10815 }
10816
10817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10818         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10819         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10820         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10821         return (uint64_t)ret_conv;
10822 }
10823
10824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10825         LDKHTLCUpdate o_conv;
10826         o_conv.inner = (void*)(o & (~1));
10827         o_conv.is_owned = (o & 1) || (o == 0);
10828         o_conv = HTLCUpdate_clone(&o_conv);
10829         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10830         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10831         return (uint64_t)ret_conv;
10832 }
10833
10834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10835         LDKDecodeError e_conv;
10836         e_conv.inner = (void*)(e & (~1));
10837         e_conv.is_owned = (e & 1) || (e == 0);
10838         e_conv = DecodeError_clone(&e_conv);
10839         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10840         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10841         return (uint64_t)ret_conv;
10842 }
10843
10844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10845         if ((_res & 1) != 0) return;
10846         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10847         FREE((void*)_res);
10848         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10849 }
10850
10851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10852         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10853         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10854         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10855         return (uint64_t)ret_conv;
10856 }
10857
10858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
10859         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10860         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
10861         return (uint64_t)ret_conv;
10862 }
10863
10864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10865         LDKMonitorUpdateError e_conv;
10866         e_conv.inner = (void*)(e & (~1));
10867         e_conv.is_owned = (e & 1) || (e == 0);
10868         e_conv = MonitorUpdateError_clone(&e_conv);
10869         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10870         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
10871         return (uint64_t)ret_conv;
10872 }
10873
10874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10875         if ((_res & 1) != 0) return;
10876         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
10877         FREE((void*)_res);
10878         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
10879 }
10880
10881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10882         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
10883         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10884         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
10885         return (uint64_t)ret_conv;
10886 }
10887
10888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10889         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
10890         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10891         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
10892         return (uint64_t)ret_ref;
10893 }
10894
10895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
10896         LDKOutPoint a_conv;
10897         a_conv.inner = (void*)(a & (~1));
10898         a_conv.is_owned = (a & 1) || (a == 0);
10899         a_conv = OutPoint_clone(&a_conv);
10900         LDKCVec_u8Z b_ref;
10901         b_ref.datalen = (*env)->GetArrayLength(env, b);
10902         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10903         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10904         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10905         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10906         return (uint64_t)ret_ref;
10907 }
10908
10909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10910         if ((_res & 1) != 0) return;
10911         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
10912         FREE((void*)_res);
10913         C2Tuple_OutPointScriptZ_free(_res_conv);
10914 }
10915
10916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10917         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
10918         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10919         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
10920         return (uint64_t)ret_ref;
10921 }
10922
10923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
10924         LDKCVec_u8Z b_ref;
10925         b_ref.datalen = (*env)->GetArrayLength(env, b);
10926         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10927         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
10928         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10929         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
10930         return (uint64_t)ret_ref;
10931 }
10932
10933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10934         if ((_res & 1) != 0) return;
10935         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
10936         FREE((void*)_res);
10937         C2Tuple_u32ScriptZ_free(_res_conv);
10938 }
10939
10940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10941         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10942         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10943         if (_res_constr.datalen > 0)
10944                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10945         else
10946                 _res_constr.data = NULL;
10947         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10948         for (size_t b = 0; b < _res_constr.datalen; b++) {
10949                 int64_t _res_conv_27 = _res_vals[b];
10950                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
10951                 FREE((void*)_res_conv_27);
10952                 _res_constr.data[b] = _res_conv_27_conv;
10953         }
10954         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10955         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10956 }
10957
10958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10959         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
10960         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10961         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
10962         return (uint64_t)ret_ref;
10963 }
10964
10965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
10966         LDKThirtyTwoBytes a_ref;
10967         CHECK((*env)->GetArrayLength(env, a) == 32);
10968         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10969         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10970         b_constr.datalen = (*env)->GetArrayLength(env, b);
10971         if (b_constr.datalen > 0)
10972                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10973         else
10974                 b_constr.data = NULL;
10975         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
10976         for (size_t b = 0; b < b_constr.datalen; b++) {
10977                 int64_t b_conv_27 = b_vals[b];
10978                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
10979                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
10980                 b_constr.data[b] = b_conv_27_conv;
10981         }
10982         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
10983         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10984         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10985         return (uint64_t)ret_ref;
10986 }
10987
10988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10989         if ((_res & 1) != 0) return;
10990         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
10991         FREE((void*)_res);
10992         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10993 }
10994
10995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10996         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10997         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10998         if (_res_constr.datalen > 0)
10999                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11000         else
11001                 _res_constr.data = NULL;
11002         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11003         for (size_t v = 0; v < _res_constr.datalen; v++) {
11004                 int64_t _res_conv_47 = _res_vals[v];
11005                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11006                 FREE((void*)_res_conv_47);
11007                 _res_constr.data[v] = _res_conv_47_conv;
11008         }
11009         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11010         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11011 }
11012
11013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11014         LDKCVec_EventZ _res_constr;
11015         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11016         if (_res_constr.datalen > 0)
11017                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11018         else
11019                 _res_constr.data = NULL;
11020         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11021         for (size_t h = 0; h < _res_constr.datalen; h++) {
11022                 int64_t _res_conv_7 = _res_vals[h];
11023                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11024                 FREE((void*)_res_conv_7);
11025                 _res_constr.data[h] = _res_conv_7_conv;
11026         }
11027         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11028         CVec_EventZ_free(_res_constr);
11029 }
11030
11031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11032         LDKCVec_TransactionZ _res_constr;
11033         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11034         if (_res_constr.datalen > 0)
11035                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11036         else
11037                 _res_constr.data = NULL;
11038         for (size_t i = 0; i < _res_constr.datalen; i++) {
11039                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11040                 LDKTransaction _res_conv_8_ref;
11041                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11042                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11043                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11044                 _res_conv_8_ref.data_is_owned = true;
11045                 _res_constr.data[i] = _res_conv_8_ref;
11046         }
11047         CVec_TransactionZ_free(_res_constr);
11048 }
11049
11050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11051         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11052         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11053         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11054         return (uint64_t)ret_ref;
11055 }
11056
11057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11058         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11059         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11060         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11061         return (uint64_t)ret_ref;
11062 }
11063
11064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11065         if ((_res & 1) != 0) return;
11066         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11067         FREE((void*)_res);
11068         C2Tuple_u32TxOutZ_free(_res_conv);
11069 }
11070
11071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11072         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11073         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11074         if (_res_constr.datalen > 0)
11075                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11076         else
11077                 _res_constr.data = NULL;
11078         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11079         for (size_t a = 0; a < _res_constr.datalen; a++) {
11080                 int64_t _res_conv_26 = _res_vals[a];
11081                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11082                 FREE((void*)_res_conv_26);
11083                 _res_constr.data[a] = _res_conv_26_conv;
11084         }
11085         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11086         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11087 }
11088
11089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11090         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11091         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11092         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11093         return (uint64_t)ret_ref;
11094 }
11095
11096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11097         LDKThirtyTwoBytes a_ref;
11098         CHECK((*env)->GetArrayLength(env, a) == 32);
11099         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11100         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11101         b_constr.datalen = (*env)->GetArrayLength(env, b);
11102         if (b_constr.datalen > 0)
11103                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11104         else
11105                 b_constr.data = NULL;
11106         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11107         for (size_t a = 0; a < b_constr.datalen; a++) {
11108                 int64_t b_conv_26 = b_vals[a];
11109                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11110                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11111                 b_constr.data[a] = b_conv_26_conv;
11112         }
11113         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11114         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11115         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11116         return (uint64_t)ret_ref;
11117 }
11118
11119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11120         if ((_res & 1) != 0) return;
11121         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11122         FREE((void*)_res);
11123         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11124 }
11125
11126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11127         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11128         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11129         if (_res_constr.datalen > 0)
11130                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11131         else
11132                 _res_constr.data = NULL;
11133         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11134         for (size_t u = 0; u < _res_constr.datalen; u++) {
11135                 int64_t _res_conv_46 = _res_vals[u];
11136                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11137                 FREE((void*)_res_conv_46);
11138                 _res_constr.data[u] = _res_conv_46_conv;
11139         }
11140         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11141         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11142 }
11143
11144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11145         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11146         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11147         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11148         return (uint64_t)ret_conv;
11149 }
11150
11151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11152         LDKDecodeError e_conv;
11153         e_conv.inner = (void*)(e & (~1));
11154         e_conv.is_owned = (e & 1) || (e == 0);
11155         e_conv = DecodeError_clone(&e_conv);
11156         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11157         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11158         return (uint64_t)ret_conv;
11159 }
11160
11161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11162         if ((_res & 1) != 0) return;
11163         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11164         FREE((void*)_res);
11165         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11166 }
11167
11168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11169         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11170         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11171         return (uint64_t)ret_conv;
11172 }
11173
11174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11175         LDKLightningError e_conv;
11176         e_conv.inner = (void*)(e & (~1));
11177         e_conv.is_owned = (e & 1) || (e == 0);
11178         e_conv = LightningError_clone(&e_conv);
11179         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11180         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11181         return (uint64_t)ret_conv;
11182 }
11183
11184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11185         if ((_res & 1) != 0) return;
11186         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11187         FREE((void*)_res);
11188         CResult_boolLightningErrorZ_free(_res_conv);
11189 }
11190
11191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11192         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11193         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11194         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11195         return (uint64_t)ret_conv;
11196 }
11197
11198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11199         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11200         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11201         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11202         return (uint64_t)ret_ref;
11203 }
11204
11205 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) {
11206         LDKChannelAnnouncement a_conv;
11207         a_conv.inner = (void*)(a & (~1));
11208         a_conv.is_owned = (a & 1) || (a == 0);
11209         a_conv = ChannelAnnouncement_clone(&a_conv);
11210         LDKChannelUpdate b_conv;
11211         b_conv.inner = (void*)(b & (~1));
11212         b_conv.is_owned = (b & 1) || (b == 0);
11213         b_conv = ChannelUpdate_clone(&b_conv);
11214         LDKChannelUpdate c_conv;
11215         c_conv.inner = (void*)(c & (~1));
11216         c_conv.is_owned = (c & 1) || (c == 0);
11217         c_conv = ChannelUpdate_clone(&c_conv);
11218         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11219         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11220         return (uint64_t)ret_ref;
11221 }
11222
11223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11224         if ((_res & 1) != 0) return;
11225         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11226         FREE((void*)_res);
11227         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11228 }
11229
11230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11231         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11232         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11233         if (_res_constr.datalen > 0)
11234                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11235         else
11236                 _res_constr.data = NULL;
11237         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11238         for (size_t l = 0; l < _res_constr.datalen; l++) {
11239                 int64_t _res_conv_63 = _res_vals[l];
11240                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11241                 FREE((void*)_res_conv_63);
11242                 _res_constr.data[l] = _res_conv_63_conv;
11243         }
11244         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11245         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11246 }
11247
11248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11249         LDKCVec_NodeAnnouncementZ _res_constr;
11250         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11251         if (_res_constr.datalen > 0)
11252                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11253         else
11254                 _res_constr.data = NULL;
11255         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11256         for (size_t s = 0; s < _res_constr.datalen; s++) {
11257                 int64_t _res_conv_18 = _res_vals[s];
11258                 LDKNodeAnnouncement _res_conv_18_conv;
11259                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11260                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11261                 _res_constr.data[s] = _res_conv_18_conv;
11262         }
11263         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11264         CVec_NodeAnnouncementZ_free(_res_constr);
11265 }
11266
11267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11268         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11269         *ret_conv = CResult_NoneLightningErrorZ_ok();
11270         return (uint64_t)ret_conv;
11271 }
11272
11273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11274         LDKLightningError e_conv;
11275         e_conv.inner = (void*)(e & (~1));
11276         e_conv.is_owned = (e & 1) || (e == 0);
11277         e_conv = LightningError_clone(&e_conv);
11278         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11279         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11280         return (uint64_t)ret_conv;
11281 }
11282
11283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11284         if ((_res & 1) != 0) return;
11285         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11286         FREE((void*)_res);
11287         CResult_NoneLightningErrorZ_free(_res_conv);
11288 }
11289
11290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11291         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11292         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11293         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11294         return (uint64_t)ret_conv;
11295 }
11296
11297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11298         LDKCVec_PublicKeyZ _res_constr;
11299         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11300         if (_res_constr.datalen > 0)
11301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11302         else
11303                 _res_constr.data = NULL;
11304         for (size_t i = 0; i < _res_constr.datalen; i++) {
11305                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11306                 LDKPublicKey _res_conv_8_ref;
11307                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11308                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11309                 _res_constr.data[i] = _res_conv_8_ref;
11310         }
11311         CVec_PublicKeyZ_free(_res_constr);
11312 }
11313
11314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11315         LDKCVec_u8Z o_ref;
11316         o_ref.datalen = (*env)->GetArrayLength(env, o);
11317         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11318         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11319         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11320         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11321         return (uint64_t)ret_conv;
11322 }
11323
11324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11325         LDKPeerHandleError e_conv;
11326         e_conv.inner = (void*)(e & (~1));
11327         e_conv.is_owned = (e & 1) || (e == 0);
11328         e_conv = PeerHandleError_clone(&e_conv);
11329         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11330         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11331         return (uint64_t)ret_conv;
11332 }
11333
11334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11335         if ((_res & 1) != 0) return;
11336         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11337         FREE((void*)_res);
11338         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11339 }
11340
11341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11342         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11343         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11344         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11345         return (uint64_t)ret_conv;
11346 }
11347
11348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11349         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11350         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11351         return (uint64_t)ret_conv;
11352 }
11353
11354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11355         LDKPeerHandleError e_conv;
11356         e_conv.inner = (void*)(e & (~1));
11357         e_conv.is_owned = (e & 1) || (e == 0);
11358         e_conv = PeerHandleError_clone(&e_conv);
11359         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11360         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11361         return (uint64_t)ret_conv;
11362 }
11363
11364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11365         if ((_res & 1) != 0) return;
11366         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11367         FREE((void*)_res);
11368         CResult_NonePeerHandleErrorZ_free(_res_conv);
11369 }
11370
11371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11372         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11373         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11374         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11375         return (uint64_t)ret_conv;
11376 }
11377
11378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11379         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11380         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11381         return (uint64_t)ret_conv;
11382 }
11383
11384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11385         LDKPeerHandleError e_conv;
11386         e_conv.inner = (void*)(e & (~1));
11387         e_conv.is_owned = (e & 1) || (e == 0);
11388         e_conv = PeerHandleError_clone(&e_conv);
11389         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11390         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11391         return (uint64_t)ret_conv;
11392 }
11393
11394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11395         if ((_res & 1) != 0) return;
11396         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11397         FREE((void*)_res);
11398         CResult_boolPeerHandleErrorZ_free(_res_conv);
11399 }
11400
11401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11402         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11403         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11404         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11405         return (uint64_t)ret_conv;
11406 }
11407
11408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11409         LDKDirectionalChannelInfo o_conv;
11410         o_conv.inner = (void*)(o & (~1));
11411         o_conv.is_owned = (o & 1) || (o == 0);
11412         o_conv = DirectionalChannelInfo_clone(&o_conv);
11413         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11414         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11415         return (uint64_t)ret_conv;
11416 }
11417
11418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11419         LDKDecodeError e_conv;
11420         e_conv.inner = (void*)(e & (~1));
11421         e_conv.is_owned = (e & 1) || (e == 0);
11422         e_conv = DecodeError_clone(&e_conv);
11423         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11424         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11425         return (uint64_t)ret_conv;
11426 }
11427
11428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11429         if ((_res & 1) != 0) return;
11430         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11431         FREE((void*)_res);
11432         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11433 }
11434
11435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11436         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11437         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11438         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11439         return (uint64_t)ret_conv;
11440 }
11441
11442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11443         LDKChannelInfo o_conv;
11444         o_conv.inner = (void*)(o & (~1));
11445         o_conv.is_owned = (o & 1) || (o == 0);
11446         o_conv = ChannelInfo_clone(&o_conv);
11447         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11448         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11449         return (uint64_t)ret_conv;
11450 }
11451
11452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11453         LDKDecodeError e_conv;
11454         e_conv.inner = (void*)(e & (~1));
11455         e_conv.is_owned = (e & 1) || (e == 0);
11456         e_conv = DecodeError_clone(&e_conv);
11457         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11458         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11459         return (uint64_t)ret_conv;
11460 }
11461
11462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11463         if ((_res & 1) != 0) return;
11464         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11465         FREE((void*)_res);
11466         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11467 }
11468
11469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11470         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11471         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11472         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11473         return (uint64_t)ret_conv;
11474 }
11475
11476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11477         LDKRoutingFees o_conv;
11478         o_conv.inner = (void*)(o & (~1));
11479         o_conv.is_owned = (o & 1) || (o == 0);
11480         o_conv = RoutingFees_clone(&o_conv);
11481         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11482         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11483         return (uint64_t)ret_conv;
11484 }
11485
11486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11487         LDKDecodeError e_conv;
11488         e_conv.inner = (void*)(e & (~1));
11489         e_conv.is_owned = (e & 1) || (e == 0);
11490         e_conv = DecodeError_clone(&e_conv);
11491         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11492         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11493         return (uint64_t)ret_conv;
11494 }
11495
11496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11497         if ((_res & 1) != 0) return;
11498         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11499         FREE((void*)_res);
11500         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11501 }
11502
11503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11504         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11505         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11506         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11507         return (uint64_t)ret_conv;
11508 }
11509
11510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11511         LDKNodeAnnouncementInfo o_conv;
11512         o_conv.inner = (void*)(o & (~1));
11513         o_conv.is_owned = (o & 1) || (o == 0);
11514         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11515         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11516         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11517         return (uint64_t)ret_conv;
11518 }
11519
11520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11521         LDKDecodeError e_conv;
11522         e_conv.inner = (void*)(e & (~1));
11523         e_conv.is_owned = (e & 1) || (e == 0);
11524         e_conv = DecodeError_clone(&e_conv);
11525         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11526         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11527         return (uint64_t)ret_conv;
11528 }
11529
11530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11531         if ((_res & 1) != 0) return;
11532         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11533         FREE((void*)_res);
11534         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11535 }
11536
11537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11538         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11539         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11540         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11541         return (uint64_t)ret_conv;
11542 }
11543
11544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11545         LDKCVec_u64Z _res_constr;
11546         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11547         if (_res_constr.datalen > 0)
11548                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11549         else
11550                 _res_constr.data = NULL;
11551         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11552         for (size_t g = 0; g < _res_constr.datalen; g++) {
11553                 int64_t _res_conv_6 = _res_vals[g];
11554                 _res_constr.data[g] = _res_conv_6;
11555         }
11556         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11557         CVec_u64Z_free(_res_constr);
11558 }
11559
11560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11561         LDKNodeInfo o_conv;
11562         o_conv.inner = (void*)(o & (~1));
11563         o_conv.is_owned = (o & 1) || (o == 0);
11564         o_conv = NodeInfo_clone(&o_conv);
11565         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11566         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11567         return (uint64_t)ret_conv;
11568 }
11569
11570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11571         LDKDecodeError e_conv;
11572         e_conv.inner = (void*)(e & (~1));
11573         e_conv.is_owned = (e & 1) || (e == 0);
11574         e_conv = DecodeError_clone(&e_conv);
11575         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11576         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11577         return (uint64_t)ret_conv;
11578 }
11579
11580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11581         if ((_res & 1) != 0) return;
11582         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11583         FREE((void*)_res);
11584         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11585 }
11586
11587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11588         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11589         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11590         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11591         return (uint64_t)ret_conv;
11592 }
11593
11594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11595         LDKNetworkGraph o_conv;
11596         o_conv.inner = (void*)(o & (~1));
11597         o_conv.is_owned = (o & 1) || (o == 0);
11598         o_conv = NetworkGraph_clone(&o_conv);
11599         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11600         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
11601         return (uint64_t)ret_conv;
11602 }
11603
11604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11605         LDKDecodeError e_conv;
11606         e_conv.inner = (void*)(e & (~1));
11607         e_conv.is_owned = (e & 1) || (e == 0);
11608         e_conv = DecodeError_clone(&e_conv);
11609         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11610         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
11611         return (uint64_t)ret_conv;
11612 }
11613
11614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11615         if ((_res & 1) != 0) return;
11616         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
11617         FREE((void*)_res);
11618         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
11619 }
11620
11621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11622         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
11623         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11624         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
11625         return (uint64_t)ret_conv;
11626 }
11627
11628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
11629         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11630         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11631         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
11632         return (uint64_t)ret_conv;
11633 }
11634
11635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
11636         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11637         *ret_conv = CResult_NetAddressu8Z_err(e);
11638         return (uint64_t)ret_conv;
11639 }
11640
11641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11642         if ((_res & 1) != 0) return;
11643         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
11644         FREE((void*)_res);
11645         CResult_NetAddressu8Z_free(_res_conv);
11646 }
11647
11648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11649         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
11650         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11651         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
11652         return (uint64_t)ret_conv;
11653 }
11654
11655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11656         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
11657         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11658         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
11659         return (uint64_t)ret_conv;
11660 }
11661
11662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11663         LDKDecodeError e_conv;
11664         e_conv.inner = (void*)(e & (~1));
11665         e_conv.is_owned = (e & 1) || (e == 0);
11666         e_conv = DecodeError_clone(&e_conv);
11667         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11668         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
11669         return (uint64_t)ret_conv;
11670 }
11671
11672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11673         if ((_res & 1) != 0) return;
11674         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11675         FREE((void*)_res);
11676         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
11677 }
11678
11679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11680         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
11681         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11682         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
11683         return (uint64_t)ret_conv;
11684 }
11685
11686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11687         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11688         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11689         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
11690         return (uint64_t)ret_conv;
11691 }
11692
11693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11694         LDKDecodeError e_conv;
11695         e_conv.inner = (void*)(e & (~1));
11696         e_conv.is_owned = (e & 1) || (e == 0);
11697         e_conv = DecodeError_clone(&e_conv);
11698         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11699         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
11700         return (uint64_t)ret_conv;
11701 }
11702
11703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11704         if ((_res & 1) != 0) return;
11705         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
11706         FREE((void*)_res);
11707         CResult_NetAddressDecodeErrorZ_free(_res_conv);
11708 }
11709
11710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11711         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
11712         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11713         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
11714         return (uint64_t)ret_conv;
11715 }
11716
11717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11718         LDKCVec_UpdateAddHTLCZ _res_constr;
11719         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11720         if (_res_constr.datalen > 0)
11721                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11722         else
11723                 _res_constr.data = NULL;
11724         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11725         for (size_t p = 0; p < _res_constr.datalen; p++) {
11726                 int64_t _res_conv_15 = _res_vals[p];
11727                 LDKUpdateAddHTLC _res_conv_15_conv;
11728                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
11729                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
11730                 _res_constr.data[p] = _res_conv_15_conv;
11731         }
11732         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11733         CVec_UpdateAddHTLCZ_free(_res_constr);
11734 }
11735
11736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11737         LDKCVec_UpdateFulfillHTLCZ _res_constr;
11738         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11739         if (_res_constr.datalen > 0)
11740                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11741         else
11742                 _res_constr.data = NULL;
11743         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11744         for (size_t t = 0; t < _res_constr.datalen; t++) {
11745                 int64_t _res_conv_19 = _res_vals[t];
11746                 LDKUpdateFulfillHTLC _res_conv_19_conv;
11747                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
11748                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
11749                 _res_constr.data[t] = _res_conv_19_conv;
11750         }
11751         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11752         CVec_UpdateFulfillHTLCZ_free(_res_constr);
11753 }
11754
11755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11756         LDKCVec_UpdateFailHTLCZ _res_constr;
11757         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11758         if (_res_constr.datalen > 0)
11759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11760         else
11761                 _res_constr.data = NULL;
11762         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11763         for (size_t q = 0; q < _res_constr.datalen; q++) {
11764                 int64_t _res_conv_16 = _res_vals[q];
11765                 LDKUpdateFailHTLC _res_conv_16_conv;
11766                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11767                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11768                 _res_constr.data[q] = _res_conv_16_conv;
11769         }
11770         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11771         CVec_UpdateFailHTLCZ_free(_res_constr);
11772 }
11773
11774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11775         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
11776         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11777         if (_res_constr.datalen > 0)
11778                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11779         else
11780                 _res_constr.data = NULL;
11781         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11782         for (size_t z = 0; z < _res_constr.datalen; z++) {
11783                 int64_t _res_conv_25 = _res_vals[z];
11784                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
11785                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
11786                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
11787                 _res_constr.data[z] = _res_conv_25_conv;
11788         }
11789         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11790         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
11791 }
11792
11793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11794         LDKAcceptChannel o_conv;
11795         o_conv.inner = (void*)(o & (~1));
11796         o_conv.is_owned = (o & 1) || (o == 0);
11797         o_conv = AcceptChannel_clone(&o_conv);
11798         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11799         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
11800         return (uint64_t)ret_conv;
11801 }
11802
11803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11804         LDKDecodeError e_conv;
11805         e_conv.inner = (void*)(e & (~1));
11806         e_conv.is_owned = (e & 1) || (e == 0);
11807         e_conv = DecodeError_clone(&e_conv);
11808         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11809         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
11810         return (uint64_t)ret_conv;
11811 }
11812
11813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11814         if ((_res & 1) != 0) return;
11815         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
11816         FREE((void*)_res);
11817         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
11818 }
11819
11820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11821         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
11822         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11823         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
11824         return (uint64_t)ret_conv;
11825 }
11826
11827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11828         LDKAnnouncementSignatures o_conv;
11829         o_conv.inner = (void*)(o & (~1));
11830         o_conv.is_owned = (o & 1) || (o == 0);
11831         o_conv = AnnouncementSignatures_clone(&o_conv);
11832         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11833         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
11834         return (uint64_t)ret_conv;
11835 }
11836
11837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11838         LDKDecodeError e_conv;
11839         e_conv.inner = (void*)(e & (~1));
11840         e_conv.is_owned = (e & 1) || (e == 0);
11841         e_conv = DecodeError_clone(&e_conv);
11842         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11843         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
11844         return (uint64_t)ret_conv;
11845 }
11846
11847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11848         if ((_res & 1) != 0) return;
11849         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11850         FREE((void*)_res);
11851         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
11852 }
11853
11854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11855         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
11856         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11857         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
11858         return (uint64_t)ret_conv;
11859 }
11860
11861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11862         LDKChannelReestablish o_conv;
11863         o_conv.inner = (void*)(o & (~1));
11864         o_conv.is_owned = (o & 1) || (o == 0);
11865         o_conv = ChannelReestablish_clone(&o_conv);
11866         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11867         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
11868         return (uint64_t)ret_conv;
11869 }
11870
11871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11872         LDKDecodeError e_conv;
11873         e_conv.inner = (void*)(e & (~1));
11874         e_conv.is_owned = (e & 1) || (e == 0);
11875         e_conv = DecodeError_clone(&e_conv);
11876         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11877         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
11878         return (uint64_t)ret_conv;
11879 }
11880
11881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11882         if ((_res & 1) != 0) return;
11883         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
11884         FREE((void*)_res);
11885         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
11886 }
11887
11888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11889         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
11890         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11891         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
11892         return (uint64_t)ret_conv;
11893 }
11894
11895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11896         LDKClosingSigned o_conv;
11897         o_conv.inner = (void*)(o & (~1));
11898         o_conv.is_owned = (o & 1) || (o == 0);
11899         o_conv = ClosingSigned_clone(&o_conv);
11900         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11901         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
11902         return (uint64_t)ret_conv;
11903 }
11904
11905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11906         LDKDecodeError e_conv;
11907         e_conv.inner = (void*)(e & (~1));
11908         e_conv.is_owned = (e & 1) || (e == 0);
11909         e_conv = DecodeError_clone(&e_conv);
11910         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11911         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
11912         return (uint64_t)ret_conv;
11913 }
11914
11915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11916         if ((_res & 1) != 0) return;
11917         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11918         FREE((void*)_res);
11919         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
11920 }
11921
11922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11923         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
11924         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11925         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
11926         return (uint64_t)ret_conv;
11927 }
11928
11929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11930         LDKCommitmentSigned o_conv;
11931         o_conv.inner = (void*)(o & (~1));
11932         o_conv.is_owned = (o & 1) || (o == 0);
11933         o_conv = CommitmentSigned_clone(&o_conv);
11934         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11935         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
11936         return (uint64_t)ret_conv;
11937 }
11938
11939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11940         LDKDecodeError e_conv;
11941         e_conv.inner = (void*)(e & (~1));
11942         e_conv.is_owned = (e & 1) || (e == 0);
11943         e_conv = DecodeError_clone(&e_conv);
11944         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11945         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
11946         return (uint64_t)ret_conv;
11947 }
11948
11949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11950         if ((_res & 1) != 0) return;
11951         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11952         FREE((void*)_res);
11953         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
11954 }
11955
11956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11957         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
11958         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11959         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
11960         return (uint64_t)ret_conv;
11961 }
11962
11963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11964         LDKFundingCreated o_conv;
11965         o_conv.inner = (void*)(o & (~1));
11966         o_conv.is_owned = (o & 1) || (o == 0);
11967         o_conv = FundingCreated_clone(&o_conv);
11968         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11969         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
11970         return (uint64_t)ret_conv;
11971 }
11972
11973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11974         LDKDecodeError e_conv;
11975         e_conv.inner = (void*)(e & (~1));
11976         e_conv.is_owned = (e & 1) || (e == 0);
11977         e_conv = DecodeError_clone(&e_conv);
11978         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11979         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
11980         return (uint64_t)ret_conv;
11981 }
11982
11983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11984         if ((_res & 1) != 0) return;
11985         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11986         FREE((void*)_res);
11987         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
11988 }
11989
11990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11991         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
11992         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11993         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
11994         return (uint64_t)ret_conv;
11995 }
11996
11997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11998         LDKFundingSigned o_conv;
11999         o_conv.inner = (void*)(o & (~1));
12000         o_conv.is_owned = (o & 1) || (o == 0);
12001         o_conv = FundingSigned_clone(&o_conv);
12002         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12003         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12004         return (uint64_t)ret_conv;
12005 }
12006
12007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12008         LDKDecodeError e_conv;
12009         e_conv.inner = (void*)(e & (~1));
12010         e_conv.is_owned = (e & 1) || (e == 0);
12011         e_conv = DecodeError_clone(&e_conv);
12012         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12013         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12014         return (uint64_t)ret_conv;
12015 }
12016
12017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12018         if ((_res & 1) != 0) return;
12019         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12020         FREE((void*)_res);
12021         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12022 }
12023
12024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12025         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12026         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12027         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12028         return (uint64_t)ret_conv;
12029 }
12030
12031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12032         LDKFundingLocked o_conv;
12033         o_conv.inner = (void*)(o & (~1));
12034         o_conv.is_owned = (o & 1) || (o == 0);
12035         o_conv = FundingLocked_clone(&o_conv);
12036         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12037         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12038         return (uint64_t)ret_conv;
12039 }
12040
12041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12042         LDKDecodeError e_conv;
12043         e_conv.inner = (void*)(e & (~1));
12044         e_conv.is_owned = (e & 1) || (e == 0);
12045         e_conv = DecodeError_clone(&e_conv);
12046         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12047         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12048         return (uint64_t)ret_conv;
12049 }
12050
12051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12052         if ((_res & 1) != 0) return;
12053         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12054         FREE((void*)_res);
12055         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12056 }
12057
12058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12059         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12060         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12061         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12062         return (uint64_t)ret_conv;
12063 }
12064
12065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12066         LDKInit o_conv;
12067         o_conv.inner = (void*)(o & (~1));
12068         o_conv.is_owned = (o & 1) || (o == 0);
12069         o_conv = Init_clone(&o_conv);
12070         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12071         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12072         return (uint64_t)ret_conv;
12073 }
12074
12075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12076         LDKDecodeError e_conv;
12077         e_conv.inner = (void*)(e & (~1));
12078         e_conv.is_owned = (e & 1) || (e == 0);
12079         e_conv = DecodeError_clone(&e_conv);
12080         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12081         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12082         return (uint64_t)ret_conv;
12083 }
12084
12085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12086         if ((_res & 1) != 0) return;
12087         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12088         FREE((void*)_res);
12089         CResult_InitDecodeErrorZ_free(_res_conv);
12090 }
12091
12092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12093         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12094         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12095         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12096         return (uint64_t)ret_conv;
12097 }
12098
12099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12100         LDKOpenChannel o_conv;
12101         o_conv.inner = (void*)(o & (~1));
12102         o_conv.is_owned = (o & 1) || (o == 0);
12103         o_conv = OpenChannel_clone(&o_conv);
12104         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12105         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12106         return (uint64_t)ret_conv;
12107 }
12108
12109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12110         LDKDecodeError e_conv;
12111         e_conv.inner = (void*)(e & (~1));
12112         e_conv.is_owned = (e & 1) || (e == 0);
12113         e_conv = DecodeError_clone(&e_conv);
12114         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12115         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12116         return (uint64_t)ret_conv;
12117 }
12118
12119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12120         if ((_res & 1) != 0) return;
12121         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12122         FREE((void*)_res);
12123         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12124 }
12125
12126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12127         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12128         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12129         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12130         return (uint64_t)ret_conv;
12131 }
12132
12133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12134         LDKRevokeAndACK o_conv;
12135         o_conv.inner = (void*)(o & (~1));
12136         o_conv.is_owned = (o & 1) || (o == 0);
12137         o_conv = RevokeAndACK_clone(&o_conv);
12138         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12139         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12140         return (uint64_t)ret_conv;
12141 }
12142
12143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12144         LDKDecodeError e_conv;
12145         e_conv.inner = (void*)(e & (~1));
12146         e_conv.is_owned = (e & 1) || (e == 0);
12147         e_conv = DecodeError_clone(&e_conv);
12148         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12149         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12150         return (uint64_t)ret_conv;
12151 }
12152
12153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12154         if ((_res & 1) != 0) return;
12155         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12156         FREE((void*)_res);
12157         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12158 }
12159
12160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12161         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12162         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12163         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12164         return (uint64_t)ret_conv;
12165 }
12166
12167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12168         LDKShutdown o_conv;
12169         o_conv.inner = (void*)(o & (~1));
12170         o_conv.is_owned = (o & 1) || (o == 0);
12171         o_conv = Shutdown_clone(&o_conv);
12172         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12173         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12174         return (uint64_t)ret_conv;
12175 }
12176
12177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12178         LDKDecodeError e_conv;
12179         e_conv.inner = (void*)(e & (~1));
12180         e_conv.is_owned = (e & 1) || (e == 0);
12181         e_conv = DecodeError_clone(&e_conv);
12182         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12183         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12184         return (uint64_t)ret_conv;
12185 }
12186
12187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12188         if ((_res & 1) != 0) return;
12189         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12190         FREE((void*)_res);
12191         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12192 }
12193
12194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12195         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12196         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12197         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12198         return (uint64_t)ret_conv;
12199 }
12200
12201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12202         LDKUpdateFailHTLC o_conv;
12203         o_conv.inner = (void*)(o & (~1));
12204         o_conv.is_owned = (o & 1) || (o == 0);
12205         o_conv = UpdateFailHTLC_clone(&o_conv);
12206         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12207         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12208         return (uint64_t)ret_conv;
12209 }
12210
12211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12212         LDKDecodeError e_conv;
12213         e_conv.inner = (void*)(e & (~1));
12214         e_conv.is_owned = (e & 1) || (e == 0);
12215         e_conv = DecodeError_clone(&e_conv);
12216         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12217         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12218         return (uint64_t)ret_conv;
12219 }
12220
12221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12222         if ((_res & 1) != 0) return;
12223         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12224         FREE((void*)_res);
12225         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12226 }
12227
12228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12229         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12230         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12231         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12232         return (uint64_t)ret_conv;
12233 }
12234
12235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12236         LDKUpdateFailMalformedHTLC o_conv;
12237         o_conv.inner = (void*)(o & (~1));
12238         o_conv.is_owned = (o & 1) || (o == 0);
12239         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12240         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12241         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12242         return (uint64_t)ret_conv;
12243 }
12244
12245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12246         LDKDecodeError e_conv;
12247         e_conv.inner = (void*)(e & (~1));
12248         e_conv.is_owned = (e & 1) || (e == 0);
12249         e_conv = DecodeError_clone(&e_conv);
12250         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12251         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12252         return (uint64_t)ret_conv;
12253 }
12254
12255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12256         if ((_res & 1) != 0) return;
12257         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12258         FREE((void*)_res);
12259         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12260 }
12261
12262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12263         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12264         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12265         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12266         return (uint64_t)ret_conv;
12267 }
12268
12269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12270         LDKUpdateFee o_conv;
12271         o_conv.inner = (void*)(o & (~1));
12272         o_conv.is_owned = (o & 1) || (o == 0);
12273         o_conv = UpdateFee_clone(&o_conv);
12274         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12275         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12276         return (uint64_t)ret_conv;
12277 }
12278
12279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12280         LDKDecodeError e_conv;
12281         e_conv.inner = (void*)(e & (~1));
12282         e_conv.is_owned = (e & 1) || (e == 0);
12283         e_conv = DecodeError_clone(&e_conv);
12284         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12285         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12286         return (uint64_t)ret_conv;
12287 }
12288
12289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12290         if ((_res & 1) != 0) return;
12291         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12292         FREE((void*)_res);
12293         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12294 }
12295
12296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12297         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12298         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12299         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12300         return (uint64_t)ret_conv;
12301 }
12302
12303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12304         LDKUpdateFulfillHTLC o_conv;
12305         o_conv.inner = (void*)(o & (~1));
12306         o_conv.is_owned = (o & 1) || (o == 0);
12307         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12308         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12309         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12310         return (uint64_t)ret_conv;
12311 }
12312
12313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12314         LDKDecodeError e_conv;
12315         e_conv.inner = (void*)(e & (~1));
12316         e_conv.is_owned = (e & 1) || (e == 0);
12317         e_conv = DecodeError_clone(&e_conv);
12318         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12319         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12320         return (uint64_t)ret_conv;
12321 }
12322
12323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12324         if ((_res & 1) != 0) return;
12325         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12326         FREE((void*)_res);
12327         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12328 }
12329
12330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12331         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12332         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12333         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12334         return (uint64_t)ret_conv;
12335 }
12336
12337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12338         LDKUpdateAddHTLC o_conv;
12339         o_conv.inner = (void*)(o & (~1));
12340         o_conv.is_owned = (o & 1) || (o == 0);
12341         o_conv = UpdateAddHTLC_clone(&o_conv);
12342         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12343         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12344         return (uint64_t)ret_conv;
12345 }
12346
12347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12348         LDKDecodeError e_conv;
12349         e_conv.inner = (void*)(e & (~1));
12350         e_conv.is_owned = (e & 1) || (e == 0);
12351         e_conv = DecodeError_clone(&e_conv);
12352         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12353         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12354         return (uint64_t)ret_conv;
12355 }
12356
12357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12358         if ((_res & 1) != 0) return;
12359         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12360         FREE((void*)_res);
12361         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12362 }
12363
12364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12365         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12366         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12367         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12368         return (uint64_t)ret_conv;
12369 }
12370
12371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12372         LDKPing o_conv;
12373         o_conv.inner = (void*)(o & (~1));
12374         o_conv.is_owned = (o & 1) || (o == 0);
12375         o_conv = Ping_clone(&o_conv);
12376         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12377         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12378         return (uint64_t)ret_conv;
12379 }
12380
12381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12382         LDKDecodeError e_conv;
12383         e_conv.inner = (void*)(e & (~1));
12384         e_conv.is_owned = (e & 1) || (e == 0);
12385         e_conv = DecodeError_clone(&e_conv);
12386         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12387         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12388         return (uint64_t)ret_conv;
12389 }
12390
12391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12392         if ((_res & 1) != 0) return;
12393         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12394         FREE((void*)_res);
12395         CResult_PingDecodeErrorZ_free(_res_conv);
12396 }
12397
12398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12399         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12400         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12401         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12402         return (uint64_t)ret_conv;
12403 }
12404
12405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12406         LDKPong o_conv;
12407         o_conv.inner = (void*)(o & (~1));
12408         o_conv.is_owned = (o & 1) || (o == 0);
12409         o_conv = Pong_clone(&o_conv);
12410         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12411         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12412         return (uint64_t)ret_conv;
12413 }
12414
12415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12416         LDKDecodeError e_conv;
12417         e_conv.inner = (void*)(e & (~1));
12418         e_conv.is_owned = (e & 1) || (e == 0);
12419         e_conv = DecodeError_clone(&e_conv);
12420         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12421         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12422         return (uint64_t)ret_conv;
12423 }
12424
12425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12426         if ((_res & 1) != 0) return;
12427         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12428         FREE((void*)_res);
12429         CResult_PongDecodeErrorZ_free(_res_conv);
12430 }
12431
12432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12433         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12434         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12435         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12436         return (uint64_t)ret_conv;
12437 }
12438
12439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12440         LDKUnsignedChannelAnnouncement o_conv;
12441         o_conv.inner = (void*)(o & (~1));
12442         o_conv.is_owned = (o & 1) || (o == 0);
12443         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12444         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12445         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12446         return (uint64_t)ret_conv;
12447 }
12448
12449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12450         LDKDecodeError e_conv;
12451         e_conv.inner = (void*)(e & (~1));
12452         e_conv.is_owned = (e & 1) || (e == 0);
12453         e_conv = DecodeError_clone(&e_conv);
12454         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12455         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12456         return (uint64_t)ret_conv;
12457 }
12458
12459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12460         if ((_res & 1) != 0) return;
12461         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12462         FREE((void*)_res);
12463         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12464 }
12465
12466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12467         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12468         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12469         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12470         return (uint64_t)ret_conv;
12471 }
12472
12473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12474         LDKChannelAnnouncement o_conv;
12475         o_conv.inner = (void*)(o & (~1));
12476         o_conv.is_owned = (o & 1) || (o == 0);
12477         o_conv = ChannelAnnouncement_clone(&o_conv);
12478         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12479         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12480         return (uint64_t)ret_conv;
12481 }
12482
12483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12484         LDKDecodeError e_conv;
12485         e_conv.inner = (void*)(e & (~1));
12486         e_conv.is_owned = (e & 1) || (e == 0);
12487         e_conv = DecodeError_clone(&e_conv);
12488         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12489         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12490         return (uint64_t)ret_conv;
12491 }
12492
12493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12494         if ((_res & 1) != 0) return;
12495         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12496         FREE((void*)_res);
12497         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12498 }
12499
12500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12501         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12502         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12503         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12504         return (uint64_t)ret_conv;
12505 }
12506
12507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12508         LDKUnsignedChannelUpdate o_conv;
12509         o_conv.inner = (void*)(o & (~1));
12510         o_conv.is_owned = (o & 1) || (o == 0);
12511         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12512         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12513         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12514         return (uint64_t)ret_conv;
12515 }
12516
12517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12518         LDKDecodeError e_conv;
12519         e_conv.inner = (void*)(e & (~1));
12520         e_conv.is_owned = (e & 1) || (e == 0);
12521         e_conv = DecodeError_clone(&e_conv);
12522         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12523         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12524         return (uint64_t)ret_conv;
12525 }
12526
12527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12528         if ((_res & 1) != 0) return;
12529         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12530         FREE((void*)_res);
12531         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12532 }
12533
12534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12535         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12536         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12537         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12538         return (uint64_t)ret_conv;
12539 }
12540
12541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12542         LDKChannelUpdate o_conv;
12543         o_conv.inner = (void*)(o & (~1));
12544         o_conv.is_owned = (o & 1) || (o == 0);
12545         o_conv = ChannelUpdate_clone(&o_conv);
12546         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12547         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12548         return (uint64_t)ret_conv;
12549 }
12550
12551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12552         LDKDecodeError e_conv;
12553         e_conv.inner = (void*)(e & (~1));
12554         e_conv.is_owned = (e & 1) || (e == 0);
12555         e_conv = DecodeError_clone(&e_conv);
12556         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12557         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12558         return (uint64_t)ret_conv;
12559 }
12560
12561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12562         if ((_res & 1) != 0) return;
12563         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12564         FREE((void*)_res);
12565         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12566 }
12567
12568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12569         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12570         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12571         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12572         return (uint64_t)ret_conv;
12573 }
12574
12575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12576         LDKErrorMessage o_conv;
12577         o_conv.inner = (void*)(o & (~1));
12578         o_conv.is_owned = (o & 1) || (o == 0);
12579         o_conv = ErrorMessage_clone(&o_conv);
12580         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12581         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12582         return (uint64_t)ret_conv;
12583 }
12584
12585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12586         LDKDecodeError e_conv;
12587         e_conv.inner = (void*)(e & (~1));
12588         e_conv.is_owned = (e & 1) || (e == 0);
12589         e_conv = DecodeError_clone(&e_conv);
12590         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12591         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12592         return (uint64_t)ret_conv;
12593 }
12594
12595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12596         if ((_res & 1) != 0) return;
12597         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12598         FREE((void*)_res);
12599         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12600 }
12601
12602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12603         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
12604         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12605         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
12606         return (uint64_t)ret_conv;
12607 }
12608
12609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12610         LDKUnsignedNodeAnnouncement o_conv;
12611         o_conv.inner = (void*)(o & (~1));
12612         o_conv.is_owned = (o & 1) || (o == 0);
12613         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
12614         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12615         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
12616         return (uint64_t)ret_conv;
12617 }
12618
12619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12620         LDKDecodeError e_conv;
12621         e_conv.inner = (void*)(e & (~1));
12622         e_conv.is_owned = (e & 1) || (e == 0);
12623         e_conv = DecodeError_clone(&e_conv);
12624         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12625         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
12626         return (uint64_t)ret_conv;
12627 }
12628
12629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12630         if ((_res & 1) != 0) return;
12631         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12632         FREE((void*)_res);
12633         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
12634 }
12635
12636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12637         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
12638         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12639         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
12640         return (uint64_t)ret_conv;
12641 }
12642
12643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12644         LDKNodeAnnouncement o_conv;
12645         o_conv.inner = (void*)(o & (~1));
12646         o_conv.is_owned = (o & 1) || (o == 0);
12647         o_conv = NodeAnnouncement_clone(&o_conv);
12648         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12649         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
12650         return (uint64_t)ret_conv;
12651 }
12652
12653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12654         LDKDecodeError e_conv;
12655         e_conv.inner = (void*)(e & (~1));
12656         e_conv.is_owned = (e & 1) || (e == 0);
12657         e_conv = DecodeError_clone(&e_conv);
12658         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12659         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
12660         return (uint64_t)ret_conv;
12661 }
12662
12663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12664         if ((_res & 1) != 0) return;
12665         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12666         FREE((void*)_res);
12667         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
12668 }
12669
12670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12671         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
12672         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12673         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
12674         return (uint64_t)ret_conv;
12675 }
12676
12677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12678         LDKQueryShortChannelIds o_conv;
12679         o_conv.inner = (void*)(o & (~1));
12680         o_conv.is_owned = (o & 1) || (o == 0);
12681         o_conv = QueryShortChannelIds_clone(&o_conv);
12682         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12683         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
12684         return (uint64_t)ret_conv;
12685 }
12686
12687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12688         LDKDecodeError e_conv;
12689         e_conv.inner = (void*)(e & (~1));
12690         e_conv.is_owned = (e & 1) || (e == 0);
12691         e_conv = DecodeError_clone(&e_conv);
12692         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12693         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
12694         return (uint64_t)ret_conv;
12695 }
12696
12697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12698         if ((_res & 1) != 0) return;
12699         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
12700         FREE((void*)_res);
12701         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
12702 }
12703
12704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12705         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
12706         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12707         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
12708         return (uint64_t)ret_conv;
12709 }
12710
12711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12712         LDKReplyShortChannelIdsEnd o_conv;
12713         o_conv.inner = (void*)(o & (~1));
12714         o_conv.is_owned = (o & 1) || (o == 0);
12715         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
12716         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12717         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
12718         return (uint64_t)ret_conv;
12719 }
12720
12721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12722         LDKDecodeError e_conv;
12723         e_conv.inner = (void*)(e & (~1));
12724         e_conv.is_owned = (e & 1) || (e == 0);
12725         e_conv = DecodeError_clone(&e_conv);
12726         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12727         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
12728         return (uint64_t)ret_conv;
12729 }
12730
12731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12732         if ((_res & 1) != 0) return;
12733         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
12734         FREE((void*)_res);
12735         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
12736 }
12737
12738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12739         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
12740         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12741         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
12742         return (uint64_t)ret_conv;
12743 }
12744
12745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12746         LDKQueryChannelRange o_conv;
12747         o_conv.inner = (void*)(o & (~1));
12748         o_conv.is_owned = (o & 1) || (o == 0);
12749         o_conv = QueryChannelRange_clone(&o_conv);
12750         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12751         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
12752         return (uint64_t)ret_conv;
12753 }
12754
12755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12756         LDKDecodeError e_conv;
12757         e_conv.inner = (void*)(e & (~1));
12758         e_conv.is_owned = (e & 1) || (e == 0);
12759         e_conv = DecodeError_clone(&e_conv);
12760         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12761         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
12762         return (uint64_t)ret_conv;
12763 }
12764
12765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12766         if ((_res & 1) != 0) return;
12767         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12768         FREE((void*)_res);
12769         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
12770 }
12771
12772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12773         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
12774         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12775         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
12776         return (uint64_t)ret_conv;
12777 }
12778
12779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12780         LDKReplyChannelRange o_conv;
12781         o_conv.inner = (void*)(o & (~1));
12782         o_conv.is_owned = (o & 1) || (o == 0);
12783         o_conv = ReplyChannelRange_clone(&o_conv);
12784         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12785         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
12786         return (uint64_t)ret_conv;
12787 }
12788
12789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12790         LDKDecodeError e_conv;
12791         e_conv.inner = (void*)(e & (~1));
12792         e_conv.is_owned = (e & 1) || (e == 0);
12793         e_conv = DecodeError_clone(&e_conv);
12794         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12795         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
12796         return (uint64_t)ret_conv;
12797 }
12798
12799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12800         if ((_res & 1) != 0) return;
12801         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12802         FREE((void*)_res);
12803         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
12804 }
12805
12806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12807         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
12808         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12809         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
12810         return (uint64_t)ret_conv;
12811 }
12812
12813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12814         LDKGossipTimestampFilter o_conv;
12815         o_conv.inner = (void*)(o & (~1));
12816         o_conv.is_owned = (o & 1) || (o == 0);
12817         o_conv = GossipTimestampFilter_clone(&o_conv);
12818         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12819         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
12820         return (uint64_t)ret_conv;
12821 }
12822
12823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12824         LDKDecodeError e_conv;
12825         e_conv.inner = (void*)(e & (~1));
12826         e_conv.is_owned = (e & 1) || (e == 0);
12827         e_conv = DecodeError_clone(&e_conv);
12828         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12829         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
12830         return (uint64_t)ret_conv;
12831 }
12832
12833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12834         if ((_res & 1) != 0) return;
12835         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
12836         FREE((void*)_res);
12837         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
12838 }
12839
12840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12841         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
12842         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12843         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
12844         return (uint64_t)ret_conv;
12845 }
12846
12847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12848         LDKInvoice o_conv;
12849         o_conv.inner = (void*)(o & (~1));
12850         o_conv.is_owned = (o & 1) || (o == 0);
12851         o_conv = Invoice_clone(&o_conv);
12852         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12853         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
12854         return (uint64_t)ret_conv;
12855 }
12856
12857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12858         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
12859         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12860         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
12861         return (uint64_t)ret_conv;
12862 }
12863
12864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12865         if ((_res & 1) != 0) return;
12866         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
12867         FREE((void*)_res);
12868         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
12869 }
12870
12871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12872         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
12873         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12874         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
12875         return (uint64_t)ret_conv;
12876 }
12877
12878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12879         if ((this_ptr & 1) != 0) return;
12880         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
12881         FREE((void*)this_ptr);
12882         Event_free(this_ptr_conv);
12883 }
12884
12885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12886         LDKEvent* orig_conv = (LDKEvent*)orig;
12887         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12888         *ret_copy = Event_clone(orig_conv);
12889         uint64_t ret_ref = (uint64_t)ret_copy;
12890         return ret_ref;
12891 }
12892
12893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
12894         LDKEvent* obj_conv = (LDKEvent*)obj;
12895         LDKCVec_u8Z ret_var = Event_write(obj_conv);
12896         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12897         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12898         CVec_u8Z_free(ret_var);
12899         return ret_arr;
12900 }
12901
12902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12903         if ((this_ptr & 1) != 0) return;
12904         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
12905         FREE((void*)this_ptr);
12906         MessageSendEvent_free(this_ptr_conv);
12907 }
12908
12909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12910         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
12911         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12912         *ret_copy = MessageSendEvent_clone(orig_conv);
12913         uint64_t ret_ref = (uint64_t)ret_copy;
12914         return ret_ref;
12915 }
12916
12917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12918         if ((this_ptr & 1) != 0) return;
12919         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
12920         FREE((void*)this_ptr);
12921         MessageSendEventsProvider_free(this_ptr_conv);
12922 }
12923
12924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12925         if ((this_ptr & 1) != 0) return;
12926         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
12927         FREE((void*)this_ptr);
12928         EventsProvider_free(this_ptr_conv);
12929 }
12930
12931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12932         if ((this_ptr & 1) != 0) return;
12933         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
12934         FREE((void*)this_ptr);
12935         EventHandler_free(this_ptr_conv);
12936 }
12937
12938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
12939         if ((this_ptr & 1) != 0) return;
12940         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
12941         FREE((void*)this_ptr);
12942         APIError_free(this_ptr_conv);
12943 }
12944
12945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12946         LDKAPIError* orig_conv = (LDKAPIError*)orig;
12947         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12948         *ret_copy = APIError_clone(orig_conv);
12949         uint64_t ret_ref = (uint64_t)ret_copy;
12950         return ret_ref;
12951 }
12952
12953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
12954         LDKu8slice msg_ref;
12955         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12956         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12957         LDKSecretKey sk_ref;
12958         CHECK((*env)->GetArrayLength(env, sk) == 32);
12959         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_ref.bytes);
12960         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12961         *ret_conv = sign(msg_ref, sk_ref);
12962         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12963         return (uint64_t)ret_conv;
12964 }
12965
12966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
12967         LDKu8slice msg_ref;
12968         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12969         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12970         LDKStr sig_conv = java_to_owned_str(env, sig);
12971         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
12972         *ret_conv = recover_pk(msg_ref, sig_conv);
12973         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12974         return (uint64_t)ret_conv;
12975 }
12976
12977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
12978         LDKu8slice msg_ref;
12979         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
12980         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
12981         LDKStr sig_conv = java_to_owned_str(env, sig);
12982         LDKPublicKey pk_ref;
12983         CHECK((*env)->GetArrayLength(env, pk) == 33);
12984         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
12985         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
12986         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
12987         return ret_val;
12988 }
12989
12990 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12991         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
12992         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
12993         return ret_conv;
12994 }
12995
12996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
12997         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
12998         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
12999         jboolean ret_val = Level_eq(a_conv, b_conv);
13000         return ret_val;
13001 }
13002
13003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13004         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13005         int64_t ret_val = Level_hash(o_conv);
13006         return ret_val;
13007 }
13008
13009 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13010         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13011         return ret_conv;
13012 }
13013
13014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13015         if ((this_ptr & 1) != 0) return;
13016         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13017         FREE((void*)this_ptr);
13018         Logger_free(this_ptr_conv);
13019 }
13020
13021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13022         LDKChannelHandshakeConfig this_obj_conv;
13023         this_obj_conv.inner = (void*)(this_obj & (~1));
13024         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13025         ChannelHandshakeConfig_free(this_obj_conv);
13026 }
13027
13028 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13029         LDKChannelHandshakeConfig this_ptr_conv;
13030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13031         this_ptr_conv.is_owned = false;
13032         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13033         return ret_val;
13034 }
13035
13036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13037         LDKChannelHandshakeConfig this_ptr_conv;
13038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13039         this_ptr_conv.is_owned = false;
13040         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13041 }
13042
13043 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13044         LDKChannelHandshakeConfig this_ptr_conv;
13045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13046         this_ptr_conv.is_owned = false;
13047         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13048         return ret_val;
13049 }
13050
13051 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) {
13052         LDKChannelHandshakeConfig this_ptr_conv;
13053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13054         this_ptr_conv.is_owned = false;
13055         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13056 }
13057
13058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13059         LDKChannelHandshakeConfig this_ptr_conv;
13060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13061         this_ptr_conv.is_owned = false;
13062         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13063         return ret_val;
13064 }
13065
13066 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) {
13067         LDKChannelHandshakeConfig this_ptr_conv;
13068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13069         this_ptr_conv.is_owned = false;
13070         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13071 }
13072
13073 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) {
13074         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13077         uint64_t ret_ref = (uint64_t)ret_var.inner;
13078         if (ret_var.is_owned) {
13079                 ret_ref |= 1;
13080         }
13081         return ret_ref;
13082 }
13083
13084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13085         LDKChannelHandshakeConfig orig_conv;
13086         orig_conv.inner = (void*)(orig & (~1));
13087         orig_conv.is_owned = false;
13088         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13091         uint64_t ret_ref = (uint64_t)ret_var.inner;
13092         if (ret_var.is_owned) {
13093                 ret_ref |= 1;
13094         }
13095         return ret_ref;
13096 }
13097
13098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13099         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13102         uint64_t ret_ref = (uint64_t)ret_var.inner;
13103         if (ret_var.is_owned) {
13104                 ret_ref |= 1;
13105         }
13106         return ret_ref;
13107 }
13108
13109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13110         LDKChannelHandshakeLimits this_obj_conv;
13111         this_obj_conv.inner = (void*)(this_obj & (~1));
13112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13113         ChannelHandshakeLimits_free(this_obj_conv);
13114 }
13115
13116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13117         LDKChannelHandshakeLimits this_ptr_conv;
13118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13119         this_ptr_conv.is_owned = false;
13120         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13121         return ret_val;
13122 }
13123
13124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13125         LDKChannelHandshakeLimits this_ptr_conv;
13126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13127         this_ptr_conv.is_owned = false;
13128         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13129 }
13130
13131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13132         LDKChannelHandshakeLimits this_ptr_conv;
13133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13134         this_ptr_conv.is_owned = false;
13135         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13136         return ret_val;
13137 }
13138
13139 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) {
13140         LDKChannelHandshakeLimits this_ptr_conv;
13141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13142         this_ptr_conv.is_owned = false;
13143         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13144 }
13145
13146 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) {
13147         LDKChannelHandshakeLimits this_ptr_conv;
13148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13149         this_ptr_conv.is_owned = false;
13150         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13151         return ret_val;
13152 }
13153
13154 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) {
13155         LDKChannelHandshakeLimits this_ptr_conv;
13156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13157         this_ptr_conv.is_owned = false;
13158         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13159 }
13160
13161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13162         LDKChannelHandshakeLimits this_ptr_conv;
13163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13164         this_ptr_conv.is_owned = false;
13165         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13166         return ret_val;
13167 }
13168
13169 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) {
13170         LDKChannelHandshakeLimits this_ptr_conv;
13171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13172         this_ptr_conv.is_owned = false;
13173         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13174 }
13175
13176 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13177         LDKChannelHandshakeLimits this_ptr_conv;
13178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13179         this_ptr_conv.is_owned = false;
13180         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13181         return ret_val;
13182 }
13183
13184 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) {
13185         LDKChannelHandshakeLimits this_ptr_conv;
13186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13187         this_ptr_conv.is_owned = false;
13188         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13189 }
13190
13191 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13192         LDKChannelHandshakeLimits this_ptr_conv;
13193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13194         this_ptr_conv.is_owned = false;
13195         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13196         return ret_val;
13197 }
13198
13199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13200         LDKChannelHandshakeLimits this_ptr_conv;
13201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13202         this_ptr_conv.is_owned = false;
13203         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13204 }
13205
13206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
13207         LDKChannelHandshakeLimits this_ptr_conv;
13208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13209         this_ptr_conv.is_owned = false;
13210         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13211         return ret_val;
13212 }
13213
13214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13215         LDKChannelHandshakeLimits this_ptr_conv;
13216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13217         this_ptr_conv.is_owned = false;
13218         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13219 }
13220
13221 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13222         LDKChannelHandshakeLimits this_ptr_conv;
13223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13224         this_ptr_conv.is_owned = false;
13225         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13226         return ret_val;
13227 }
13228
13229 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) {
13230         LDKChannelHandshakeLimits this_ptr_conv;
13231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13232         this_ptr_conv.is_owned = false;
13233         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13234 }
13235
13236 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) {
13237         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);
13238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13240         uint64_t ret_ref = (uint64_t)ret_var.inner;
13241         if (ret_var.is_owned) {
13242                 ret_ref |= 1;
13243         }
13244         return ret_ref;
13245 }
13246
13247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13248         LDKChannelHandshakeLimits orig_conv;
13249         orig_conv.inner = (void*)(orig & (~1));
13250         orig_conv.is_owned = false;
13251         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13254         uint64_t ret_ref = (uint64_t)ret_var.inner;
13255         if (ret_var.is_owned) {
13256                 ret_ref |= 1;
13257         }
13258         return ret_ref;
13259 }
13260
13261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
13262         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13265         uint64_t ret_ref = (uint64_t)ret_var.inner;
13266         if (ret_var.is_owned) {
13267                 ret_ref |= 1;
13268         }
13269         return ret_ref;
13270 }
13271
13272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13273         LDKChannelConfig this_obj_conv;
13274         this_obj_conv.inner = (void*)(this_obj & (~1));
13275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13276         ChannelConfig_free(this_obj_conv);
13277 }
13278
13279 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
13280         LDKChannelConfig this_ptr_conv;
13281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13282         this_ptr_conv.is_owned = false;
13283         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
13284         return ret_val;
13285 }
13286
13287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13288         LDKChannelConfig this_ptr_conv;
13289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13290         this_ptr_conv.is_owned = false;
13291         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
13292 }
13293
13294 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
13295         LDKChannelConfig this_ptr_conv;
13296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13297         this_ptr_conv.is_owned = false;
13298         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13299         return ret_val;
13300 }
13301
13302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
13303         LDKChannelConfig this_ptr_conv;
13304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13305         this_ptr_conv.is_owned = false;
13306         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13307 }
13308
13309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
13310         LDKChannelConfig this_ptr_conv;
13311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13312         this_ptr_conv.is_owned = false;
13313         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13314         return ret_val;
13315 }
13316
13317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13318         LDKChannelConfig this_ptr_conv;
13319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13320         this_ptr_conv.is_owned = false;
13321         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13322 }
13323
13324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13325         LDKChannelConfig this_ptr_conv;
13326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13327         this_ptr_conv.is_owned = false;
13328         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13329         return ret_val;
13330 }
13331
13332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
13333         LDKChannelConfig this_ptr_conv;
13334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13335         this_ptr_conv.is_owned = false;
13336         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13337 }
13338
13339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
13340         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
13341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13343         uint64_t ret_ref = (uint64_t)ret_var.inner;
13344         if (ret_var.is_owned) {
13345                 ret_ref |= 1;
13346         }
13347         return ret_ref;
13348 }
13349
13350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13351         LDKChannelConfig orig_conv;
13352         orig_conv.inner = (void*)(orig & (~1));
13353         orig_conv.is_owned = false;
13354         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13357         uint64_t ret_ref = (uint64_t)ret_var.inner;
13358         if (ret_var.is_owned) {
13359                 ret_ref |= 1;
13360         }
13361         return ret_ref;
13362 }
13363
13364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
13365         LDKChannelConfig ret_var = ChannelConfig_default();
13366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13368         uint64_t ret_ref = (uint64_t)ret_var.inner;
13369         if (ret_var.is_owned) {
13370                 ret_ref |= 1;
13371         }
13372         return ret_ref;
13373 }
13374
13375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
13376         LDKChannelConfig obj_conv;
13377         obj_conv.inner = (void*)(obj & (~1));
13378         obj_conv.is_owned = false;
13379         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13380         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13381         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13382         CVec_u8Z_free(ret_var);
13383         return ret_arr;
13384 }
13385
13386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13387         LDKu8slice ser_ref;
13388         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13389         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13390         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13391         *ret_conv = ChannelConfig_read(ser_ref);
13392         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13393         return (uint64_t)ret_conv;
13394 }
13395
13396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13397         LDKUserConfig this_obj_conv;
13398         this_obj_conv.inner = (void*)(this_obj & (~1));
13399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13400         UserConfig_free(this_obj_conv);
13401 }
13402
13403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
13404         LDKUserConfig this_ptr_conv;
13405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13406         this_ptr_conv.is_owned = false;
13407         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13408         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13409         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13410         uint64_t ret_ref = (uint64_t)ret_var.inner;
13411         if (ret_var.is_owned) {
13412                 ret_ref |= 1;
13413         }
13414         return ret_ref;
13415 }
13416
13417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13418         LDKUserConfig this_ptr_conv;
13419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13420         this_ptr_conv.is_owned = false;
13421         LDKChannelHandshakeConfig val_conv;
13422         val_conv.inner = (void*)(val & (~1));
13423         val_conv.is_owned = (val & 1) || (val == 0);
13424         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13425         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13426 }
13427
13428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
13429         LDKUserConfig this_ptr_conv;
13430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13431         this_ptr_conv.is_owned = false;
13432         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13435         uint64_t ret_ref = (uint64_t)ret_var.inner;
13436         if (ret_var.is_owned) {
13437                 ret_ref |= 1;
13438         }
13439         return ret_ref;
13440 }
13441
13442 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) {
13443         LDKUserConfig this_ptr_conv;
13444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13445         this_ptr_conv.is_owned = false;
13446         LDKChannelHandshakeLimits val_conv;
13447         val_conv.inner = (void*)(val & (~1));
13448         val_conv.is_owned = (val & 1) || (val == 0);
13449         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13450         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13451 }
13452
13453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
13454         LDKUserConfig this_ptr_conv;
13455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13456         this_ptr_conv.is_owned = false;
13457         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13460         uint64_t ret_ref = (uint64_t)ret_var.inner;
13461         if (ret_var.is_owned) {
13462                 ret_ref |= 1;
13463         }
13464         return ret_ref;
13465 }
13466
13467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13468         LDKUserConfig this_ptr_conv;
13469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13470         this_ptr_conv.is_owned = false;
13471         LDKChannelConfig val_conv;
13472         val_conv.inner = (void*)(val & (~1));
13473         val_conv.is_owned = (val & 1) || (val == 0);
13474         val_conv = ChannelConfig_clone(&val_conv);
13475         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13476 }
13477
13478 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) {
13479         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13480         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13481         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13482         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13483         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13484         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13485         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13486         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13487         LDKChannelConfig channel_options_arg_conv;
13488         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13489         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13490         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13491         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
13492         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13493         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13494         uint64_t ret_ref = (uint64_t)ret_var.inner;
13495         if (ret_var.is_owned) {
13496                 ret_ref |= 1;
13497         }
13498         return ret_ref;
13499 }
13500
13501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13502         LDKUserConfig orig_conv;
13503         orig_conv.inner = (void*)(orig & (~1));
13504         orig_conv.is_owned = false;
13505         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13506         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13507         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13508         uint64_t ret_ref = (uint64_t)ret_var.inner;
13509         if (ret_var.is_owned) {
13510                 ret_ref |= 1;
13511         }
13512         return ret_ref;
13513 }
13514
13515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
13516         LDKUserConfig ret_var = UserConfig_default();
13517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13519         uint64_t ret_ref = (uint64_t)ret_var.inner;
13520         if (ret_var.is_owned) {
13521                 ret_ref |= 1;
13522         }
13523         return ret_ref;
13524 }
13525
13526 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13527         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13528         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
13529         return ret_conv;
13530 }
13531
13532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13533         if ((this_ptr & 1) != 0) return;
13534         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
13535         FREE((void*)this_ptr);
13536         Access_free(this_ptr_conv);
13537 }
13538
13539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13540         if ((this_ptr & 1) != 0) return;
13541         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
13542         FREE((void*)this_ptr);
13543         Listen_free(this_ptr_conv);
13544 }
13545
13546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13547         if ((this_ptr & 1) != 0) return;
13548         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
13549         FREE((void*)this_ptr);
13550         Confirm_free(this_ptr_conv);
13551 }
13552
13553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13554         if ((this_ptr & 1) != 0) return;
13555         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
13556         FREE((void*)this_ptr);
13557         Watch_free(this_ptr_conv);
13558 }
13559
13560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13561         if ((this_ptr & 1) != 0) return;
13562         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
13563         FREE((void*)this_ptr);
13564         Filter_free(this_ptr_conv);
13565 }
13566
13567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13568         LDKWatchedOutput this_obj_conv;
13569         this_obj_conv.inner = (void*)(this_obj & (~1));
13570         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13571         WatchedOutput_free(this_obj_conv);
13572 }
13573
13574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
13575         LDKWatchedOutput this_ptr_conv;
13576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13577         this_ptr_conv.is_owned = false;
13578         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
13579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
13580         return ret_arr;
13581 }
13582
13583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13584         LDKWatchedOutput this_ptr_conv;
13585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13586         this_ptr_conv.is_owned = false;
13587         LDKThirtyTwoBytes val_ref;
13588         CHECK((*env)->GetArrayLength(env, val) == 32);
13589         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
13590         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
13591 }
13592
13593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
13594         LDKWatchedOutput this_ptr_conv;
13595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13596         this_ptr_conv.is_owned = false;
13597         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
13598         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13599         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13600         uint64_t ret_ref = (uint64_t)ret_var.inner;
13601         if (ret_var.is_owned) {
13602                 ret_ref |= 1;
13603         }
13604         return ret_ref;
13605 }
13606
13607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13608         LDKWatchedOutput this_ptr_conv;
13609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13610         this_ptr_conv.is_owned = false;
13611         LDKOutPoint val_conv;
13612         val_conv.inner = (void*)(val & (~1));
13613         val_conv.is_owned = (val & 1) || (val == 0);
13614         val_conv = OutPoint_clone(&val_conv);
13615         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
13616 }
13617
13618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
13619         LDKWatchedOutput this_ptr_conv;
13620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13621         this_ptr_conv.is_owned = false;
13622         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
13623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13625         return ret_arr;
13626 }
13627
13628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
13629         LDKWatchedOutput this_ptr_conv;
13630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13631         this_ptr_conv.is_owned = false;
13632         LDKCVec_u8Z val_ref;
13633         val_ref.datalen = (*env)->GetArrayLength(env, val);
13634         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13635         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
13636         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
13637 }
13638
13639 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) {
13640         LDKThirtyTwoBytes block_hash_arg_ref;
13641         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
13642         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
13643         LDKOutPoint outpoint_arg_conv;
13644         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13645         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13646         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13647         LDKCVec_u8Z script_pubkey_arg_ref;
13648         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
13649         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13650         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
13651         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
13652         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13653         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13654         uint64_t ret_ref = (uint64_t)ret_var.inner;
13655         if (ret_var.is_owned) {
13656                 ret_ref |= 1;
13657         }
13658         return ret_ref;
13659 }
13660
13661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13662         LDKWatchedOutput orig_conv;
13663         orig_conv.inner = (void*)(orig & (~1));
13664         orig_conv.is_owned = false;
13665         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
13666         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13667         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13668         uint64_t ret_ref = (uint64_t)ret_var.inner;
13669         if (ret_var.is_owned) {
13670                 ret_ref |= 1;
13671         }
13672         return ret_ref;
13673 }
13674
13675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
13676         LDKWatchedOutput o_conv;
13677         o_conv.inner = (void*)(o & (~1));
13678         o_conv.is_owned = false;
13679         int64_t ret_val = WatchedOutput_hash(&o_conv);
13680         return ret_val;
13681 }
13682
13683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13684         if ((this_ptr & 1) != 0) return;
13685         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
13686         FREE((void*)this_ptr);
13687         BroadcasterInterface_free(this_ptr_conv);
13688 }
13689
13690 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13691         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
13692         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
13693         return ret_conv;
13694 }
13695
13696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13697         if ((this_ptr & 1) != 0) return;
13698         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
13699         FREE((void*)this_ptr);
13700         FeeEstimator_free(this_ptr_conv);
13701 }
13702
13703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13704         LDKChainMonitor this_obj_conv;
13705         this_obj_conv.inner = (void*)(this_obj & (~1));
13706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13707         ChainMonitor_free(this_obj_conv);
13708 }
13709
13710 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) {
13711         LDKFilter *chain_source_conv_ptr = NULL;
13712         if (chain_source != 0) {
13713                 LDKFilter chain_source_conv;
13714                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
13715                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
13716                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13717                         LDKFilter_JCalls_clone(chain_source_conv.this_arg);
13718                 }
13719                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
13720                 *chain_source_conv_ptr = chain_source_conv;
13721         }
13722         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13723         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
13724                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13725                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
13726         }
13727         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13728         if (logger_conv.free == LDKLogger_JCalls_free) {
13729                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13730                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13731         }
13732         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
13733         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
13734                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13735                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
13736         }
13737         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
13738         if (persister_conv.free == LDKPersist_JCalls_free) {
13739                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13740                 LDKPersist_JCalls_clone(persister_conv.this_arg);
13741         }
13742         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
13743         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13744         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13745         uint64_t ret_ref = (uint64_t)ret_var.inner;
13746         if (ret_var.is_owned) {
13747                 ret_ref |= 1;
13748         }
13749         return ret_ref;
13750 }
13751
13752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
13753         LDKChainMonitor this_arg_conv;
13754         this_arg_conv.inner = (void*)(this_arg & (~1));
13755         this_arg_conv.is_owned = false;
13756         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13757         *ret = ChainMonitor_as_Listen(&this_arg_conv);
13758         return (uint64_t)ret;
13759 }
13760
13761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
13762         LDKChainMonitor this_arg_conv;
13763         this_arg_conv.inner = (void*)(this_arg & (~1));
13764         this_arg_conv.is_owned = false;
13765         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13766         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
13767         return (uint64_t)ret;
13768 }
13769
13770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
13771         LDKChainMonitor this_arg_conv;
13772         this_arg_conv.inner = (void*)(this_arg & (~1));
13773         this_arg_conv.is_owned = false;
13774         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
13775         *ret = ChainMonitor_as_Watch(&this_arg_conv);
13776         return (uint64_t)ret;
13777 }
13778
13779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
13780         LDKChainMonitor this_arg_conv;
13781         this_arg_conv.inner = (void*)(this_arg & (~1));
13782         this_arg_conv.is_owned = false;
13783         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13784         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
13785         return (uint64_t)ret;
13786 }
13787
13788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13789         LDKChannelMonitorUpdate this_obj_conv;
13790         this_obj_conv.inner = (void*)(this_obj & (~1));
13791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13792         ChannelMonitorUpdate_free(this_obj_conv);
13793 }
13794
13795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
13796         LDKChannelMonitorUpdate this_ptr_conv;
13797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13798         this_ptr_conv.is_owned = false;
13799         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
13800         return ret_val;
13801 }
13802
13803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13804         LDKChannelMonitorUpdate this_ptr_conv;
13805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13806         this_ptr_conv.is_owned = false;
13807         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
13808 }
13809
13810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13811         LDKChannelMonitorUpdate orig_conv;
13812         orig_conv.inner = (void*)(orig & (~1));
13813         orig_conv.is_owned = false;
13814         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
13815         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13816         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13817         uint64_t ret_ref = (uint64_t)ret_var.inner;
13818         if (ret_var.is_owned) {
13819                 ret_ref |= 1;
13820         }
13821         return ret_ref;
13822 }
13823
13824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
13825         LDKChannelMonitorUpdate obj_conv;
13826         obj_conv.inner = (void*)(obj & (~1));
13827         obj_conv.is_owned = false;
13828         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
13829         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13830         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13831         CVec_u8Z_free(ret_var);
13832         return ret_arr;
13833 }
13834
13835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13836         LDKu8slice ser_ref;
13837         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13838         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13839         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13840         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
13841         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13842         return (uint64_t)ret_conv;
13843 }
13844
13845 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13846         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
13847         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
13848         return ret_conv;
13849 }
13850
13851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13852         LDKMonitorUpdateError this_obj_conv;
13853         this_obj_conv.inner = (void*)(this_obj & (~1));
13854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13855         MonitorUpdateError_free(this_obj_conv);
13856 }
13857
13858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13859         LDKMonitorUpdateError orig_conv;
13860         orig_conv.inner = (void*)(orig & (~1));
13861         orig_conv.is_owned = false;
13862         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
13863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13865         uint64_t ret_ref = (uint64_t)ret_var.inner;
13866         if (ret_var.is_owned) {
13867                 ret_ref |= 1;
13868         }
13869         return ret_ref;
13870 }
13871
13872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13873         if ((this_ptr & 1) != 0) return;
13874         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
13875         FREE((void*)this_ptr);
13876         MonitorEvent_free(this_ptr_conv);
13877 }
13878
13879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13880         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
13881         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13882         *ret_copy = MonitorEvent_clone(orig_conv);
13883         uint64_t ret_ref = (uint64_t)ret_copy;
13884         return ret_ref;
13885 }
13886
13887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13888         LDKHTLCUpdate this_obj_conv;
13889         this_obj_conv.inner = (void*)(this_obj & (~1));
13890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13891         HTLCUpdate_free(this_obj_conv);
13892 }
13893
13894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13895         LDKHTLCUpdate orig_conv;
13896         orig_conv.inner = (void*)(orig & (~1));
13897         orig_conv.is_owned = false;
13898         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
13899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13901         uint64_t ret_ref = (uint64_t)ret_var.inner;
13902         if (ret_var.is_owned) {
13903                 ret_ref |= 1;
13904         }
13905         return ret_ref;
13906 }
13907
13908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
13909         LDKHTLCUpdate obj_conv;
13910         obj_conv.inner = (void*)(obj & (~1));
13911         obj_conv.is_owned = false;
13912         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
13913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13915         CVec_u8Z_free(ret_var);
13916         return ret_arr;
13917 }
13918
13919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
13920         LDKu8slice ser_ref;
13921         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
13922         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
13923         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13924         *ret_conv = HTLCUpdate_read(ser_ref);
13925         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
13926         return (uint64_t)ret_conv;
13927 }
13928
13929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13930         LDKChannelMonitor this_obj_conv;
13931         this_obj_conv.inner = (void*)(this_obj & (~1));
13932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13933         ChannelMonitor_free(this_obj_conv);
13934 }
13935
13936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13937         LDKChannelMonitor orig_conv;
13938         orig_conv.inner = (void*)(orig & (~1));
13939         orig_conv.is_owned = false;
13940         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
13941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13943         uint64_t ret_ref = (uint64_t)ret_var.inner;
13944         if (ret_var.is_owned) {
13945                 ret_ref |= 1;
13946         }
13947         return ret_ref;
13948 }
13949
13950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
13951         LDKChannelMonitor obj_conv;
13952         obj_conv.inner = (void*)(obj & (~1));
13953         obj_conv.is_owned = false;
13954         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
13955         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13956         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13957         CVec_u8Z_free(ret_var);
13958         return ret_arr;
13959 }
13960
13961 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) {
13962         LDKChannelMonitor this_arg_conv;
13963         this_arg_conv.inner = (void*)(this_arg & (~1));
13964         this_arg_conv.is_owned = false;
13965         LDKChannelMonitorUpdate updates_conv;
13966         updates_conv.inner = (void*)(updates & (~1));
13967         updates_conv.is_owned = false;
13968         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13969         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13970         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13971         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13972         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
13973         return (uint64_t)ret_conv;
13974 }
13975
13976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13977         LDKChannelMonitor this_arg_conv;
13978         this_arg_conv.inner = (void*)(this_arg & (~1));
13979         this_arg_conv.is_owned = false;
13980         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
13981         return ret_val;
13982 }
13983
13984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
13985         LDKChannelMonitor this_arg_conv;
13986         this_arg_conv.inner = (void*)(this_arg & (~1));
13987         this_arg_conv.is_owned = false;
13988         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13989         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
13990         return (uint64_t)ret_ref;
13991 }
13992
13993 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
13994         LDKChannelMonitor this_arg_conv;
13995         this_arg_conv.inner = (void*)(this_arg & (~1));
13996         this_arg_conv.is_owned = false;
13997         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
13998         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13999         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14000         for (size_t v = 0; v < ret_var.datalen; v++) {
14001                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14002                 *ret_conv_47_ref = ret_var.data[v];
14003                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14004         }
14005         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14006         FREE(ret_var.data);
14007         return ret_arr;
14008 }
14009
14010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14011         LDKChannelMonitor this_arg_conv;
14012         this_arg_conv.inner = (void*)(this_arg & (~1));
14013         this_arg_conv.is_owned = false;
14014         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14015         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14016 }
14017
14018 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14019         LDKChannelMonitor this_arg_conv;
14020         this_arg_conv.inner = (void*)(this_arg & (~1));
14021         this_arg_conv.is_owned = false;
14022         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14023         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14024         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14025         for (size_t o = 0; o < ret_var.datalen; o++) {
14026                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14027                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14028                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14029                 ret_arr_ptr[o] = ret_conv_14_ref;
14030         }
14031         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14032         FREE(ret_var.data);
14033         return ret_arr;
14034 }
14035
14036 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14037         LDKChannelMonitor this_arg_conv;
14038         this_arg_conv.inner = (void*)(this_arg & (~1));
14039         this_arg_conv.is_owned = false;
14040         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14041         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14042         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14043         for (size_t h = 0; h < ret_var.datalen; h++) {
14044                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14045                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14046                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14047                 ret_arr_ptr[h] = ret_conv_7_ref;
14048         }
14049         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14050         FREE(ret_var.data);
14051         return ret_arr;
14052 }
14053
14054 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) {
14055         LDKChannelMonitor this_arg_conv;
14056         this_arg_conv.inner = (void*)(this_arg & (~1));
14057         this_arg_conv.is_owned = false;
14058         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14059         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14060         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14061         ;
14062         for (size_t i = 0; i < ret_var.datalen; i++) {
14063                 LDKTransaction ret_conv_8_var = ret_var.data[i];
14064                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
14065                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
14066                 Transaction_free(ret_conv_8_var);
14067                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14068         }
14069         FREE(ret_var.data);
14070         return ret_arr;
14071 }
14072
14073 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) {
14074         LDKChannelMonitor this_arg_conv;
14075         this_arg_conv.inner = (void*)(this_arg & (~1));
14076         this_arg_conv.is_owned = false;
14077         unsigned char header_arr[80];
14078         CHECK((*env)->GetArrayLength(env, header) == 80);
14079         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14080         unsigned char (*header_ref)[80] = &header_arr;
14081         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14082         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14083         if (txdata_constr.datalen > 0)
14084                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14085         else
14086                 txdata_constr.data = NULL;
14087         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14088         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14089                 int64_t txdata_conv_24 = txdata_vals[y];
14090                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14091                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14092                 txdata_constr.data[y] = txdata_conv_24_conv;
14093         }
14094         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14095         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14096         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14098                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14099         }
14100         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14101         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14103                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14104         }
14105         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14106         if (logger_conv.free == LDKLogger_JCalls_free) {
14107                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14108                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14109         }
14110         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);
14111         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14112         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14113         for (size_t u = 0; u < ret_var.datalen; u++) {
14114                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14115                 *ret_conv_46_ref = ret_var.data[u];
14116                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14117         }
14118         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14119         FREE(ret_var.data);
14120         return ret_arr;
14121 }
14122
14123 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) {
14124         LDKChannelMonitor this_arg_conv;
14125         this_arg_conv.inner = (void*)(this_arg & (~1));
14126         this_arg_conv.is_owned = false;
14127         unsigned char header_arr[80];
14128         CHECK((*env)->GetArrayLength(env, header) == 80);
14129         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14130         unsigned char (*header_ref)[80] = &header_arr;
14131         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14132         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14134                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14135         }
14136         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14137         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14138                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14139                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14140         }
14141         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14142         if (logger_conv.free == LDKLogger_JCalls_free) {
14143                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14144                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14145         }
14146         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14147 }
14148
14149 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) {
14150         LDKChannelMonitor this_arg_conv;
14151         this_arg_conv.inner = (void*)(this_arg & (~1));
14152         this_arg_conv.is_owned = false;
14153         unsigned char header_arr[80];
14154         CHECK((*env)->GetArrayLength(env, header) == 80);
14155         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14156         unsigned char (*header_ref)[80] = &header_arr;
14157         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14158         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
14159         if (txdata_constr.datalen > 0)
14160                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14161         else
14162                 txdata_constr.data = NULL;
14163         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
14164         for (size_t y = 0; y < txdata_constr.datalen; y++) {
14165                 int64_t txdata_conv_24 = txdata_vals[y];
14166                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
14167                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
14168                 txdata_constr.data[y] = txdata_conv_24_conv;
14169         }
14170         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
14171         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14172         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14173                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14174                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14175         }
14176         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14177         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14178                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14179                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14180         }
14181         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14182         if (logger_conv.free == LDKLogger_JCalls_free) {
14183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14184                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14185         }
14186         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);
14187         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14188         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14189         for (size_t u = 0; u < ret_var.datalen; u++) {
14190                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14191                 *ret_conv_46_ref = ret_var.data[u];
14192                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14193         }
14194         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14195         FREE(ret_var.data);
14196         return ret_arr;
14197 }
14198
14199 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) {
14200         LDKChannelMonitor this_arg_conv;
14201         this_arg_conv.inner = (void*)(this_arg & (~1));
14202         this_arg_conv.is_owned = false;
14203         unsigned char txid_arr[32];
14204         CHECK((*env)->GetArrayLength(env, txid) == 32);
14205         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
14206         unsigned char (*txid_ref)[32] = &txid_arr;
14207         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14208         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14210                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14211         }
14212         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14213         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14214                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14215                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14216         }
14217         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14218         if (logger_conv.free == LDKLogger_JCalls_free) {
14219                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14220                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14221         }
14222         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14223 }
14224
14225 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) {
14226         LDKChannelMonitor this_arg_conv;
14227         this_arg_conv.inner = (void*)(this_arg & (~1));
14228         this_arg_conv.is_owned = false;
14229         unsigned char header_arr[80];
14230         CHECK((*env)->GetArrayLength(env, header) == 80);
14231         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
14232         unsigned char (*header_ref)[80] = &header_arr;
14233         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14234         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14235                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14236                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
14237         }
14238         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14239         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
14240                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14241                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
14242         }
14243         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14244         if (logger_conv.free == LDKLogger_JCalls_free) {
14245                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14246                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14247         }
14248         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14249         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14250         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14251         for (size_t u = 0; u < ret_var.datalen; u++) {
14252                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14253                 *ret_conv_46_ref = ret_var.data[u];
14254                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
14255         }
14256         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14257         FREE(ret_var.data);
14258         return ret_arr;
14259 }
14260
14261 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
14262         LDKChannelMonitor this_arg_conv;
14263         this_arg_conv.inner = (void*)(this_arg & (~1));
14264         this_arg_conv.is_owned = false;
14265         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14266         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
14267         ;
14268         for (size_t i = 0; i < ret_var.datalen; i++) {
14269                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
14270                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
14271                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
14272         }
14273         FREE(ret_var.data);
14274         return ret_arr;
14275 }
14276
14277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14278         if ((this_ptr & 1) != 0) return;
14279         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14280         FREE((void*)this_ptr);
14281         Persist_free(this_ptr_conv);
14282 }
14283
14284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
14285         LDKu8slice ser_ref;
14286         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14287         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14288         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14289         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14290         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14291         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14292         return (uint64_t)ret_conv;
14293 }
14294
14295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14296         LDKOutPoint this_obj_conv;
14297         this_obj_conv.inner = (void*)(this_obj & (~1));
14298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14299         OutPoint_free(this_obj_conv);
14300 }
14301
14302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
14303         LDKOutPoint this_ptr_conv;
14304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14305         this_ptr_conv.is_owned = false;
14306         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
14308         return ret_arr;
14309 }
14310
14311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14312         LDKOutPoint this_ptr_conv;
14313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14314         this_ptr_conv.is_owned = false;
14315         LDKThirtyTwoBytes val_ref;
14316         CHECK((*env)->GetArrayLength(env, val) == 32);
14317         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14318         OutPoint_set_txid(&this_ptr_conv, val_ref);
14319 }
14320
14321 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
14322         LDKOutPoint this_ptr_conv;
14323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14324         this_ptr_conv.is_owned = false;
14325         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14326         return ret_val;
14327 }
14328
14329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14330         LDKOutPoint this_ptr_conv;
14331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14332         this_ptr_conv.is_owned = false;
14333         OutPoint_set_index(&this_ptr_conv, val);
14334 }
14335
14336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
14337         LDKThirtyTwoBytes txid_arg_ref;
14338         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
14339         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
14340         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14343         uint64_t ret_ref = (uint64_t)ret_var.inner;
14344         if (ret_var.is_owned) {
14345                 ret_ref |= 1;
14346         }
14347         return ret_ref;
14348 }
14349
14350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14351         LDKOutPoint orig_conv;
14352         orig_conv.inner = (void*)(orig & (~1));
14353         orig_conv.is_owned = false;
14354         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14357         uint64_t ret_ref = (uint64_t)ret_var.inner;
14358         if (ret_var.is_owned) {
14359                 ret_ref |= 1;
14360         }
14361         return ret_ref;
14362 }
14363
14364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14365         LDKOutPoint a_conv;
14366         a_conv.inner = (void*)(a & (~1));
14367         a_conv.is_owned = false;
14368         LDKOutPoint b_conv;
14369         b_conv.inner = (void*)(b & (~1));
14370         b_conv.is_owned = false;
14371         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14372         return ret_val;
14373 }
14374
14375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
14376         LDKOutPoint o_conv;
14377         o_conv.inner = (void*)(o & (~1));
14378         o_conv.is_owned = false;
14379         int64_t ret_val = OutPoint_hash(&o_conv);
14380         return ret_val;
14381 }
14382
14383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14384         LDKOutPoint this_arg_conv;
14385         this_arg_conv.inner = (void*)(this_arg & (~1));
14386         this_arg_conv.is_owned = false;
14387         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14388         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
14389         return ret_arr;
14390 }
14391
14392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
14393         LDKOutPoint obj_conv;
14394         obj_conv.inner = (void*)(obj & (~1));
14395         obj_conv.is_owned = false;
14396         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14397         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14398         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14399         CVec_u8Z_free(ret_var);
14400         return ret_arr;
14401 }
14402
14403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14404         LDKu8slice ser_ref;
14405         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14406         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14407         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14408         *ret_conv = OutPoint_read(ser_ref);
14409         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14410         return (uint64_t)ret_conv;
14411 }
14412
14413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14414         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14415         this_obj_conv.inner = (void*)(this_obj & (~1));
14416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14417         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14418 }
14419
14420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14421         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14423         this_ptr_conv.is_owned = false;
14424         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14427         uint64_t ret_ref = (uint64_t)ret_var.inner;
14428         if (ret_var.is_owned) {
14429                 ret_ref |= 1;
14430         }
14431         return ret_ref;
14432 }
14433
14434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14435         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14437         this_ptr_conv.is_owned = false;
14438         LDKOutPoint val_conv;
14439         val_conv.inner = (void*)(val & (~1));
14440         val_conv.is_owned = (val & 1) || (val == 0);
14441         val_conv = OutPoint_clone(&val_conv);
14442         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14443 }
14444
14445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
14446         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14448         this_ptr_conv.is_owned = false;
14449         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
14451         return ret_arr;
14452 }
14453
14454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14455         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14457         this_ptr_conv.is_owned = false;
14458         LDKPublicKey val_ref;
14459         CHECK((*env)->GetArrayLength(env, val) == 33);
14460         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14461         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14462 }
14463
14464 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14465         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14467         this_ptr_conv.is_owned = false;
14468         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14469         return ret_val;
14470 }
14471
14472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14473         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14475         this_ptr_conv.is_owned = false;
14476         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14477 }
14478
14479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14480         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14482         this_ptr_conv.is_owned = false;
14483         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14484         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14485 }
14486
14487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14488         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14490         this_ptr_conv.is_owned = false;
14491         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
14493         return ret_arr;
14494 }
14495
14496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14497         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14499         this_ptr_conv.is_owned = false;
14500         LDKPublicKey val_ref;
14501         CHECK((*env)->GetArrayLength(env, val) == 33);
14502         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
14503         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14504 }
14505
14506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14507         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14509         this_ptr_conv.is_owned = false;
14510         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14512         return ret_arr;
14513 }
14514
14515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14516         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14518         this_ptr_conv.is_owned = false;
14519         LDKThirtyTwoBytes val_ref;
14520         CHECK((*env)->GetArrayLength(env, val) == 32);
14521         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14522         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14523 }
14524
14525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14526         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14528         this_ptr_conv.is_owned = false;
14529         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14530         return ret_val;
14531 }
14532
14533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14534         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14536         this_ptr_conv.is_owned = false;
14537         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14538 }
14539
14540 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) {
14541         LDKOutPoint outpoint_arg_conv;
14542         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14543         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14544         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14545         LDKPublicKey per_commitment_point_arg_ref;
14546         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
14547         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
14548         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14549         LDKPublicKey revocation_pubkey_arg_ref;
14550         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
14551         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
14552         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14553         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
14554         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
14555         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);
14556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14558         uint64_t ret_ref = (uint64_t)ret_var.inner;
14559         if (ret_var.is_owned) {
14560                 ret_ref |= 1;
14561         }
14562         return ret_ref;
14563 }
14564
14565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14566         LDKDelayedPaymentOutputDescriptor orig_conv;
14567         orig_conv.inner = (void*)(orig & (~1));
14568         orig_conv.is_owned = false;
14569         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
14570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14572         uint64_t ret_ref = (uint64_t)ret_var.inner;
14573         if (ret_var.is_owned) {
14574                 ret_ref |= 1;
14575         }
14576         return ret_ref;
14577 }
14578
14579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14580         LDKDelayedPaymentOutputDescriptor obj_conv;
14581         obj_conv.inner = (void*)(obj & (~1));
14582         obj_conv.is_owned = false;
14583         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
14584         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14585         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14586         CVec_u8Z_free(ret_var);
14587         return ret_arr;
14588 }
14589
14590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14591         LDKu8slice ser_ref;
14592         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14593         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14594         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14595         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
14596         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14597         return (uint64_t)ret_conv;
14598 }
14599
14600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14601         LDKStaticPaymentOutputDescriptor this_obj_conv;
14602         this_obj_conv.inner = (void*)(this_obj & (~1));
14603         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14604         StaticPaymentOutputDescriptor_free(this_obj_conv);
14605 }
14606
14607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14608         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14610         this_ptr_conv.is_owned = false;
14611         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14614         uint64_t ret_ref = (uint64_t)ret_var.inner;
14615         if (ret_var.is_owned) {
14616                 ret_ref |= 1;
14617         }
14618         return ret_ref;
14619 }
14620
14621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14622         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14624         this_ptr_conv.is_owned = false;
14625         LDKOutPoint val_conv;
14626         val_conv.inner = (void*)(val & (~1));
14627         val_conv.is_owned = (val & 1) || (val == 0);
14628         val_conv = OutPoint_clone(&val_conv);
14629         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14630 }
14631
14632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14633         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14635         this_ptr_conv.is_owned = false;
14636         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14637         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14638 }
14639
14640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14641         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14643         this_ptr_conv.is_owned = false;
14644         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
14646         return ret_arr;
14647 }
14648
14649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14650         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14652         this_ptr_conv.is_owned = false;
14653         LDKThirtyTwoBytes val_ref;
14654         CHECK((*env)->GetArrayLength(env, val) == 32);
14655         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14656         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14657 }
14658
14659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14660         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14662         this_ptr_conv.is_owned = false;
14663         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14664         return ret_val;
14665 }
14666
14667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14668         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14670         this_ptr_conv.is_owned = false;
14671         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14672 }
14673
14674 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) {
14675         LDKOutPoint outpoint_arg_conv;
14676         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14677         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14678         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14679         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14680         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14681         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
14682         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
14683         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
14684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14686         uint64_t ret_ref = (uint64_t)ret_var.inner;
14687         if (ret_var.is_owned) {
14688                 ret_ref |= 1;
14689         }
14690         return ret_ref;
14691 }
14692
14693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14694         LDKStaticPaymentOutputDescriptor orig_conv;
14695         orig_conv.inner = (void*)(orig & (~1));
14696         orig_conv.is_owned = false;
14697         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
14698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14700         uint64_t ret_ref = (uint64_t)ret_var.inner;
14701         if (ret_var.is_owned) {
14702                 ret_ref |= 1;
14703         }
14704         return ret_ref;
14705 }
14706
14707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14708         LDKStaticPaymentOutputDescriptor obj_conv;
14709         obj_conv.inner = (void*)(obj & (~1));
14710         obj_conv.is_owned = false;
14711         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
14712         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14713         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14714         CVec_u8Z_free(ret_var);
14715         return ret_arr;
14716 }
14717
14718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14719         LDKu8slice ser_ref;
14720         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14721         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14722         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14723         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
14724         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14725         return (uint64_t)ret_conv;
14726 }
14727
14728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14729         if ((this_ptr & 1) != 0) return;
14730         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
14731         FREE((void*)this_ptr);
14732         SpendableOutputDescriptor_free(this_ptr_conv);
14733 }
14734
14735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14736         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
14737         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14738         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
14739         uint64_t ret_ref = (uint64_t)ret_copy;
14740         return ret_ref;
14741 }
14742
14743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14744         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
14745         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
14746         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14747         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14748         CVec_u8Z_free(ret_var);
14749         return ret_arr;
14750 }
14751
14752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14753         LDKu8slice ser_ref;
14754         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14755         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14756         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14757         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
14758         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14759         return (uint64_t)ret_conv;
14760 }
14761
14762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14763         if ((this_ptr & 1) != 0) return;
14764         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
14765         FREE((void*)this_ptr);
14766         BaseSign_free(this_ptr_conv);
14767 }
14768
14769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14770         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
14771         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
14772         *ret = Sign_clone(orig_conv);
14773         return (uint64_t)ret;
14774 }
14775
14776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14777         if ((this_ptr & 1) != 0) return;
14778         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
14779         FREE((void*)this_ptr);
14780         Sign_free(this_ptr_conv);
14781 }
14782
14783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14784         if ((this_ptr & 1) != 0) return;
14785         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
14786         FREE((void*)this_ptr);
14787         KeysInterface_free(this_ptr_conv);
14788 }
14789
14790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14791         LDKInMemorySigner this_obj_conv;
14792         this_obj_conv.inner = (void*)(this_obj & (~1));
14793         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14794         InMemorySigner_free(this_obj_conv);
14795 }
14796
14797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14798         LDKInMemorySigner this_ptr_conv;
14799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14800         this_ptr_conv.is_owned = false;
14801         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
14803         return ret_arr;
14804 }
14805
14806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14807         LDKInMemorySigner this_ptr_conv;
14808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14809         this_ptr_conv.is_owned = false;
14810         LDKSecretKey val_ref;
14811         CHECK((*env)->GetArrayLength(env, val) == 32);
14812         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14813         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
14814 }
14815
14816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14817         LDKInMemorySigner this_ptr_conv;
14818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14819         this_ptr_conv.is_owned = false;
14820         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
14822         return ret_arr;
14823 }
14824
14825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14826         LDKInMemorySigner this_ptr_conv;
14827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14828         this_ptr_conv.is_owned = false;
14829         LDKSecretKey val_ref;
14830         CHECK((*env)->GetArrayLength(env, val) == 32);
14831         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14832         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
14833 }
14834
14835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14836         LDKInMemorySigner 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, *InMemorySigner_get_payment_key(&this_ptr_conv));
14841         return ret_arr;
14842 }
14843
14844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14845         LDKInMemorySigner this_ptr_conv;
14846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14847         this_ptr_conv.is_owned = false;
14848         LDKSecretKey val_ref;
14849         CHECK((*env)->GetArrayLength(env, val) == 32);
14850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14851         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
14852 }
14853
14854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14855         LDKInMemorySigner this_ptr_conv;
14856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14857         this_ptr_conv.is_owned = false;
14858         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
14860         return ret_arr;
14861 }
14862
14863 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) {
14864         LDKInMemorySigner this_ptr_conv;
14865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14866         this_ptr_conv.is_owned = false;
14867         LDKSecretKey val_ref;
14868         CHECK((*env)->GetArrayLength(env, val) == 32);
14869         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14870         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
14871 }
14872
14873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
14874         LDKInMemorySigner this_ptr_conv;
14875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14876         this_ptr_conv.is_owned = false;
14877         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14878         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
14879         return ret_arr;
14880 }
14881
14882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14883         LDKInMemorySigner this_ptr_conv;
14884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14885         this_ptr_conv.is_owned = false;
14886         LDKSecretKey val_ref;
14887         CHECK((*env)->GetArrayLength(env, val) == 32);
14888         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
14889         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
14890 }
14891
14892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
14893         LDKInMemorySigner this_ptr_conv;
14894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14895         this_ptr_conv.is_owned = false;
14896         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
14898         return ret_arr;
14899 }
14900
14901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14902         LDKInMemorySigner this_ptr_conv;
14903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14904         this_ptr_conv.is_owned = false;
14905         LDKThirtyTwoBytes val_ref;
14906         CHECK((*env)->GetArrayLength(env, val) == 32);
14907         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14908         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
14909 }
14910
14911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14912         LDKInMemorySigner orig_conv;
14913         orig_conv.inner = (void*)(orig & (~1));
14914         orig_conv.is_owned = false;
14915         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
14916         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14917         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14918         uint64_t ret_ref = (uint64_t)ret_var.inner;
14919         if (ret_var.is_owned) {
14920                 ret_ref |= 1;
14921         }
14922         return ret_ref;
14923 }
14924
14925 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) {
14926         LDKSecretKey funding_key_ref;
14927         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
14928         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
14929         LDKSecretKey revocation_base_key_ref;
14930         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
14931         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
14932         LDKSecretKey payment_key_ref;
14933         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
14934         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
14935         LDKSecretKey delayed_payment_base_key_ref;
14936         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
14937         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
14938         LDKSecretKey htlc_base_key_ref;
14939         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
14940         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
14941         LDKThirtyTwoBytes commitment_seed_ref;
14942         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
14943         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
14944         LDKThirtyTwoBytes channel_keys_id_ref;
14945         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
14946         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
14947         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);
14948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14950         uint64_t ret_ref = (uint64_t)ret_var.inner;
14951         if (ret_var.is_owned) {
14952                 ret_ref |= 1;
14953         }
14954         return ret_ref;
14955 }
14956
14957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
14958         LDKInMemorySigner this_arg_conv;
14959         this_arg_conv.inner = (void*)(this_arg & (~1));
14960         this_arg_conv.is_owned = false;
14961         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
14962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14964         uint64_t ret_ref = (uint64_t)ret_var.inner;
14965         if (ret_var.is_owned) {
14966                 ret_ref |= 1;
14967         }
14968         return ret_ref;
14969 }
14970
14971 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
14972         LDKInMemorySigner this_arg_conv;
14973         this_arg_conv.inner = (void*)(this_arg & (~1));
14974         this_arg_conv.is_owned = false;
14975         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
14976         return ret_val;
14977 }
14978
14979 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
14980         LDKInMemorySigner this_arg_conv;
14981         this_arg_conv.inner = (void*)(this_arg & (~1));
14982         this_arg_conv.is_owned = false;
14983         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
14984         return ret_val;
14985 }
14986
14987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
14988         LDKInMemorySigner this_arg_conv;
14989         this_arg_conv.inner = (void*)(this_arg & (~1));
14990         this_arg_conv.is_owned = false;
14991         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
14992         return ret_val;
14993 }
14994
14995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
14996         LDKInMemorySigner this_arg_conv;
14997         this_arg_conv.inner = (void*)(this_arg & (~1));
14998         this_arg_conv.is_owned = false;
14999         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
15000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15002         uint64_t ret_ref = (uint64_t)ret_var.inner;
15003         if (ret_var.is_owned) {
15004                 ret_ref |= 1;
15005         }
15006         return ret_ref;
15007 }
15008
15009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
15010         LDKInMemorySigner this_arg_conv;
15011         this_arg_conv.inner = (void*)(this_arg & (~1));
15012         this_arg_conv.is_owned = false;
15013         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15016         uint64_t ret_ref = (uint64_t)ret_var.inner;
15017         if (ret_var.is_owned) {
15018                 ret_ref |= 1;
15019         }
15020         return ret_ref;
15021 }
15022
15023 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) {
15024         LDKInMemorySigner this_arg_conv;
15025         this_arg_conv.inner = (void*)(this_arg & (~1));
15026         this_arg_conv.is_owned = false;
15027         LDKTransaction spend_tx_ref;
15028         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15029         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15030         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15031         spend_tx_ref.data_is_owned = true;
15032         LDKStaticPaymentOutputDescriptor descriptor_conv;
15033         descriptor_conv.inner = (void*)(descriptor & (~1));
15034         descriptor_conv.is_owned = false;
15035         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15036         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15037         return (uint64_t)ret_conv;
15038 }
15039
15040 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) {
15041         LDKInMemorySigner this_arg_conv;
15042         this_arg_conv.inner = (void*)(this_arg & (~1));
15043         this_arg_conv.is_owned = false;
15044         LDKTransaction spend_tx_ref;
15045         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
15046         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15047         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
15048         spend_tx_ref.data_is_owned = true;
15049         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15050         descriptor_conv.inner = (void*)(descriptor & (~1));
15051         descriptor_conv.is_owned = false;
15052         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15053         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15054         return (uint64_t)ret_conv;
15055 }
15056
15057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
15058         LDKInMemorySigner this_arg_conv;
15059         this_arg_conv.inner = (void*)(this_arg & (~1));
15060         this_arg_conv.is_owned = false;
15061         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15062         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15063         return (uint64_t)ret;
15064 }
15065
15066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
15067         LDKInMemorySigner this_arg_conv;
15068         this_arg_conv.inner = (void*)(this_arg & (~1));
15069         this_arg_conv.is_owned = false;
15070         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15071         *ret = InMemorySigner_as_Sign(&this_arg_conv);
15072         return (uint64_t)ret;
15073 }
15074
15075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
15076         LDKInMemorySigner obj_conv;
15077         obj_conv.inner = (void*)(obj & (~1));
15078         obj_conv.is_owned = false;
15079         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15080         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15081         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15082         CVec_u8Z_free(ret_var);
15083         return ret_arr;
15084 }
15085
15086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15087         LDKu8slice ser_ref;
15088         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15089         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15090         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15091         *ret_conv = InMemorySigner_read(ser_ref);
15092         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15093         return (uint64_t)ret_conv;
15094 }
15095
15096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15097         LDKKeysManager this_obj_conv;
15098         this_obj_conv.inner = (void*)(this_obj & (~1));
15099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15100         KeysManager_free(this_obj_conv);
15101 }
15102
15103 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) {
15104         unsigned char seed_arr[32];
15105         CHECK((*env)->GetArrayLength(env, seed) == 32);
15106         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
15107         unsigned char (*seed_ref)[32] = &seed_arr;
15108         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15111         uint64_t ret_ref = (uint64_t)ret_var.inner;
15112         if (ret_var.is_owned) {
15113                 ret_ref |= 1;
15114         }
15115         return ret_ref;
15116 }
15117
15118 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) {
15119         LDKKeysManager this_arg_conv;
15120         this_arg_conv.inner = (void*)(this_arg & (~1));
15121         this_arg_conv.is_owned = false;
15122         unsigned char params_arr[32];
15123         CHECK((*env)->GetArrayLength(env, params) == 32);
15124         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
15125         unsigned char (*params_ref)[32] = &params_arr;
15126         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15127         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15128         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15129         uint64_t ret_ref = (uint64_t)ret_var.inner;
15130         if (ret_var.is_owned) {
15131                 ret_ref |= 1;
15132         }
15133         return ret_ref;
15134 }
15135
15136 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) {
15137         LDKKeysManager this_arg_conv;
15138         this_arg_conv.inner = (void*)(this_arg & (~1));
15139         this_arg_conv.is_owned = false;
15140         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15141         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
15142         if (descriptors_constr.datalen > 0)
15143                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15144         else
15145                 descriptors_constr.data = NULL;
15146         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
15147         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15148                 int64_t descriptors_conv_27 = descriptors_vals[b];
15149                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15150                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15151                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15152         }
15153         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
15154         LDKCVec_TxOutZ outputs_constr;
15155         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
15156         if (outputs_constr.datalen > 0)
15157                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15158         else
15159                 outputs_constr.data = NULL;
15160         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
15161         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15162                 int64_t outputs_conv_7 = outputs_vals[h];
15163                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15164                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15165                 outputs_constr.data[h] = outputs_conv_7_conv;
15166         }
15167         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
15168         LDKCVec_u8Z change_destination_script_ref;
15169         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
15170         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15171         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
15172         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15173         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15174         return (uint64_t)ret_conv;
15175 }
15176
15177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
15178         LDKKeysManager this_arg_conv;
15179         this_arg_conv.inner = (void*)(this_arg & (~1));
15180         this_arg_conv.is_owned = false;
15181         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15182         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
15183         return (uint64_t)ret;
15184 }
15185
15186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15187         LDKChannelManager this_obj_conv;
15188         this_obj_conv.inner = (void*)(this_obj & (~1));
15189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15190         ChannelManager_free(this_obj_conv);
15191 }
15192
15193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15194         LDKChainParameters this_obj_conv;
15195         this_obj_conv.inner = (void*)(this_obj & (~1));
15196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15197         ChainParameters_free(this_obj_conv);
15198 }
15199
15200 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
15201         LDKChainParameters this_ptr_conv;
15202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15203         this_ptr_conv.is_owned = false;
15204         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
15205         return ret_conv;
15206 }
15207
15208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
15209         LDKChainParameters this_ptr_conv;
15210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15211         this_ptr_conv.is_owned = false;
15212         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
15213         ChainParameters_set_network(&this_ptr_conv, val_conv);
15214 }
15215
15216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
15217         LDKChainParameters this_ptr_conv;
15218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15219         this_ptr_conv.is_owned = false;
15220         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15223         uint64_t ret_ref = (uint64_t)ret_var.inner;
15224         if (ret_var.is_owned) {
15225                 ret_ref |= 1;
15226         }
15227         return ret_ref;
15228 }
15229
15230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15231         LDKChainParameters this_ptr_conv;
15232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15233         this_ptr_conv.is_owned = false;
15234         LDKBestBlock val_conv;
15235         val_conv.inner = (void*)(val & (~1));
15236         val_conv.is_owned = (val & 1) || (val == 0);
15237         val_conv = BestBlock_clone(&val_conv);
15238         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15239 }
15240
15241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
15242         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
15243         LDKBestBlock best_block_arg_conv;
15244         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15245         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15246         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15247         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15248         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15249         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15250         uint64_t ret_ref = (uint64_t)ret_var.inner;
15251         if (ret_var.is_owned) {
15252                 ret_ref |= 1;
15253         }
15254         return ret_ref;
15255 }
15256
15257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15258         LDKChainParameters orig_conv;
15259         orig_conv.inner = (void*)(orig & (~1));
15260         orig_conv.is_owned = false;
15261         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15264         uint64_t ret_ref = (uint64_t)ret_var.inner;
15265         if (ret_var.is_owned) {
15266                 ret_ref |= 1;
15267         }
15268         return ret_ref;
15269 }
15270
15271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15272         LDKBestBlock this_obj_conv;
15273         this_obj_conv.inner = (void*)(this_obj & (~1));
15274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15275         BestBlock_free(this_obj_conv);
15276 }
15277
15278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15279         LDKBestBlock orig_conv;
15280         orig_conv.inner = (void*)(orig & (~1));
15281         orig_conv.is_owned = false;
15282         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
15283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15285         uint64_t ret_ref = (uint64_t)ret_var.inner;
15286         if (ret_var.is_owned) {
15287                 ret_ref |= 1;
15288         }
15289         return ret_ref;
15290 }
15291
15292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
15293         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
15294         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
15295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15297         uint64_t ret_ref = (uint64_t)ret_var.inner;
15298         if (ret_var.is_owned) {
15299                 ret_ref |= 1;
15300         }
15301         return ret_ref;
15302 }
15303
15304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
15305         LDKThirtyTwoBytes block_hash_ref;
15306         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
15307         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
15308         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
15309         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15310         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15311         uint64_t ret_ref = (uint64_t)ret_var.inner;
15312         if (ret_var.is_owned) {
15313                 ret_ref |= 1;
15314         }
15315         return ret_ref;
15316 }
15317
15318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
15319         LDKBestBlock this_arg_conv;
15320         this_arg_conv.inner = (void*)(this_arg & (~1));
15321         this_arg_conv.is_owned = false;
15322         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15323         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
15324         return ret_arr;
15325 }
15326
15327 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
15328         LDKBestBlock this_arg_conv;
15329         this_arg_conv.inner = (void*)(this_arg & (~1));
15330         this_arg_conv.is_owned = false;
15331         int32_t ret_val = BestBlock_height(&this_arg_conv);
15332         return ret_val;
15333 }
15334
15335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15336         LDKChannelDetails this_obj_conv;
15337         this_obj_conv.inner = (void*)(this_obj & (~1));
15338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15339         ChannelDetails_free(this_obj_conv);
15340 }
15341
15342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15343         LDKChannelDetails this_ptr_conv;
15344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15345         this_ptr_conv.is_owned = false;
15346         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15347         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
15348         return ret_arr;
15349 }
15350
15351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15352         LDKChannelDetails this_ptr_conv;
15353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15354         this_ptr_conv.is_owned = false;
15355         LDKThirtyTwoBytes val_ref;
15356         CHECK((*env)->GetArrayLength(env, val) == 32);
15357         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15358         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15359 }
15360
15361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
15362         LDKChannelDetails this_ptr_conv;
15363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15364         this_ptr_conv.is_owned = false;
15365         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15368         uint64_t ret_ref = (uint64_t)ret_var.inner;
15369         if (ret_var.is_owned) {
15370                 ret_ref |= 1;
15371         }
15372         return ret_ref;
15373 }
15374
15375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15376         LDKChannelDetails this_ptr_conv;
15377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15378         this_ptr_conv.is_owned = false;
15379         LDKOutPoint val_conv;
15380         val_conv.inner = (void*)(val & (~1));
15381         val_conv.is_owned = (val & 1) || (val == 0);
15382         val_conv = OutPoint_clone(&val_conv);
15383         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15384 }
15385
15386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15387         LDKChannelDetails this_ptr_conv;
15388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15389         this_ptr_conv.is_owned = false;
15390         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15391         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15392         uint64_t ret_ref = (uint64_t)ret_copy;
15393         return ret_ref;
15394 }
15395
15396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15397         LDKChannelDetails this_ptr_conv;
15398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15399         this_ptr_conv.is_owned = false;
15400         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15401         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15402 }
15403
15404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15405         LDKChannelDetails this_ptr_conv;
15406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15407         this_ptr_conv.is_owned = false;
15408         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15409         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form);
15410         return ret_arr;
15411 }
15412
15413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15414         LDKChannelDetails this_ptr_conv;
15415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15416         this_ptr_conv.is_owned = false;
15417         LDKPublicKey val_ref;
15418         CHECK((*env)->GetArrayLength(env, val) == 33);
15419         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15420         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
15421 }
15422
15423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
15424         LDKChannelDetails this_ptr_conv;
15425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15426         this_ptr_conv.is_owned = false;
15427         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
15428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15430         uint64_t ret_ref = (uint64_t)ret_var.inner;
15431         if (ret_var.is_owned) {
15432                 ret_ref |= 1;
15433         }
15434         return ret_ref;
15435 }
15436
15437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15438         LDKChannelDetails this_ptr_conv;
15439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15440         this_ptr_conv.is_owned = false;
15441         LDKInitFeatures val_conv;
15442         val_conv.inner = (void*)(val & (~1));
15443         val_conv.is_owned = (val & 1) || (val == 0);
15444         val_conv = InitFeatures_clone(&val_conv);
15445         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
15446 }
15447
15448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15449         LDKChannelDetails this_ptr_conv;
15450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15451         this_ptr_conv.is_owned = false;
15452         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15453         return ret_val;
15454 }
15455
15456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15457         LDKChannelDetails this_ptr_conv;
15458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15459         this_ptr_conv.is_owned = false;
15460         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15461 }
15462
15463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15464         LDKChannelDetails this_ptr_conv;
15465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15466         this_ptr_conv.is_owned = false;
15467         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15468         return ret_val;
15469 }
15470
15471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15472         LDKChannelDetails this_ptr_conv;
15473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15474         this_ptr_conv.is_owned = false;
15475         ChannelDetails_set_user_id(&this_ptr_conv, val);
15476 }
15477
15478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15479         LDKChannelDetails this_ptr_conv;
15480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15481         this_ptr_conv.is_owned = false;
15482         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15483         return ret_val;
15484 }
15485
15486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15487         LDKChannelDetails this_ptr_conv;
15488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15489         this_ptr_conv.is_owned = false;
15490         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15491 }
15492
15493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
15494         LDKChannelDetails this_ptr_conv;
15495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15496         this_ptr_conv.is_owned = false;
15497         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
15498         return ret_val;
15499 }
15500
15501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15502         LDKChannelDetails this_ptr_conv;
15503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15504         this_ptr_conv.is_owned = false;
15505         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
15506 }
15507
15508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
15509         LDKChannelDetails this_ptr_conv;
15510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15511         this_ptr_conv.is_owned = false;
15512         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
15513         return ret_val;
15514 }
15515
15516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15517         LDKChannelDetails this_ptr_conv;
15518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15519         this_ptr_conv.is_owned = false;
15520         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
15521 }
15522
15523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
15524         LDKChannelDetails this_ptr_conv;
15525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15526         this_ptr_conv.is_owned = false;
15527         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
15528         return ret_val;
15529 }
15530
15531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15532         LDKChannelDetails this_ptr_conv;
15533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15534         this_ptr_conv.is_owned = false;
15535         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
15536 }
15537
15538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
15539         LDKChannelDetails this_ptr_conv;
15540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15541         this_ptr_conv.is_owned = false;
15542         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
15543         return ret_val;
15544 }
15545
15546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15547         LDKChannelDetails this_ptr_conv;
15548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15549         this_ptr_conv.is_owned = false;
15550         ChannelDetails_set_is_usable(&this_ptr_conv, val);
15551 }
15552
15553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
15554         LDKChannelDetails this_ptr_conv;
15555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15556         this_ptr_conv.is_owned = false;
15557         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
15558         return ret_val;
15559 }
15560
15561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
15562         LDKChannelDetails this_ptr_conv;
15563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15564         this_ptr_conv.is_owned = false;
15565         ChannelDetails_set_is_public(&this_ptr_conv, val);
15566 }
15567
15568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15569         LDKChannelDetails orig_conv;
15570         orig_conv.inner = (void*)(orig & (~1));
15571         orig_conv.is_owned = false;
15572         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
15573         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15574         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15575         uint64_t ret_ref = (uint64_t)ret_var.inner;
15576         if (ret_var.is_owned) {
15577                 ret_ref |= 1;
15578         }
15579         return ret_ref;
15580 }
15581
15582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15583         if ((this_ptr & 1) != 0) return;
15584         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
15585         FREE((void*)this_ptr);
15586         PaymentSendFailure_free(this_ptr_conv);
15587 }
15588
15589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15590         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
15591         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15592         *ret_copy = PaymentSendFailure_clone(orig_conv);
15593         uint64_t ret_ref = (uint64_t)ret_copy;
15594         return ret_ref;
15595 }
15596
15597 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) {
15598         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
15599         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
15600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15601                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
15602         }
15603         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
15604         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
15605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15606                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
15607         }
15608         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
15609         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15610                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15611                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
15612         }
15613         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15614         if (logger_conv.free == LDKLogger_JCalls_free) {
15615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15616                 LDKLogger_JCalls_clone(logger_conv.this_arg);
15617         }
15618         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
15619         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
15620                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15621                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
15622         }
15623         LDKUserConfig config_conv;
15624         config_conv.inner = (void*)(config & (~1));
15625         config_conv.is_owned = (config & 1) || (config == 0);
15626         config_conv = UserConfig_clone(&config_conv);
15627         LDKChainParameters params_conv;
15628         params_conv.inner = (void*)(params & (~1));
15629         params_conv.is_owned = (params & 1) || (params == 0);
15630         params_conv = ChainParameters_clone(&params_conv);
15631         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
15632         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15633         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15634         uint64_t ret_ref = (uint64_t)ret_var.inner;
15635         if (ret_var.is_owned) {
15636                 ret_ref |= 1;
15637         }
15638         return ret_ref;
15639 }
15640
15641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
15642         LDKChannelManager this_arg_conv;
15643         this_arg_conv.inner = (void*)(this_arg & (~1));
15644         this_arg_conv.is_owned = false;
15645         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
15646         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15647         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15648         uint64_t ret_ref = (uint64_t)ret_var.inner;
15649         if (ret_var.is_owned) {
15650                 ret_ref |= 1;
15651         }
15652         return ret_ref;
15653 }
15654
15655 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) {
15656         LDKChannelManager this_arg_conv;
15657         this_arg_conv.inner = (void*)(this_arg & (~1));
15658         this_arg_conv.is_owned = false;
15659         LDKPublicKey their_network_key_ref;
15660         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
15661         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
15662         LDKUserConfig override_config_conv;
15663         override_config_conv.inner = (void*)(override_config & (~1));
15664         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
15665         override_config_conv = UserConfig_clone(&override_config_conv);
15666         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15667         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
15668         return (uint64_t)ret_conv;
15669 }
15670
15671 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15672         LDKChannelManager this_arg_conv;
15673         this_arg_conv.inner = (void*)(this_arg & (~1));
15674         this_arg_conv.is_owned = false;
15675         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
15676         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15677         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15678         for (size_t q = 0; q < ret_var.datalen; q++) {
15679                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15680                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15681                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15682                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15683                 if (ret_conv_16_var.is_owned) {
15684                         ret_conv_16_ref |= 1;
15685                 }
15686                 ret_arr_ptr[q] = ret_conv_16_ref;
15687         }
15688         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15689         FREE(ret_var.data);
15690         return ret_arr;
15691 }
15692
15693 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15694         LDKChannelManager this_arg_conv;
15695         this_arg_conv.inner = (void*)(this_arg & (~1));
15696         this_arg_conv.is_owned = false;
15697         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
15698         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15699         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15700         for (size_t q = 0; q < ret_var.datalen; q++) {
15701                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15702                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15703                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15704                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15705                 if (ret_conv_16_var.is_owned) {
15706                         ret_conv_16_ref |= 1;
15707                 }
15708                 ret_arr_ptr[q] = ret_conv_16_ref;
15709         }
15710         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15711         FREE(ret_var.data);
15712         return ret_arr;
15713 }
15714
15715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
15716         LDKChannelManager this_arg_conv;
15717         this_arg_conv.inner = (void*)(this_arg & (~1));
15718         this_arg_conv.is_owned = false;
15719         unsigned char channel_id_arr[32];
15720         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15721         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
15722         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15723         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15724         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
15725         return (uint64_t)ret_conv;
15726 }
15727
15728 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) {
15729         LDKChannelManager this_arg_conv;
15730         this_arg_conv.inner = (void*)(this_arg & (~1));
15731         this_arg_conv.is_owned = false;
15732         unsigned char channel_id_arr[32];
15733         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
15734         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
15735         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15736         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15737         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
15738         return (uint64_t)ret_conv;
15739 }
15740
15741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
15742         LDKChannelManager this_arg_conv;
15743         this_arg_conv.inner = (void*)(this_arg & (~1));
15744         this_arg_conv.is_owned = false;
15745         ChannelManager_force_close_all_channels(&this_arg_conv);
15746 }
15747
15748 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) {
15749         LDKChannelManager this_arg_conv;
15750         this_arg_conv.inner = (void*)(this_arg & (~1));
15751         this_arg_conv.is_owned = false;
15752         LDKRoute route_conv;
15753         route_conv.inner = (void*)(route & (~1));
15754         route_conv.is_owned = false;
15755         LDKThirtyTwoBytes payment_hash_ref;
15756         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15757         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15758         LDKThirtyTwoBytes payment_secret_ref;
15759         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15760         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15761         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15762         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
15763         return (uint64_t)ret_conv;
15764 }
15765
15766 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) {
15767         LDKChannelManager this_arg_conv;
15768         this_arg_conv.inner = (void*)(this_arg & (~1));
15769         this_arg_conv.is_owned = false;
15770         unsigned char temporary_channel_id_arr[32];
15771         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
15772         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
15773         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
15774         LDKTransaction funding_transaction_ref;
15775         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
15776         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
15777         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
15778         funding_transaction_ref.data_is_owned = true;
15779         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15780         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
15781         return (uint64_t)ret_conv;
15782 }
15783
15784 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) {
15785         LDKChannelManager this_arg_conv;
15786         this_arg_conv.inner = (void*)(this_arg & (~1));
15787         this_arg_conv.is_owned = false;
15788         LDKThreeBytes rgb_ref;
15789         CHECK((*env)->GetArrayLength(env, rgb) == 3);
15790         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
15791         LDKThirtyTwoBytes alias_ref;
15792         CHECK((*env)->GetArrayLength(env, alias) == 32);
15793         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
15794         LDKCVec_NetAddressZ addresses_constr;
15795         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
15796         if (addresses_constr.datalen > 0)
15797                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15798         else
15799                 addresses_constr.data = NULL;
15800         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
15801         for (size_t m = 0; m < addresses_constr.datalen; m++) {
15802                 int64_t addresses_conv_12 = addresses_vals[m];
15803                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
15804                 addresses_constr.data[m] = addresses_conv_12_conv;
15805         }
15806         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
15807         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
15808 }
15809
15810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
15811         LDKChannelManager this_arg_conv;
15812         this_arg_conv.inner = (void*)(this_arg & (~1));
15813         this_arg_conv.is_owned = false;
15814         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
15815 }
15816
15817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
15818         LDKChannelManager this_arg_conv;
15819         this_arg_conv.inner = (void*)(this_arg & (~1));
15820         this_arg_conv.is_owned = false;
15821         ChannelManager_timer_tick_occurred(&this_arg_conv);
15822 }
15823
15824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
15825         LDKChannelManager this_arg_conv;
15826         this_arg_conv.inner = (void*)(this_arg & (~1));
15827         this_arg_conv.is_owned = false;
15828         unsigned char payment_hash_arr[32];
15829         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15830         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
15831         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15832         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
15833         return ret_val;
15834 }
15835
15836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
15837         LDKChannelManager this_arg_conv;
15838         this_arg_conv.inner = (void*)(this_arg & (~1));
15839         this_arg_conv.is_owned = false;
15840         LDKThirtyTwoBytes payment_preimage_ref;
15841         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15842         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15843         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
15844         return ret_val;
15845 }
15846
15847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15848         LDKChannelManager this_arg_conv;
15849         this_arg_conv.inner = (void*)(this_arg & (~1));
15850         this_arg_conv.is_owned = false;
15851         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15852         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
15853         return ret_arr;
15854 }
15855
15856 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) {
15857         LDKChannelManager this_arg_conv;
15858         this_arg_conv.inner = (void*)(this_arg & (~1));
15859         this_arg_conv.is_owned = false;
15860         LDKOutPoint funding_txo_conv;
15861         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15862         funding_txo_conv.is_owned = false;
15863         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
15864 }
15865
15866 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) {
15867         LDKChannelManager this_arg_conv;
15868         this_arg_conv.inner = (void*)(this_arg & (~1));
15869         this_arg_conv.is_owned = false;
15870         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15871         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15872         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
15873         return (uint64_t)ret_ref;
15874 }
15875
15876 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) {
15877         LDKChannelManager this_arg_conv;
15878         this_arg_conv.inner = (void*)(this_arg & (~1));
15879         this_arg_conv.is_owned = false;
15880         LDKThirtyTwoBytes payment_hash_ref;
15881         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15882         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15883         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15884         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15885         *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);
15886         return (uint64_t)ret_conv;
15887 }
15888
15889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15890         LDKChannelManager this_arg_conv;
15891         this_arg_conv.inner = (void*)(this_arg & (~1));
15892         this_arg_conv.is_owned = false;
15893         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15894         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
15895         return (uint64_t)ret;
15896 }
15897
15898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15899         LDKChannelManager this_arg_conv;
15900         this_arg_conv.inner = (void*)(this_arg & (~1));
15901         this_arg_conv.is_owned = false;
15902         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15903         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
15904         return (uint64_t)ret;
15905 }
15906
15907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
15908         LDKChannelManager this_arg_conv;
15909         this_arg_conv.inner = (void*)(this_arg & (~1));
15910         this_arg_conv.is_owned = false;
15911         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
15912         *ret = ChannelManager_as_Listen(&this_arg_conv);
15913         return (uint64_t)ret;
15914 }
15915
15916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
15917         LDKChannelManager this_arg_conv;
15918         this_arg_conv.inner = (void*)(this_arg & (~1));
15919         this_arg_conv.is_owned = false;
15920         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15921         *ret = ChannelManager_as_Confirm(&this_arg_conv);
15922         return (uint64_t)ret;
15923 }
15924
15925 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) {
15926         LDKChannelManager this_arg_conv;
15927         this_arg_conv.inner = (void*)(this_arg & (~1));
15928         this_arg_conv.is_owned = false;
15929         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
15930         return ret_val;
15931 }
15932
15933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
15934         LDKChannelManager this_arg_conv;
15935         this_arg_conv.inner = (void*)(this_arg & (~1));
15936         this_arg_conv.is_owned = false;
15937         ChannelManager_await_persistable_update(&this_arg_conv);
15938 }
15939
15940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
15941         LDKChannelManager this_arg_conv;
15942         this_arg_conv.inner = (void*)(this_arg & (~1));
15943         this_arg_conv.is_owned = false;
15944         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
15945         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
15946         return (uint64_t)ret;
15947 }
15948
15949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
15950         LDKChannelManager obj_conv;
15951         obj_conv.inner = (void*)(obj & (~1));
15952         obj_conv.is_owned = false;
15953         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
15954         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15955         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15956         CVec_u8Z_free(ret_var);
15957         return ret_arr;
15958 }
15959
15960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15961         LDKChannelManagerReadArgs this_obj_conv;
15962         this_obj_conv.inner = (void*)(this_obj & (~1));
15963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15964         ChannelManagerReadArgs_free(this_obj_conv);
15965 }
15966
15967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
15968         LDKChannelManagerReadArgs this_ptr_conv;
15969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15970         this_ptr_conv.is_owned = false;
15971         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
15972         return ret_ret;
15973 }
15974
15975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15976         LDKChannelManagerReadArgs this_ptr_conv;
15977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15978         this_ptr_conv.is_owned = false;
15979         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
15980         if (val_conv.free == LDKKeysInterface_JCalls_free) {
15981                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15982                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
15983         }
15984         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
15985 }
15986
15987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
15988         LDKChannelManagerReadArgs this_ptr_conv;
15989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15990         this_ptr_conv.is_owned = false;
15991         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
15992         return ret_ret;
15993 }
15994
15995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15996         LDKChannelManagerReadArgs this_ptr_conv;
15997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15998         this_ptr_conv.is_owned = false;
15999         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16000         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
16001                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16002                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
16003         }
16004         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16005 }
16006
16007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
16008         LDKChannelManagerReadArgs this_ptr_conv;
16009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16010         this_ptr_conv.is_owned = false;
16011         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16012         return ret_ret;
16013 }
16014
16015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16016         LDKChannelManagerReadArgs this_ptr_conv;
16017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16018         this_ptr_conv.is_owned = false;
16019         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16020         if (val_conv.free == LDKWatch_JCalls_free) {
16021                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16022                 LDKWatch_JCalls_clone(val_conv.this_arg);
16023         }
16024         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16025 }
16026
16027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
16028         LDKChannelManagerReadArgs this_ptr_conv;
16029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16030         this_ptr_conv.is_owned = false;
16031         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16032         return ret_ret;
16033 }
16034
16035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16036         LDKChannelManagerReadArgs this_ptr_conv;
16037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16038         this_ptr_conv.is_owned = false;
16039         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16040         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
16041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16042                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
16043         }
16044         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16045 }
16046
16047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
16048         LDKChannelManagerReadArgs this_ptr_conv;
16049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16050         this_ptr_conv.is_owned = false;
16051         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16052         return ret_ret;
16053 }
16054
16055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16056         LDKChannelManagerReadArgs this_ptr_conv;
16057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16058         this_ptr_conv.is_owned = false;
16059         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16060         if (val_conv.free == LDKLogger_JCalls_free) {
16061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16062                 LDKLogger_JCalls_clone(val_conv.this_arg);
16063         }
16064         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16065 }
16066
16067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
16068         LDKChannelManagerReadArgs this_ptr_conv;
16069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16070         this_ptr_conv.is_owned = false;
16071         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16074         uint64_t ret_ref = (uint64_t)ret_var.inner;
16075         if (ret_var.is_owned) {
16076                 ret_ref |= 1;
16077         }
16078         return ret_ref;
16079 }
16080
16081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16082         LDKChannelManagerReadArgs this_ptr_conv;
16083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16084         this_ptr_conv.is_owned = false;
16085         LDKUserConfig val_conv;
16086         val_conv.inner = (void*)(val & (~1));
16087         val_conv.is_owned = (val & 1) || (val == 0);
16088         val_conv = UserConfig_clone(&val_conv);
16089         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16090 }
16091
16092 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) {
16093         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16094         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16095                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16096                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
16097         }
16098         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16099         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
16100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16101                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
16102         }
16103         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16104         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16105                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16106                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
16107         }
16108         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16109         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16110                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16111                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
16112         }
16113         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16114         if (logger_conv.free == LDKLogger_JCalls_free) {
16115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16116                 LDKLogger_JCalls_clone(logger_conv.this_arg);
16117         }
16118         LDKUserConfig default_config_conv;
16119         default_config_conv.inner = (void*)(default_config & (~1));
16120         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16121         default_config_conv = UserConfig_clone(&default_config_conv);
16122         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16123         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
16124         if (channel_monitors_constr.datalen > 0)
16125                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16126         else
16127                 channel_monitors_constr.data = NULL;
16128         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
16129         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16130                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
16131                 LDKChannelMonitor channel_monitors_conv_16_conv;
16132                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16133                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16134                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16135         }
16136         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
16137         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);
16138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16140         uint64_t ret_ref = (uint64_t)ret_var.inner;
16141         if (ret_var.is_owned) {
16142                 ret_ref |= 1;
16143         }
16144         return ret_ref;
16145 }
16146
16147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
16148         LDKu8slice ser_ref;
16149         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16150         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16151         LDKChannelManagerReadArgs arg_conv;
16152         arg_conv.inner = (void*)(arg & (~1));
16153         arg_conv.is_owned = (arg & 1) || (arg == 0);
16154         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16155         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16156         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16157         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16158         return (uint64_t)ret_conv;
16159 }
16160
16161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16162         LDKDecodeError this_obj_conv;
16163         this_obj_conv.inner = (void*)(this_obj & (~1));
16164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16165         DecodeError_free(this_obj_conv);
16166 }
16167
16168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16169         LDKDecodeError orig_conv;
16170         orig_conv.inner = (void*)(orig & (~1));
16171         orig_conv.is_owned = false;
16172         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16175         uint64_t ret_ref = (uint64_t)ret_var.inner;
16176         if (ret_var.is_owned) {
16177                 ret_ref |= 1;
16178         }
16179         return ret_ref;
16180 }
16181
16182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16183         LDKInit this_obj_conv;
16184         this_obj_conv.inner = (void*)(this_obj & (~1));
16185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16186         Init_free(this_obj_conv);
16187 }
16188
16189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16190         LDKInit this_ptr_conv;
16191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16192         this_ptr_conv.is_owned = false;
16193         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16194         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16195         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16196         uint64_t ret_ref = (uint64_t)ret_var.inner;
16197         if (ret_var.is_owned) {
16198                 ret_ref |= 1;
16199         }
16200         return ret_ref;
16201 }
16202
16203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16204         LDKInit this_ptr_conv;
16205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16206         this_ptr_conv.is_owned = false;
16207         LDKInitFeatures val_conv;
16208         val_conv.inner = (void*)(val & (~1));
16209         val_conv.is_owned = (val & 1) || (val == 0);
16210         val_conv = InitFeatures_clone(&val_conv);
16211         Init_set_features(&this_ptr_conv, val_conv);
16212 }
16213
16214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
16215         LDKInitFeatures features_arg_conv;
16216         features_arg_conv.inner = (void*)(features_arg & (~1));
16217         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16218         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16219         LDKInit ret_var = Init_new(features_arg_conv);
16220         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16221         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16222         uint64_t ret_ref = (uint64_t)ret_var.inner;
16223         if (ret_var.is_owned) {
16224                 ret_ref |= 1;
16225         }
16226         return ret_ref;
16227 }
16228
16229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16230         LDKInit orig_conv;
16231         orig_conv.inner = (void*)(orig & (~1));
16232         orig_conv.is_owned = false;
16233         LDKInit ret_var = Init_clone(&orig_conv);
16234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16236         uint64_t ret_ref = (uint64_t)ret_var.inner;
16237         if (ret_var.is_owned) {
16238                 ret_ref |= 1;
16239         }
16240         return ret_ref;
16241 }
16242
16243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16244         LDKErrorMessage this_obj_conv;
16245         this_obj_conv.inner = (void*)(this_obj & (~1));
16246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16247         ErrorMessage_free(this_obj_conv);
16248 }
16249
16250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16251         LDKErrorMessage this_ptr_conv;
16252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16253         this_ptr_conv.is_owned = false;
16254         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
16256         return ret_arr;
16257 }
16258
16259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16260         LDKErrorMessage this_ptr_conv;
16261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16262         this_ptr_conv.is_owned = false;
16263         LDKThirtyTwoBytes val_ref;
16264         CHECK((*env)->GetArrayLength(env, val) == 32);
16265         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16266         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16267 }
16268
16269 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
16270         LDKErrorMessage this_ptr_conv;
16271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16272         this_ptr_conv.is_owned = false;
16273         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16274         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16275         return ret_conv;
16276 }
16277
16278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
16279         LDKErrorMessage this_ptr_conv;
16280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16281         this_ptr_conv.is_owned = false;
16282         LDKStr val_conv = java_to_owned_str(env, val);
16283         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16284 }
16285
16286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
16287         LDKThirtyTwoBytes channel_id_arg_ref;
16288         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16289         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16290         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
16291         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16294         uint64_t ret_ref = (uint64_t)ret_var.inner;
16295         if (ret_var.is_owned) {
16296                 ret_ref |= 1;
16297         }
16298         return ret_ref;
16299 }
16300
16301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16302         LDKErrorMessage orig_conv;
16303         orig_conv.inner = (void*)(orig & (~1));
16304         orig_conv.is_owned = false;
16305         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16308         uint64_t ret_ref = (uint64_t)ret_var.inner;
16309         if (ret_var.is_owned) {
16310                 ret_ref |= 1;
16311         }
16312         return ret_ref;
16313 }
16314
16315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16316         LDKPing this_obj_conv;
16317         this_obj_conv.inner = (void*)(this_obj & (~1));
16318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16319         Ping_free(this_obj_conv);
16320 }
16321
16322 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16323         LDKPing this_ptr_conv;
16324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16325         this_ptr_conv.is_owned = false;
16326         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16327         return ret_val;
16328 }
16329
16330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16331         LDKPing this_ptr_conv;
16332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16333         this_ptr_conv.is_owned = false;
16334         Ping_set_ponglen(&this_ptr_conv, val);
16335 }
16336
16337 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16338         LDKPing this_ptr_conv;
16339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16340         this_ptr_conv.is_owned = false;
16341         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16342         return ret_val;
16343 }
16344
16345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16346         LDKPing this_ptr_conv;
16347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16348         this_ptr_conv.is_owned = false;
16349         Ping_set_byteslen(&this_ptr_conv, val);
16350 }
16351
16352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
16353         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16356         uint64_t ret_ref = (uint64_t)ret_var.inner;
16357         if (ret_var.is_owned) {
16358                 ret_ref |= 1;
16359         }
16360         return ret_ref;
16361 }
16362
16363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16364         LDKPing orig_conv;
16365         orig_conv.inner = (void*)(orig & (~1));
16366         orig_conv.is_owned = false;
16367         LDKPing ret_var = Ping_clone(&orig_conv);
16368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16370         uint64_t ret_ref = (uint64_t)ret_var.inner;
16371         if (ret_var.is_owned) {
16372                 ret_ref |= 1;
16373         }
16374         return ret_ref;
16375 }
16376
16377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16378         LDKPong this_obj_conv;
16379         this_obj_conv.inner = (void*)(this_obj & (~1));
16380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16381         Pong_free(this_obj_conv);
16382 }
16383
16384 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
16385         LDKPong this_ptr_conv;
16386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16387         this_ptr_conv.is_owned = false;
16388         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16389         return ret_val;
16390 }
16391
16392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16393         LDKPong this_ptr_conv;
16394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16395         this_ptr_conv.is_owned = false;
16396         Pong_set_byteslen(&this_ptr_conv, val);
16397 }
16398
16399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
16400         LDKPong ret_var = Pong_new(byteslen_arg);
16401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16403         uint64_t ret_ref = (uint64_t)ret_var.inner;
16404         if (ret_var.is_owned) {
16405                 ret_ref |= 1;
16406         }
16407         return ret_ref;
16408 }
16409
16410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16411         LDKPong orig_conv;
16412         orig_conv.inner = (void*)(orig & (~1));
16413         orig_conv.is_owned = false;
16414         LDKPong ret_var = Pong_clone(&orig_conv);
16415         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16416         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16417         uint64_t ret_ref = (uint64_t)ret_var.inner;
16418         if (ret_var.is_owned) {
16419                 ret_ref |= 1;
16420         }
16421         return ret_ref;
16422 }
16423
16424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16425         LDKOpenChannel this_obj_conv;
16426         this_obj_conv.inner = (void*)(this_obj & (~1));
16427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16428         OpenChannel_free(this_obj_conv);
16429 }
16430
16431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
16432         LDKOpenChannel this_ptr_conv;
16433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16434         this_ptr_conv.is_owned = false;
16435         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16436         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
16437         return ret_arr;
16438 }
16439
16440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16441         LDKOpenChannel this_ptr_conv;
16442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16443         this_ptr_conv.is_owned = false;
16444         LDKThirtyTwoBytes val_ref;
16445         CHECK((*env)->GetArrayLength(env, val) == 32);
16446         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16447         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
16448 }
16449
16450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16451         LDKOpenChannel this_ptr_conv;
16452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16453         this_ptr_conv.is_owned = false;
16454         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16455         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
16456         return ret_arr;
16457 }
16458
16459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16460         LDKOpenChannel this_ptr_conv;
16461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16462         this_ptr_conv.is_owned = false;
16463         LDKThirtyTwoBytes val_ref;
16464         CHECK((*env)->GetArrayLength(env, val) == 32);
16465         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16466         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16467 }
16468
16469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16470         LDKOpenChannel this_ptr_conv;
16471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16472         this_ptr_conv.is_owned = false;
16473         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
16474         return ret_val;
16475 }
16476
16477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16478         LDKOpenChannel this_ptr_conv;
16479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16480         this_ptr_conv.is_owned = false;
16481         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
16482 }
16483
16484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16485         LDKOpenChannel this_ptr_conv;
16486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16487         this_ptr_conv.is_owned = false;
16488         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
16489         return ret_val;
16490 }
16491
16492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16493         LDKOpenChannel this_ptr_conv;
16494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16495         this_ptr_conv.is_owned = false;
16496         OpenChannel_set_push_msat(&this_ptr_conv, val);
16497 }
16498
16499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16500         LDKOpenChannel this_ptr_conv;
16501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16502         this_ptr_conv.is_owned = false;
16503         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
16504         return ret_val;
16505 }
16506
16507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16508         LDKOpenChannel this_ptr_conv;
16509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16510         this_ptr_conv.is_owned = false;
16511         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16512 }
16513
16514 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) {
16515         LDKOpenChannel this_ptr_conv;
16516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16517         this_ptr_conv.is_owned = false;
16518         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16519         return ret_val;
16520 }
16521
16522 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) {
16523         LDKOpenChannel this_ptr_conv;
16524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16525         this_ptr_conv.is_owned = false;
16526         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16527 }
16528
16529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16530         LDKOpenChannel this_ptr_conv;
16531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16532         this_ptr_conv.is_owned = false;
16533         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16534         return ret_val;
16535 }
16536
16537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16538         LDKOpenChannel this_ptr_conv;
16539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16540         this_ptr_conv.is_owned = false;
16541         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16542 }
16543
16544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16545         LDKOpenChannel this_ptr_conv;
16546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16547         this_ptr_conv.is_owned = false;
16548         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
16549         return ret_val;
16550 }
16551
16552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16553         LDKOpenChannel this_ptr_conv;
16554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16555         this_ptr_conv.is_owned = false;
16556         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16557 }
16558
16559 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
16560         LDKOpenChannel this_ptr_conv;
16561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16562         this_ptr_conv.is_owned = false;
16563         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
16564         return ret_val;
16565 }
16566
16567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16568         LDKOpenChannel this_ptr_conv;
16569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16570         this_ptr_conv.is_owned = false;
16571         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
16572 }
16573
16574 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16575         LDKOpenChannel this_ptr_conv;
16576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16577         this_ptr_conv.is_owned = false;
16578         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
16579         return ret_val;
16580 }
16581
16582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16583         LDKOpenChannel this_ptr_conv;
16584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16585         this_ptr_conv.is_owned = false;
16586         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
16587 }
16588
16589 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16590         LDKOpenChannel this_ptr_conv;
16591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16592         this_ptr_conv.is_owned = false;
16593         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
16594         return ret_val;
16595 }
16596
16597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16598         LDKOpenChannel this_ptr_conv;
16599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16600         this_ptr_conv.is_owned = false;
16601         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16602 }
16603
16604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16605         LDKOpenChannel this_ptr_conv;
16606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16607         this_ptr_conv.is_owned = false;
16608         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16609         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
16610         return ret_arr;
16611 }
16612
16613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16614         LDKOpenChannel this_ptr_conv;
16615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16616         this_ptr_conv.is_owned = false;
16617         LDKPublicKey val_ref;
16618         CHECK((*env)->GetArrayLength(env, val) == 33);
16619         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16620         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16621 }
16622
16623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16624         LDKOpenChannel this_ptr_conv;
16625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16626         this_ptr_conv.is_owned = false;
16627         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16629         return ret_arr;
16630 }
16631
16632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16633         LDKOpenChannel this_ptr_conv;
16634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16635         this_ptr_conv.is_owned = false;
16636         LDKPublicKey val_ref;
16637         CHECK((*env)->GetArrayLength(env, val) == 33);
16638         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16639         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16640 }
16641
16642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16643         LDKOpenChannel this_ptr_conv;
16644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16645         this_ptr_conv.is_owned = false;
16646         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
16648         return ret_arr;
16649 }
16650
16651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16652         LDKOpenChannel this_ptr_conv;
16653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16654         this_ptr_conv.is_owned = false;
16655         LDKPublicKey val_ref;
16656         CHECK((*env)->GetArrayLength(env, val) == 33);
16657         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16658         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
16659 }
16660
16661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16662         LDKOpenChannel this_ptr_conv;
16663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16664         this_ptr_conv.is_owned = false;
16665         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16667         return ret_arr;
16668 }
16669
16670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16671         LDKOpenChannel this_ptr_conv;
16672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16673         this_ptr_conv.is_owned = false;
16674         LDKPublicKey val_ref;
16675         CHECK((*env)->GetArrayLength(env, val) == 33);
16676         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16677         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16678 }
16679
16680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16681         LDKOpenChannel this_ptr_conv;
16682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16683         this_ptr_conv.is_owned = false;
16684         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16686         return ret_arr;
16687 }
16688
16689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16690         LDKOpenChannel this_ptr_conv;
16691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16692         this_ptr_conv.is_owned = false;
16693         LDKPublicKey val_ref;
16694         CHECK((*env)->GetArrayLength(env, val) == 33);
16695         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16696         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16697 }
16698
16699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16700         LDKOpenChannel this_ptr_conv;
16701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16702         this_ptr_conv.is_owned = false;
16703         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
16705         return ret_arr;
16706 }
16707
16708 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) {
16709         LDKOpenChannel this_ptr_conv;
16710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16711         this_ptr_conv.is_owned = false;
16712         LDKPublicKey val_ref;
16713         CHECK((*env)->GetArrayLength(env, val) == 33);
16714         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16715         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16716 }
16717
16718 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
16719         LDKOpenChannel this_ptr_conv;
16720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16721         this_ptr_conv.is_owned = false;
16722         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
16723         return ret_val;
16724 }
16725
16726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
16727         LDKOpenChannel this_ptr_conv;
16728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16729         this_ptr_conv.is_owned = false;
16730         OpenChannel_set_channel_flags(&this_ptr_conv, val);
16731 }
16732
16733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16734         LDKOpenChannel orig_conv;
16735         orig_conv.inner = (void*)(orig & (~1));
16736         orig_conv.is_owned = false;
16737         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
16738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16740         uint64_t ret_ref = (uint64_t)ret_var.inner;
16741         if (ret_var.is_owned) {
16742                 ret_ref |= 1;
16743         }
16744         return ret_ref;
16745 }
16746
16747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16748         LDKAcceptChannel this_obj_conv;
16749         this_obj_conv.inner = (void*)(this_obj & (~1));
16750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16751         AcceptChannel_free(this_obj_conv);
16752 }
16753
16754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16755         LDKAcceptChannel this_ptr_conv;
16756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16757         this_ptr_conv.is_owned = false;
16758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
16760         return ret_arr;
16761 }
16762
16763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16764         LDKAcceptChannel this_ptr_conv;
16765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16766         this_ptr_conv.is_owned = false;
16767         LDKThirtyTwoBytes val_ref;
16768         CHECK((*env)->GetArrayLength(env, val) == 32);
16769         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16770         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16771 }
16772
16773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16774         LDKAcceptChannel this_ptr_conv;
16775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16776         this_ptr_conv.is_owned = false;
16777         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
16778         return ret_val;
16779 }
16780
16781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16782         LDKAcceptChannel this_ptr_conv;
16783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16784         this_ptr_conv.is_owned = false;
16785         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16786 }
16787
16788 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) {
16789         LDKAcceptChannel this_ptr_conv;
16790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16791         this_ptr_conv.is_owned = false;
16792         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16793         return ret_val;
16794 }
16795
16796 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) {
16797         LDKAcceptChannel this_ptr_conv;
16798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16799         this_ptr_conv.is_owned = false;
16800         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16801 }
16802
16803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16804         LDKAcceptChannel this_ptr_conv;
16805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16806         this_ptr_conv.is_owned = false;
16807         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16808         return ret_val;
16809 }
16810
16811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16812         LDKAcceptChannel this_ptr_conv;
16813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16814         this_ptr_conv.is_owned = false;
16815         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16816 }
16817
16818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16819         LDKAcceptChannel this_ptr_conv;
16820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16821         this_ptr_conv.is_owned = false;
16822         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
16823         return ret_val;
16824 }
16825
16826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16827         LDKAcceptChannel this_ptr_conv;
16828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16829         this_ptr_conv.is_owned = false;
16830         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16831 }
16832
16833 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
16834         LDKAcceptChannel this_ptr_conv;
16835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16836         this_ptr_conv.is_owned = false;
16837         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
16838         return ret_val;
16839 }
16840
16841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
16842         LDKAcceptChannel this_ptr_conv;
16843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16844         this_ptr_conv.is_owned = false;
16845         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
16846 }
16847
16848 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16849         LDKAcceptChannel this_ptr_conv;
16850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16851         this_ptr_conv.is_owned = false;
16852         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
16853         return ret_val;
16854 }
16855
16856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16857         LDKAcceptChannel this_ptr_conv;
16858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16859         this_ptr_conv.is_owned = false;
16860         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
16861 }
16862
16863 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
16864         LDKAcceptChannel this_ptr_conv;
16865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16866         this_ptr_conv.is_owned = false;
16867         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
16868         return ret_val;
16869 }
16870
16871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
16872         LDKAcceptChannel this_ptr_conv;
16873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16874         this_ptr_conv.is_owned = false;
16875         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16876 }
16877
16878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
16879         LDKAcceptChannel this_ptr_conv;
16880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16881         this_ptr_conv.is_owned = false;
16882         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16883         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
16884         return ret_arr;
16885 }
16886
16887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16888         LDKAcceptChannel this_ptr_conv;
16889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16890         this_ptr_conv.is_owned = false;
16891         LDKPublicKey val_ref;
16892         CHECK((*env)->GetArrayLength(env, val) == 33);
16893         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16894         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16895 }
16896
16897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16898         LDKAcceptChannel this_ptr_conv;
16899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16900         this_ptr_conv.is_owned = false;
16901         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16902         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
16903         return ret_arr;
16904 }
16905
16906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16907         LDKAcceptChannel this_ptr_conv;
16908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16909         this_ptr_conv.is_owned = false;
16910         LDKPublicKey val_ref;
16911         CHECK((*env)->GetArrayLength(env, val) == 33);
16912         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16913         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16914 }
16915
16916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16917         LDKAcceptChannel this_ptr_conv;
16918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16919         this_ptr_conv.is_owned = false;
16920         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
16922         return ret_arr;
16923 }
16924
16925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16926         LDKAcceptChannel this_ptr_conv;
16927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16928         this_ptr_conv.is_owned = false;
16929         LDKPublicKey val_ref;
16930         CHECK((*env)->GetArrayLength(env, val) == 33);
16931         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16932         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
16933 }
16934
16935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16936         LDKAcceptChannel this_ptr_conv;
16937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16938         this_ptr_conv.is_owned = false;
16939         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
16941         return ret_arr;
16942 }
16943
16944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16945         LDKAcceptChannel this_ptr_conv;
16946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16947         this_ptr_conv.is_owned = false;
16948         LDKPublicKey val_ref;
16949         CHECK((*env)->GetArrayLength(env, val) == 33);
16950         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16951         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16952 }
16953
16954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
16955         LDKAcceptChannel this_ptr_conv;
16956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16957         this_ptr_conv.is_owned = false;
16958         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
16960         return ret_arr;
16961 }
16962
16963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16964         LDKAcceptChannel this_ptr_conv;
16965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16966         this_ptr_conv.is_owned = false;
16967         LDKPublicKey val_ref;
16968         CHECK((*env)->GetArrayLength(env, val) == 33);
16969         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16970         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16971 }
16972
16973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
16974         LDKAcceptChannel this_ptr_conv;
16975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16976         this_ptr_conv.is_owned = false;
16977         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
16979         return ret_arr;
16980 }
16981
16982 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) {
16983         LDKAcceptChannel this_ptr_conv;
16984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16985         this_ptr_conv.is_owned = false;
16986         LDKPublicKey val_ref;
16987         CHECK((*env)->GetArrayLength(env, val) == 33);
16988         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16989         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16990 }
16991
16992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16993         LDKAcceptChannel orig_conv;
16994         orig_conv.inner = (void*)(orig & (~1));
16995         orig_conv.is_owned = false;
16996         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
16997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16999         uint64_t ret_ref = (uint64_t)ret_var.inner;
17000         if (ret_var.is_owned) {
17001                 ret_ref |= 1;
17002         }
17003         return ret_ref;
17004 }
17005
17006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17007         LDKFundingCreated this_obj_conv;
17008         this_obj_conv.inner = (void*)(this_obj & (~1));
17009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17010         FundingCreated_free(this_obj_conv);
17011 }
17012
17013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17014         LDKFundingCreated this_ptr_conv;
17015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17016         this_ptr_conv.is_owned = false;
17017         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17018         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
17019         return ret_arr;
17020 }
17021
17022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17023         LDKFundingCreated this_ptr_conv;
17024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17025         this_ptr_conv.is_owned = false;
17026         LDKThirtyTwoBytes val_ref;
17027         CHECK((*env)->GetArrayLength(env, val) == 32);
17028         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17029         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17030 }
17031
17032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
17033         LDKFundingCreated this_ptr_conv;
17034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17035         this_ptr_conv.is_owned = false;
17036         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
17038         return ret_arr;
17039 }
17040
17041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17042         LDKFundingCreated this_ptr_conv;
17043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17044         this_ptr_conv.is_owned = false;
17045         LDKThirtyTwoBytes val_ref;
17046         CHECK((*env)->GetArrayLength(env, val) == 32);
17047         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17048         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17049 }
17050
17051 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
17052         LDKFundingCreated this_ptr_conv;
17053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17054         this_ptr_conv.is_owned = false;
17055         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17056         return ret_val;
17057 }
17058
17059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17060         LDKFundingCreated this_ptr_conv;
17061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17062         this_ptr_conv.is_owned = false;
17063         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17064 }
17065
17066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17067         LDKFundingCreated this_ptr_conv;
17068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17069         this_ptr_conv.is_owned = false;
17070         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
17072         return ret_arr;
17073 }
17074
17075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17076         LDKFundingCreated this_ptr_conv;
17077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17078         this_ptr_conv.is_owned = false;
17079         LDKSignature val_ref;
17080         CHECK((*env)->GetArrayLength(env, val) == 64);
17081         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17082         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17083 }
17084
17085 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) {
17086         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17087         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
17088         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
17089         LDKThirtyTwoBytes funding_txid_arg_ref;
17090         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
17091         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
17092         LDKSignature signature_arg_ref;
17093         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17094         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17095         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17098         uint64_t ret_ref = (uint64_t)ret_var.inner;
17099         if (ret_var.is_owned) {
17100                 ret_ref |= 1;
17101         }
17102         return ret_ref;
17103 }
17104
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17106         LDKFundingCreated orig_conv;
17107         orig_conv.inner = (void*)(orig & (~1));
17108         orig_conv.is_owned = false;
17109         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17110         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17111         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17112         uint64_t ret_ref = (uint64_t)ret_var.inner;
17113         if (ret_var.is_owned) {
17114                 ret_ref |= 1;
17115         }
17116         return ret_ref;
17117 }
17118
17119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17120         LDKFundingSigned this_obj_conv;
17121         this_obj_conv.inner = (void*)(this_obj & (~1));
17122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17123         FundingSigned_free(this_obj_conv);
17124 }
17125
17126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17127         LDKFundingSigned this_ptr_conv;
17128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17129         this_ptr_conv.is_owned = false;
17130         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17131         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
17132         return ret_arr;
17133 }
17134
17135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17136         LDKFundingSigned this_ptr_conv;
17137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17138         this_ptr_conv.is_owned = false;
17139         LDKThirtyTwoBytes val_ref;
17140         CHECK((*env)->GetArrayLength(env, val) == 32);
17141         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17142         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17143 }
17144
17145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17146         LDKFundingSigned this_ptr_conv;
17147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17148         this_ptr_conv.is_owned = false;
17149         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
17151         return ret_arr;
17152 }
17153
17154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17155         LDKFundingSigned this_ptr_conv;
17156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17157         this_ptr_conv.is_owned = false;
17158         LDKSignature val_ref;
17159         CHECK((*env)->GetArrayLength(env, val) == 64);
17160         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17161         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17162 }
17163
17164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
17165         LDKThirtyTwoBytes channel_id_arg_ref;
17166         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17167         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17168         LDKSignature signature_arg_ref;
17169         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17170         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17171         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17174         uint64_t ret_ref = (uint64_t)ret_var.inner;
17175         if (ret_var.is_owned) {
17176                 ret_ref |= 1;
17177         }
17178         return ret_ref;
17179 }
17180
17181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17182         LDKFundingSigned orig_conv;
17183         orig_conv.inner = (void*)(orig & (~1));
17184         orig_conv.is_owned = false;
17185         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17186         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17187         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17188         uint64_t ret_ref = (uint64_t)ret_var.inner;
17189         if (ret_var.is_owned) {
17190                 ret_ref |= 1;
17191         }
17192         return ret_ref;
17193 }
17194
17195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17196         LDKFundingLocked this_obj_conv;
17197         this_obj_conv.inner = (void*)(this_obj & (~1));
17198         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17199         FundingLocked_free(this_obj_conv);
17200 }
17201
17202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17203         LDKFundingLocked this_ptr_conv;
17204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17205         this_ptr_conv.is_owned = false;
17206         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17207         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
17208         return ret_arr;
17209 }
17210
17211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17212         LDKFundingLocked this_ptr_conv;
17213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17214         this_ptr_conv.is_owned = false;
17215         LDKThirtyTwoBytes val_ref;
17216         CHECK((*env)->GetArrayLength(env, val) == 32);
17217         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17218         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17219 }
17220
17221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17222         LDKFundingLocked this_ptr_conv;
17223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17224         this_ptr_conv.is_owned = false;
17225         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17226         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17227         return ret_arr;
17228 }
17229
17230 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) {
17231         LDKFundingLocked this_ptr_conv;
17232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17233         this_ptr_conv.is_owned = false;
17234         LDKPublicKey val_ref;
17235         CHECK((*env)->GetArrayLength(env, val) == 33);
17236         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17237         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17238 }
17239
17240 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) {
17241         LDKThirtyTwoBytes channel_id_arg_ref;
17242         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17243         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17244         LDKPublicKey next_per_commitment_point_arg_ref;
17245         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17246         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17247         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17248         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17249         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17250         uint64_t ret_ref = (uint64_t)ret_var.inner;
17251         if (ret_var.is_owned) {
17252                 ret_ref |= 1;
17253         }
17254         return ret_ref;
17255 }
17256
17257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17258         LDKFundingLocked orig_conv;
17259         orig_conv.inner = (void*)(orig & (~1));
17260         orig_conv.is_owned = false;
17261         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17264         uint64_t ret_ref = (uint64_t)ret_var.inner;
17265         if (ret_var.is_owned) {
17266                 ret_ref |= 1;
17267         }
17268         return ret_ref;
17269 }
17270
17271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17272         LDKShutdown this_obj_conv;
17273         this_obj_conv.inner = (void*)(this_obj & (~1));
17274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17275         Shutdown_free(this_obj_conv);
17276 }
17277
17278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17279         LDKShutdown this_ptr_conv;
17280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17281         this_ptr_conv.is_owned = false;
17282         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
17284         return ret_arr;
17285 }
17286
17287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17288         LDKShutdown this_ptr_conv;
17289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17290         this_ptr_conv.is_owned = false;
17291         LDKThirtyTwoBytes val_ref;
17292         CHECK((*env)->GetArrayLength(env, val) == 32);
17293         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17294         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17295 }
17296
17297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17298         LDKShutdown this_ptr_conv;
17299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17300         this_ptr_conv.is_owned = false;
17301         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17302         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17303         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17304         return ret_arr;
17305 }
17306
17307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17308         LDKShutdown this_ptr_conv;
17309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17310         this_ptr_conv.is_owned = false;
17311         LDKCVec_u8Z val_ref;
17312         val_ref.datalen = (*env)->GetArrayLength(env, val);
17313         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17314         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
17315         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17316 }
17317
17318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17319         LDKThirtyTwoBytes channel_id_arg_ref;
17320         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17321         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17322         LDKCVec_u8Z scriptpubkey_arg_ref;
17323         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
17324         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17325         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
17326         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17329         uint64_t ret_ref = (uint64_t)ret_var.inner;
17330         if (ret_var.is_owned) {
17331                 ret_ref |= 1;
17332         }
17333         return ret_ref;
17334 }
17335
17336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17337         LDKShutdown orig_conv;
17338         orig_conv.inner = (void*)(orig & (~1));
17339         orig_conv.is_owned = false;
17340         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17343         uint64_t ret_ref = (uint64_t)ret_var.inner;
17344         if (ret_var.is_owned) {
17345                 ret_ref |= 1;
17346         }
17347         return ret_ref;
17348 }
17349
17350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17351         LDKClosingSigned this_obj_conv;
17352         this_obj_conv.inner = (void*)(this_obj & (~1));
17353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17354         ClosingSigned_free(this_obj_conv);
17355 }
17356
17357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17358         LDKClosingSigned this_ptr_conv;
17359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17360         this_ptr_conv.is_owned = false;
17361         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17362         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
17363         return ret_arr;
17364 }
17365
17366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17367         LDKClosingSigned this_ptr_conv;
17368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17369         this_ptr_conv.is_owned = false;
17370         LDKThirtyTwoBytes val_ref;
17371         CHECK((*env)->GetArrayLength(env, val) == 32);
17372         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17373         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17374 }
17375
17376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17377         LDKClosingSigned this_ptr_conv;
17378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17379         this_ptr_conv.is_owned = false;
17380         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17381         return ret_val;
17382 }
17383
17384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17385         LDKClosingSigned this_ptr_conv;
17386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17387         this_ptr_conv.is_owned = false;
17388         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17389 }
17390
17391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17392         LDKClosingSigned this_ptr_conv;
17393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17394         this_ptr_conv.is_owned = false;
17395         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17396         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
17397         return ret_arr;
17398 }
17399
17400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17401         LDKClosingSigned this_ptr_conv;
17402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17403         this_ptr_conv.is_owned = false;
17404         LDKSignature val_ref;
17405         CHECK((*env)->GetArrayLength(env, val) == 64);
17406         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17407         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17408 }
17409
17410 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) {
17411         LDKThirtyTwoBytes channel_id_arg_ref;
17412         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17413         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17414         LDKSignature signature_arg_ref;
17415         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17416         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17417         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
17418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17420         uint64_t ret_ref = (uint64_t)ret_var.inner;
17421         if (ret_var.is_owned) {
17422                 ret_ref |= 1;
17423         }
17424         return ret_ref;
17425 }
17426
17427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17428         LDKClosingSigned orig_conv;
17429         orig_conv.inner = (void*)(orig & (~1));
17430         orig_conv.is_owned = false;
17431         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
17432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17434         uint64_t ret_ref = (uint64_t)ret_var.inner;
17435         if (ret_var.is_owned) {
17436                 ret_ref |= 1;
17437         }
17438         return ret_ref;
17439 }
17440
17441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17442         LDKUpdateAddHTLC this_obj_conv;
17443         this_obj_conv.inner = (void*)(this_obj & (~1));
17444         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17445         UpdateAddHTLC_free(this_obj_conv);
17446 }
17447
17448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17449         LDKUpdateAddHTLC this_ptr_conv;
17450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17451         this_ptr_conv.is_owned = false;
17452         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17453         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
17454         return ret_arr;
17455 }
17456
17457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17458         LDKUpdateAddHTLC this_ptr_conv;
17459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17460         this_ptr_conv.is_owned = false;
17461         LDKThirtyTwoBytes val_ref;
17462         CHECK((*env)->GetArrayLength(env, val) == 32);
17463         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17464         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
17465 }
17466
17467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17468         LDKUpdateAddHTLC this_ptr_conv;
17469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17470         this_ptr_conv.is_owned = false;
17471         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
17472         return ret_val;
17473 }
17474
17475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17476         LDKUpdateAddHTLC this_ptr_conv;
17477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17478         this_ptr_conv.is_owned = false;
17479         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
17480 }
17481
17482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17483         LDKUpdateAddHTLC this_ptr_conv;
17484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17485         this_ptr_conv.is_owned = false;
17486         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
17487         return ret_val;
17488 }
17489
17490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17491         LDKUpdateAddHTLC this_ptr_conv;
17492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17493         this_ptr_conv.is_owned = false;
17494         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
17495 }
17496
17497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17498         LDKUpdateAddHTLC this_ptr_conv;
17499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17500         this_ptr_conv.is_owned = false;
17501         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17502         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
17503         return ret_arr;
17504 }
17505
17506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17507         LDKUpdateAddHTLC this_ptr_conv;
17508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17509         this_ptr_conv.is_owned = false;
17510         LDKThirtyTwoBytes val_ref;
17511         CHECK((*env)->GetArrayLength(env, val) == 32);
17512         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17513         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
17514 }
17515
17516 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
17517         LDKUpdateAddHTLC this_ptr_conv;
17518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17519         this_ptr_conv.is_owned = false;
17520         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
17521         return ret_val;
17522 }
17523
17524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17525         LDKUpdateAddHTLC this_ptr_conv;
17526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17527         this_ptr_conv.is_owned = false;
17528         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
17529 }
17530
17531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17532         LDKUpdateAddHTLC orig_conv;
17533         orig_conv.inner = (void*)(orig & (~1));
17534         orig_conv.is_owned = false;
17535         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
17536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17538         uint64_t ret_ref = (uint64_t)ret_var.inner;
17539         if (ret_var.is_owned) {
17540                 ret_ref |= 1;
17541         }
17542         return ret_ref;
17543 }
17544
17545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17546         LDKUpdateFulfillHTLC this_obj_conv;
17547         this_obj_conv.inner = (void*)(this_obj & (~1));
17548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17549         UpdateFulfillHTLC_free(this_obj_conv);
17550 }
17551
17552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17553         LDKUpdateFulfillHTLC this_ptr_conv;
17554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17555         this_ptr_conv.is_owned = false;
17556         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
17558         return ret_arr;
17559 }
17560
17561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17562         LDKUpdateFulfillHTLC this_ptr_conv;
17563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17564         this_ptr_conv.is_owned = false;
17565         LDKThirtyTwoBytes val_ref;
17566         CHECK((*env)->GetArrayLength(env, val) == 32);
17567         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17568         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
17569 }
17570
17571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17572         LDKUpdateFulfillHTLC this_ptr_conv;
17573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17574         this_ptr_conv.is_owned = false;
17575         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
17576         return ret_val;
17577 }
17578
17579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17580         LDKUpdateFulfillHTLC this_ptr_conv;
17581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17582         this_ptr_conv.is_owned = false;
17583         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
17584 }
17585
17586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
17587         LDKUpdateFulfillHTLC this_ptr_conv;
17588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17589         this_ptr_conv.is_owned = false;
17590         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
17592         return ret_arr;
17593 }
17594
17595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17596         LDKUpdateFulfillHTLC this_ptr_conv;
17597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17598         this_ptr_conv.is_owned = false;
17599         LDKThirtyTwoBytes val_ref;
17600         CHECK((*env)->GetArrayLength(env, val) == 32);
17601         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17602         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
17603 }
17604
17605 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) {
17606         LDKThirtyTwoBytes channel_id_arg_ref;
17607         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17608         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17609         LDKThirtyTwoBytes payment_preimage_arg_ref;
17610         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
17611         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
17612         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
17613         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17614         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17615         uint64_t ret_ref = (uint64_t)ret_var.inner;
17616         if (ret_var.is_owned) {
17617                 ret_ref |= 1;
17618         }
17619         return ret_ref;
17620 }
17621
17622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17623         LDKUpdateFulfillHTLC orig_conv;
17624         orig_conv.inner = (void*)(orig & (~1));
17625         orig_conv.is_owned = false;
17626         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
17627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17629         uint64_t ret_ref = (uint64_t)ret_var.inner;
17630         if (ret_var.is_owned) {
17631                 ret_ref |= 1;
17632         }
17633         return ret_ref;
17634 }
17635
17636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17637         LDKUpdateFailHTLC this_obj_conv;
17638         this_obj_conv.inner = (void*)(this_obj & (~1));
17639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17640         UpdateFailHTLC_free(this_obj_conv);
17641 }
17642
17643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17644         LDKUpdateFailHTLC this_ptr_conv;
17645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17646         this_ptr_conv.is_owned = false;
17647         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
17649         return ret_arr;
17650 }
17651
17652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17653         LDKUpdateFailHTLC this_ptr_conv;
17654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17655         this_ptr_conv.is_owned = false;
17656         LDKThirtyTwoBytes val_ref;
17657         CHECK((*env)->GetArrayLength(env, val) == 32);
17658         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17659         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
17660 }
17661
17662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17663         LDKUpdateFailHTLC this_ptr_conv;
17664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17665         this_ptr_conv.is_owned = false;
17666         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
17667         return ret_val;
17668 }
17669
17670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17671         LDKUpdateFailHTLC this_ptr_conv;
17672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17673         this_ptr_conv.is_owned = false;
17674         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
17675 }
17676
17677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17678         LDKUpdateFailHTLC orig_conv;
17679         orig_conv.inner = (void*)(orig & (~1));
17680         orig_conv.is_owned = false;
17681         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
17682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17684         uint64_t ret_ref = (uint64_t)ret_var.inner;
17685         if (ret_var.is_owned) {
17686                 ret_ref |= 1;
17687         }
17688         return ret_ref;
17689 }
17690
17691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17692         LDKUpdateFailMalformedHTLC this_obj_conv;
17693         this_obj_conv.inner = (void*)(this_obj & (~1));
17694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17695         UpdateFailMalformedHTLC_free(this_obj_conv);
17696 }
17697
17698 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17699         LDKUpdateFailMalformedHTLC this_ptr_conv;
17700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17701         this_ptr_conv.is_owned = false;
17702         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
17704         return ret_arr;
17705 }
17706
17707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17708         LDKUpdateFailMalformedHTLC this_ptr_conv;
17709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17710         this_ptr_conv.is_owned = false;
17711         LDKThirtyTwoBytes val_ref;
17712         CHECK((*env)->GetArrayLength(env, val) == 32);
17713         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17714         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
17715 }
17716
17717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17718         LDKUpdateFailMalformedHTLC this_ptr_conv;
17719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17720         this_ptr_conv.is_owned = false;
17721         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
17722         return ret_val;
17723 }
17724
17725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17726         LDKUpdateFailMalformedHTLC this_ptr_conv;
17727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17728         this_ptr_conv.is_owned = false;
17729         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
17730 }
17731
17732 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
17733         LDKUpdateFailMalformedHTLC this_ptr_conv;
17734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17735         this_ptr_conv.is_owned = false;
17736         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
17737         return ret_val;
17738 }
17739
17740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17741         LDKUpdateFailMalformedHTLC this_ptr_conv;
17742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17743         this_ptr_conv.is_owned = false;
17744         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
17745 }
17746
17747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17748         LDKUpdateFailMalformedHTLC orig_conv;
17749         orig_conv.inner = (void*)(orig & (~1));
17750         orig_conv.is_owned = false;
17751         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
17752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17754         uint64_t ret_ref = (uint64_t)ret_var.inner;
17755         if (ret_var.is_owned) {
17756                 ret_ref |= 1;
17757         }
17758         return ret_ref;
17759 }
17760
17761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17762         LDKCommitmentSigned this_obj_conv;
17763         this_obj_conv.inner = (void*)(this_obj & (~1));
17764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17765         CommitmentSigned_free(this_obj_conv);
17766 }
17767
17768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17769         LDKCommitmentSigned this_ptr_conv;
17770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17771         this_ptr_conv.is_owned = false;
17772         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17773         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
17774         return ret_arr;
17775 }
17776
17777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17778         LDKCommitmentSigned this_ptr_conv;
17779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17780         this_ptr_conv.is_owned = false;
17781         LDKThirtyTwoBytes val_ref;
17782         CHECK((*env)->GetArrayLength(env, val) == 32);
17783         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17784         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
17785 }
17786
17787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
17788         LDKCommitmentSigned this_ptr_conv;
17789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17790         this_ptr_conv.is_owned = false;
17791         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
17792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
17793         return ret_arr;
17794 }
17795
17796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17797         LDKCommitmentSigned this_ptr_conv;
17798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17799         this_ptr_conv.is_owned = false;
17800         LDKSignature val_ref;
17801         CHECK((*env)->GetArrayLength(env, val) == 64);
17802         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
17803         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
17804 }
17805
17806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
17807         LDKCommitmentSigned this_ptr_conv;
17808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17809         this_ptr_conv.is_owned = false;
17810         LDKCVec_SignatureZ val_constr;
17811         val_constr.datalen = (*env)->GetArrayLength(env, val);
17812         if (val_constr.datalen > 0)
17813                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17814         else
17815                 val_constr.data = NULL;
17816         for (size_t i = 0; i < val_constr.datalen; i++) {
17817                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
17818                 LDKSignature val_conv_8_ref;
17819                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
17820                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
17821                 val_constr.data[i] = val_conv_8_ref;
17822         }
17823         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
17824 }
17825
17826 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) {
17827         LDKThirtyTwoBytes channel_id_arg_ref;
17828         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17829         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17830         LDKSignature signature_arg_ref;
17831         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
17832         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
17833         LDKCVec_SignatureZ htlc_signatures_arg_constr;
17834         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
17835         if (htlc_signatures_arg_constr.datalen > 0)
17836                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17837         else
17838                 htlc_signatures_arg_constr.data = NULL;
17839         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
17840                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
17841                 LDKSignature htlc_signatures_arg_conv_8_ref;
17842                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
17843                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
17844                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
17845         }
17846         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
17847         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17848         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17849         uint64_t ret_ref = (uint64_t)ret_var.inner;
17850         if (ret_var.is_owned) {
17851                 ret_ref |= 1;
17852         }
17853         return ret_ref;
17854 }
17855
17856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17857         LDKCommitmentSigned orig_conv;
17858         orig_conv.inner = (void*)(orig & (~1));
17859         orig_conv.is_owned = false;
17860         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
17861         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17862         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17863         uint64_t ret_ref = (uint64_t)ret_var.inner;
17864         if (ret_var.is_owned) {
17865                 ret_ref |= 1;
17866         }
17867         return ret_ref;
17868 }
17869
17870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17871         LDKRevokeAndACK this_obj_conv;
17872         this_obj_conv.inner = (void*)(this_obj & (~1));
17873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17874         RevokeAndACK_free(this_obj_conv);
17875 }
17876
17877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17878         LDKRevokeAndACK this_ptr_conv;
17879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17880         this_ptr_conv.is_owned = false;
17881         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
17883         return ret_arr;
17884 }
17885
17886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17887         LDKRevokeAndACK this_ptr_conv;
17888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17889         this_ptr_conv.is_owned = false;
17890         LDKThirtyTwoBytes val_ref;
17891         CHECK((*env)->GetArrayLength(env, val) == 32);
17892         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17893         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
17894 }
17895
17896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
17897         LDKRevokeAndACK this_ptr_conv;
17898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17899         this_ptr_conv.is_owned = false;
17900         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17901         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
17902         return ret_arr;
17903 }
17904
17905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17906         LDKRevokeAndACK this_ptr_conv;
17907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17908         this_ptr_conv.is_owned = false;
17909         LDKThirtyTwoBytes val_ref;
17910         CHECK((*env)->GetArrayLength(env, val) == 32);
17911         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17912         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
17913 }
17914
17915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17916         LDKRevokeAndACK this_ptr_conv;
17917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17918         this_ptr_conv.is_owned = false;
17919         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17920         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
17921         return ret_arr;
17922 }
17923
17924 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) {
17925         LDKRevokeAndACK this_ptr_conv;
17926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17927         this_ptr_conv.is_owned = false;
17928         LDKPublicKey val_ref;
17929         CHECK((*env)->GetArrayLength(env, val) == 33);
17930         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17931         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17932 }
17933
17934 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) {
17935         LDKThirtyTwoBytes channel_id_arg_ref;
17936         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17937         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17938         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
17939         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
17940         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
17941         LDKPublicKey next_per_commitment_point_arg_ref;
17942         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
17943         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
17944         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
17945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17947         uint64_t ret_ref = (uint64_t)ret_var.inner;
17948         if (ret_var.is_owned) {
17949                 ret_ref |= 1;
17950         }
17951         return ret_ref;
17952 }
17953
17954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17955         LDKRevokeAndACK orig_conv;
17956         orig_conv.inner = (void*)(orig & (~1));
17957         orig_conv.is_owned = false;
17958         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
17959         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17960         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17961         uint64_t ret_ref = (uint64_t)ret_var.inner;
17962         if (ret_var.is_owned) {
17963                 ret_ref |= 1;
17964         }
17965         return ret_ref;
17966 }
17967
17968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17969         LDKUpdateFee this_obj_conv;
17970         this_obj_conv.inner = (void*)(this_obj & (~1));
17971         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17972         UpdateFee_free(this_obj_conv);
17973 }
17974
17975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17976         LDKUpdateFee this_ptr_conv;
17977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17978         this_ptr_conv.is_owned = false;
17979         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
17981         return ret_arr;
17982 }
17983
17984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17985         LDKUpdateFee this_ptr_conv;
17986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17987         this_ptr_conv.is_owned = false;
17988         LDKThirtyTwoBytes val_ref;
17989         CHECK((*env)->GetArrayLength(env, val) == 32);
17990         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17991         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
17992 }
17993
17994 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17995         LDKUpdateFee this_ptr_conv;
17996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17997         this_ptr_conv.is_owned = false;
17998         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
17999         return ret_val;
18000 }
18001
18002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18003         LDKUpdateFee this_ptr_conv;
18004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18005         this_ptr_conv.is_owned = false;
18006         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18007 }
18008
18009 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) {
18010         LDKThirtyTwoBytes channel_id_arg_ref;
18011         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18012         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18013         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18016         uint64_t ret_ref = (uint64_t)ret_var.inner;
18017         if (ret_var.is_owned) {
18018                 ret_ref |= 1;
18019         }
18020         return ret_ref;
18021 }
18022
18023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18024         LDKUpdateFee orig_conv;
18025         orig_conv.inner = (void*)(orig & (~1));
18026         orig_conv.is_owned = false;
18027         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18028         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18029         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18030         uint64_t ret_ref = (uint64_t)ret_var.inner;
18031         if (ret_var.is_owned) {
18032                 ret_ref |= 1;
18033         }
18034         return ret_ref;
18035 }
18036
18037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18038         LDKDataLossProtect this_obj_conv;
18039         this_obj_conv.inner = (void*)(this_obj & (~1));
18040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18041         DataLossProtect_free(this_obj_conv);
18042 }
18043
18044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
18045         LDKDataLossProtect this_ptr_conv;
18046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18047         this_ptr_conv.is_owned = false;
18048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
18050         return ret_arr;
18051 }
18052
18053 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) {
18054         LDKDataLossProtect this_ptr_conv;
18055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18056         this_ptr_conv.is_owned = false;
18057         LDKThirtyTwoBytes val_ref;
18058         CHECK((*env)->GetArrayLength(env, val) == 32);
18059         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18060         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18061 }
18062
18063 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18064         LDKDataLossProtect this_ptr_conv;
18065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18066         this_ptr_conv.is_owned = false;
18067         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
18069         return ret_arr;
18070 }
18071
18072 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) {
18073         LDKDataLossProtect this_ptr_conv;
18074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18075         this_ptr_conv.is_owned = false;
18076         LDKPublicKey val_ref;
18077         CHECK((*env)->GetArrayLength(env, val) == 33);
18078         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18079         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18080 }
18081
18082 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) {
18083         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18084         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
18085         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
18086         LDKPublicKey my_current_per_commitment_point_arg_ref;
18087         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
18088         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
18089         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18090         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18091         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18092         uint64_t ret_ref = (uint64_t)ret_var.inner;
18093         if (ret_var.is_owned) {
18094                 ret_ref |= 1;
18095         }
18096         return ret_ref;
18097 }
18098
18099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18100         LDKDataLossProtect orig_conv;
18101         orig_conv.inner = (void*)(orig & (~1));
18102         orig_conv.is_owned = false;
18103         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18106         uint64_t ret_ref = (uint64_t)ret_var.inner;
18107         if (ret_var.is_owned) {
18108                 ret_ref |= 1;
18109         }
18110         return ret_ref;
18111 }
18112
18113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18114         LDKChannelReestablish this_obj_conv;
18115         this_obj_conv.inner = (void*)(this_obj & (~1));
18116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18117         ChannelReestablish_free(this_obj_conv);
18118 }
18119
18120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18121         LDKChannelReestablish this_ptr_conv;
18122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18123         this_ptr_conv.is_owned = false;
18124         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
18126         return ret_arr;
18127 }
18128
18129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18130         LDKChannelReestablish this_ptr_conv;
18131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18132         this_ptr_conv.is_owned = false;
18133         LDKThirtyTwoBytes val_ref;
18134         CHECK((*env)->GetArrayLength(env, val) == 32);
18135         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18136         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18137 }
18138
18139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18140         LDKChannelReestablish this_ptr_conv;
18141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18142         this_ptr_conv.is_owned = false;
18143         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18144         return ret_val;
18145 }
18146
18147 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) {
18148         LDKChannelReestablish this_ptr_conv;
18149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18150         this_ptr_conv.is_owned = false;
18151         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18152 }
18153
18154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
18155         LDKChannelReestablish this_ptr_conv;
18156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18157         this_ptr_conv.is_owned = false;
18158         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18159         return ret_val;
18160 }
18161
18162 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) {
18163         LDKChannelReestablish this_ptr_conv;
18164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18165         this_ptr_conv.is_owned = false;
18166         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18167 }
18168
18169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18170         LDKChannelReestablish orig_conv;
18171         orig_conv.inner = (void*)(orig & (~1));
18172         orig_conv.is_owned = false;
18173         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18176         uint64_t ret_ref = (uint64_t)ret_var.inner;
18177         if (ret_var.is_owned) {
18178                 ret_ref |= 1;
18179         }
18180         return ret_ref;
18181 }
18182
18183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18184         LDKAnnouncementSignatures this_obj_conv;
18185         this_obj_conv.inner = (void*)(this_obj & (~1));
18186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18187         AnnouncementSignatures_free(this_obj_conv);
18188 }
18189
18190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18191         LDKAnnouncementSignatures this_ptr_conv;
18192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18193         this_ptr_conv.is_owned = false;
18194         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
18196         return ret_arr;
18197 }
18198
18199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18200         LDKAnnouncementSignatures this_ptr_conv;
18201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18202         this_ptr_conv.is_owned = false;
18203         LDKThirtyTwoBytes val_ref;
18204         CHECK((*env)->GetArrayLength(env, val) == 32);
18205         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18206         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18207 }
18208
18209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18210         LDKAnnouncementSignatures this_ptr_conv;
18211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18212         this_ptr_conv.is_owned = false;
18213         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18214         return ret_val;
18215 }
18216
18217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18218         LDKAnnouncementSignatures this_ptr_conv;
18219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18220         this_ptr_conv.is_owned = false;
18221         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18222 }
18223
18224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18225         LDKAnnouncementSignatures this_ptr_conv;
18226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18227         this_ptr_conv.is_owned = false;
18228         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18229         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
18230         return ret_arr;
18231 }
18232
18233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18234         LDKAnnouncementSignatures this_ptr_conv;
18235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18236         this_ptr_conv.is_owned = false;
18237         LDKSignature val_ref;
18238         CHECK((*env)->GetArrayLength(env, val) == 64);
18239         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18240         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18241 }
18242
18243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18244         LDKAnnouncementSignatures this_ptr_conv;
18245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18246         this_ptr_conv.is_owned = false;
18247         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18248         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
18249         return ret_arr;
18250 }
18251
18252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18253         LDKAnnouncementSignatures this_ptr_conv;
18254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18255         this_ptr_conv.is_owned = false;
18256         LDKSignature val_ref;
18257         CHECK((*env)->GetArrayLength(env, val) == 64);
18258         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18259         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18260 }
18261
18262 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) {
18263         LDKThirtyTwoBytes channel_id_arg_ref;
18264         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18265         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18266         LDKSignature node_signature_arg_ref;
18267         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
18268         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
18269         LDKSignature bitcoin_signature_arg_ref;
18270         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
18271         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
18272         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
18273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18275         uint64_t ret_ref = (uint64_t)ret_var.inner;
18276         if (ret_var.is_owned) {
18277                 ret_ref |= 1;
18278         }
18279         return ret_ref;
18280 }
18281
18282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18283         LDKAnnouncementSignatures orig_conv;
18284         orig_conv.inner = (void*)(orig & (~1));
18285         orig_conv.is_owned = false;
18286         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18289         uint64_t ret_ref = (uint64_t)ret_var.inner;
18290         if (ret_var.is_owned) {
18291                 ret_ref |= 1;
18292         }
18293         return ret_ref;
18294 }
18295
18296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
18297         if ((this_ptr & 1) != 0) return;
18298         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18299         FREE((void*)this_ptr);
18300         NetAddress_free(this_ptr_conv);
18301 }
18302
18303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18304         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18305         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18306         *ret_copy = NetAddress_clone(orig_conv);
18307         uint64_t ret_ref = (uint64_t)ret_copy;
18308         return ret_ref;
18309 }
18310
18311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
18312         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18313         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18316         CVec_u8Z_free(ret_var);
18317         return ret_arr;
18318 }
18319
18320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18321         LDKu8slice ser_ref;
18322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18324         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18325         *ret_conv = Result_read(ser_ref);
18326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18327         return (uint64_t)ret_conv;
18328 }
18329
18330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
18331         LDKu8slice ser_ref;
18332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
18333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
18334         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18335         *ret_conv = NetAddress_read(ser_ref);
18336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
18337         return (uint64_t)ret_conv;
18338 }
18339
18340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18341         LDKUnsignedNodeAnnouncement this_obj_conv;
18342         this_obj_conv.inner = (void*)(this_obj & (~1));
18343         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18344         UnsignedNodeAnnouncement_free(this_obj_conv);
18345 }
18346
18347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18348         LDKUnsignedNodeAnnouncement this_ptr_conv;
18349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18350         this_ptr_conv.is_owned = false;
18351         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18354         uint64_t ret_ref = (uint64_t)ret_var.inner;
18355         if (ret_var.is_owned) {
18356                 ret_ref |= 1;
18357         }
18358         return ret_ref;
18359 }
18360
18361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18362         LDKUnsignedNodeAnnouncement this_ptr_conv;
18363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18364         this_ptr_conv.is_owned = false;
18365         LDKNodeFeatures val_conv;
18366         val_conv.inner = (void*)(val & (~1));
18367         val_conv.is_owned = (val & 1) || (val == 0);
18368         val_conv = NodeFeatures_clone(&val_conv);
18369         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18370 }
18371
18372 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18373         LDKUnsignedNodeAnnouncement this_ptr_conv;
18374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18375         this_ptr_conv.is_owned = false;
18376         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18377         return ret_val;
18378 }
18379
18380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18381         LDKUnsignedNodeAnnouncement this_ptr_conv;
18382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18383         this_ptr_conv.is_owned = false;
18384         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18385 }
18386
18387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18388         LDKUnsignedNodeAnnouncement this_ptr_conv;
18389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18390         this_ptr_conv.is_owned = false;
18391         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
18393         return ret_arr;
18394 }
18395
18396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18397         LDKUnsignedNodeAnnouncement this_ptr_conv;
18398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18399         this_ptr_conv.is_owned = false;
18400         LDKPublicKey val_ref;
18401         CHECK((*env)->GetArrayLength(env, val) == 33);
18402         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18403         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18404 }
18405
18406 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
18407         LDKUnsignedNodeAnnouncement this_ptr_conv;
18408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18409         this_ptr_conv.is_owned = false;
18410         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
18411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
18412         return ret_arr;
18413 }
18414
18415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18416         LDKUnsignedNodeAnnouncement this_ptr_conv;
18417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18418         this_ptr_conv.is_owned = false;
18419         LDKThreeBytes val_ref;
18420         CHECK((*env)->GetArrayLength(env, val) == 3);
18421         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
18422         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
18423 }
18424
18425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
18426         LDKUnsignedNodeAnnouncement this_ptr_conv;
18427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18428         this_ptr_conv.is_owned = false;
18429         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
18431         return ret_arr;
18432 }
18433
18434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18435         LDKUnsignedNodeAnnouncement this_ptr_conv;
18436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18437         this_ptr_conv.is_owned = false;
18438         LDKThirtyTwoBytes val_ref;
18439         CHECK((*env)->GetArrayLength(env, val) == 32);
18440         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18441         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
18442 }
18443
18444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
18445         LDKUnsignedNodeAnnouncement this_ptr_conv;
18446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18447         this_ptr_conv.is_owned = false;
18448         LDKCVec_NetAddressZ val_constr;
18449         val_constr.datalen = (*env)->GetArrayLength(env, val);
18450         if (val_constr.datalen > 0)
18451                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18452         else
18453                 val_constr.data = NULL;
18454         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
18455         for (size_t m = 0; m < val_constr.datalen; m++) {
18456                 int64_t val_conv_12 = val_vals[m];
18457                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18458                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
18459                 val_constr.data[m] = val_conv_12_conv;
18460         }
18461         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
18462         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
18463 }
18464
18465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18466         LDKUnsignedNodeAnnouncement orig_conv;
18467         orig_conv.inner = (void*)(orig & (~1));
18468         orig_conv.is_owned = false;
18469         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
18470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18472         uint64_t ret_ref = (uint64_t)ret_var.inner;
18473         if (ret_var.is_owned) {
18474                 ret_ref |= 1;
18475         }
18476         return ret_ref;
18477 }
18478
18479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18480         LDKNodeAnnouncement this_obj_conv;
18481         this_obj_conv.inner = (void*)(this_obj & (~1));
18482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18483         NodeAnnouncement_free(this_obj_conv);
18484 }
18485
18486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18487         LDKNodeAnnouncement this_ptr_conv;
18488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18489         this_ptr_conv.is_owned = false;
18490         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
18492         return ret_arr;
18493 }
18494
18495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18496         LDKNodeAnnouncement this_ptr_conv;
18497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18498         this_ptr_conv.is_owned = false;
18499         LDKSignature val_ref;
18500         CHECK((*env)->GetArrayLength(env, val) == 64);
18501         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18502         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
18503 }
18504
18505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
18506         LDKNodeAnnouncement this_ptr_conv;
18507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18508         this_ptr_conv.is_owned = false;
18509         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
18510         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18511         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18512         uint64_t ret_ref = (uint64_t)ret_var.inner;
18513         if (ret_var.is_owned) {
18514                 ret_ref |= 1;
18515         }
18516         return ret_ref;
18517 }
18518
18519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18520         LDKNodeAnnouncement this_ptr_conv;
18521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18522         this_ptr_conv.is_owned = false;
18523         LDKUnsignedNodeAnnouncement val_conv;
18524         val_conv.inner = (void*)(val & (~1));
18525         val_conv.is_owned = (val & 1) || (val == 0);
18526         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
18527         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
18528 }
18529
18530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
18531         LDKSignature signature_arg_ref;
18532         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18533         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18534         LDKUnsignedNodeAnnouncement contents_arg_conv;
18535         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18536         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18537         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
18538         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
18539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18541         uint64_t ret_ref = (uint64_t)ret_var.inner;
18542         if (ret_var.is_owned) {
18543                 ret_ref |= 1;
18544         }
18545         return ret_ref;
18546 }
18547
18548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18549         LDKNodeAnnouncement orig_conv;
18550         orig_conv.inner = (void*)(orig & (~1));
18551         orig_conv.is_owned = false;
18552         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
18553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18555         uint64_t ret_ref = (uint64_t)ret_var.inner;
18556         if (ret_var.is_owned) {
18557                 ret_ref |= 1;
18558         }
18559         return ret_ref;
18560 }
18561
18562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18563         LDKUnsignedChannelAnnouncement this_obj_conv;
18564         this_obj_conv.inner = (void*)(this_obj & (~1));
18565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18566         UnsignedChannelAnnouncement_free(this_obj_conv);
18567 }
18568
18569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
18570         LDKUnsignedChannelAnnouncement this_ptr_conv;
18571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18572         this_ptr_conv.is_owned = false;
18573         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
18574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18576         uint64_t ret_ref = (uint64_t)ret_var.inner;
18577         if (ret_var.is_owned) {
18578                 ret_ref |= 1;
18579         }
18580         return ret_ref;
18581 }
18582
18583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18584         LDKUnsignedChannelAnnouncement this_ptr_conv;
18585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18586         this_ptr_conv.is_owned = false;
18587         LDKChannelFeatures val_conv;
18588         val_conv.inner = (void*)(val & (~1));
18589         val_conv.is_owned = (val & 1) || (val == 0);
18590         val_conv = ChannelFeatures_clone(&val_conv);
18591         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
18592 }
18593
18594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18595         LDKUnsignedChannelAnnouncement this_ptr_conv;
18596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18597         this_ptr_conv.is_owned = false;
18598         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
18600         return ret_arr;
18601 }
18602
18603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18604         LDKUnsignedChannelAnnouncement this_ptr_conv;
18605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18606         this_ptr_conv.is_owned = false;
18607         LDKThirtyTwoBytes val_ref;
18608         CHECK((*env)->GetArrayLength(env, val) == 32);
18609         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18610         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
18611 }
18612
18613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18614         LDKUnsignedChannelAnnouncement this_ptr_conv;
18615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18616         this_ptr_conv.is_owned = false;
18617         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
18618         return ret_val;
18619 }
18620
18621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18622         LDKUnsignedChannelAnnouncement this_ptr_conv;
18623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18624         this_ptr_conv.is_owned = false;
18625         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
18626 }
18627
18628 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18629         LDKUnsignedChannelAnnouncement this_ptr_conv;
18630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18631         this_ptr_conv.is_owned = false;
18632         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
18634         return ret_arr;
18635 }
18636
18637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18638         LDKUnsignedChannelAnnouncement this_ptr_conv;
18639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18640         this_ptr_conv.is_owned = false;
18641         LDKPublicKey val_ref;
18642         CHECK((*env)->GetArrayLength(env, val) == 33);
18643         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18644         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
18645 }
18646
18647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18648         LDKUnsignedChannelAnnouncement this_ptr_conv;
18649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18650         this_ptr_conv.is_owned = false;
18651         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18652         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
18653         return ret_arr;
18654 }
18655
18656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18657         LDKUnsignedChannelAnnouncement this_ptr_conv;
18658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18659         this_ptr_conv.is_owned = false;
18660         LDKPublicKey val_ref;
18661         CHECK((*env)->GetArrayLength(env, val) == 33);
18662         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18663         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
18664 }
18665
18666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18667         LDKUnsignedChannelAnnouncement this_ptr_conv;
18668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18669         this_ptr_conv.is_owned = false;
18670         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
18672         return ret_arr;
18673 }
18674
18675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18676         LDKUnsignedChannelAnnouncement this_ptr_conv;
18677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18678         this_ptr_conv.is_owned = false;
18679         LDKPublicKey val_ref;
18680         CHECK((*env)->GetArrayLength(env, val) == 33);
18681         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18682         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
18683 }
18684
18685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18686         LDKUnsignedChannelAnnouncement this_ptr_conv;
18687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18688         this_ptr_conv.is_owned = false;
18689         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
18691         return ret_arr;
18692 }
18693
18694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18695         LDKUnsignedChannelAnnouncement this_ptr_conv;
18696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18697         this_ptr_conv.is_owned = false;
18698         LDKPublicKey val_ref;
18699         CHECK((*env)->GetArrayLength(env, val) == 33);
18700         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18701         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
18702 }
18703
18704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18705         LDKUnsignedChannelAnnouncement orig_conv;
18706         orig_conv.inner = (void*)(orig & (~1));
18707         orig_conv.is_owned = false;
18708         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
18709         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18710         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18711         uint64_t ret_ref = (uint64_t)ret_var.inner;
18712         if (ret_var.is_owned) {
18713                 ret_ref |= 1;
18714         }
18715         return ret_ref;
18716 }
18717
18718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18719         LDKChannelAnnouncement this_obj_conv;
18720         this_obj_conv.inner = (void*)(this_obj & (~1));
18721         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18722         ChannelAnnouncement_free(this_obj_conv);
18723 }
18724
18725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18726         LDKChannelAnnouncement this_ptr_conv;
18727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18728         this_ptr_conv.is_owned = false;
18729         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18730         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
18731         return ret_arr;
18732 }
18733
18734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18735         LDKChannelAnnouncement this_ptr_conv;
18736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18737         this_ptr_conv.is_owned = false;
18738         LDKSignature val_ref;
18739         CHECK((*env)->GetArrayLength(env, val) == 64);
18740         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18741         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
18742 }
18743
18744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18745         LDKChannelAnnouncement this_ptr_conv;
18746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18747         this_ptr_conv.is_owned = false;
18748         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
18750         return ret_arr;
18751 }
18752
18753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18754         LDKChannelAnnouncement this_ptr_conv;
18755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18756         this_ptr_conv.is_owned = false;
18757         LDKSignature val_ref;
18758         CHECK((*env)->GetArrayLength(env, val) == 64);
18759         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18760         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
18761 }
18762
18763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
18764         LDKChannelAnnouncement this_ptr_conv;
18765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18766         this_ptr_conv.is_owned = false;
18767         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
18769         return ret_arr;
18770 }
18771
18772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18773         LDKChannelAnnouncement this_ptr_conv;
18774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18775         this_ptr_conv.is_owned = false;
18776         LDKSignature val_ref;
18777         CHECK((*env)->GetArrayLength(env, val) == 64);
18778         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18779         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
18780 }
18781
18782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
18783         LDKChannelAnnouncement this_ptr_conv;
18784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18785         this_ptr_conv.is_owned = false;
18786         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
18788         return ret_arr;
18789 }
18790
18791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18792         LDKChannelAnnouncement this_ptr_conv;
18793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18794         this_ptr_conv.is_owned = false;
18795         LDKSignature val_ref;
18796         CHECK((*env)->GetArrayLength(env, val) == 64);
18797         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18798         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
18799 }
18800
18801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
18802         LDKChannelAnnouncement this_ptr_conv;
18803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18804         this_ptr_conv.is_owned = false;
18805         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
18806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18808         uint64_t ret_ref = (uint64_t)ret_var.inner;
18809         if (ret_var.is_owned) {
18810                 ret_ref |= 1;
18811         }
18812         return ret_ref;
18813 }
18814
18815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18816         LDKChannelAnnouncement this_ptr_conv;
18817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18818         this_ptr_conv.is_owned = false;
18819         LDKUnsignedChannelAnnouncement val_conv;
18820         val_conv.inner = (void*)(val & (~1));
18821         val_conv.is_owned = (val & 1) || (val == 0);
18822         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
18823         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
18824 }
18825
18826 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) {
18827         LDKSignature node_signature_1_arg_ref;
18828         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
18829         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
18830         LDKSignature node_signature_2_arg_ref;
18831         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
18832         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
18833         LDKSignature bitcoin_signature_1_arg_ref;
18834         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
18835         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
18836         LDKSignature bitcoin_signature_2_arg_ref;
18837         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
18838         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
18839         LDKUnsignedChannelAnnouncement contents_arg_conv;
18840         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18841         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18842         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
18843         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);
18844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18846         uint64_t ret_ref = (uint64_t)ret_var.inner;
18847         if (ret_var.is_owned) {
18848                 ret_ref |= 1;
18849         }
18850         return ret_ref;
18851 }
18852
18853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18854         LDKChannelAnnouncement orig_conv;
18855         orig_conv.inner = (void*)(orig & (~1));
18856         orig_conv.is_owned = false;
18857         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
18858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18860         uint64_t ret_ref = (uint64_t)ret_var.inner;
18861         if (ret_var.is_owned) {
18862                 ret_ref |= 1;
18863         }
18864         return ret_ref;
18865 }
18866
18867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18868         LDKUnsignedChannelUpdate this_obj_conv;
18869         this_obj_conv.inner = (void*)(this_obj & (~1));
18870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18871         UnsignedChannelUpdate_free(this_obj_conv);
18872 }
18873
18874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18875         LDKUnsignedChannelUpdate this_ptr_conv;
18876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18877         this_ptr_conv.is_owned = false;
18878         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18879         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
18880         return ret_arr;
18881 }
18882
18883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18884         LDKUnsignedChannelUpdate this_ptr_conv;
18885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18886         this_ptr_conv.is_owned = false;
18887         LDKThirtyTwoBytes val_ref;
18888         CHECK((*env)->GetArrayLength(env, val) == 32);
18889         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18890         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
18891 }
18892
18893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18894         LDKUnsignedChannelUpdate this_ptr_conv;
18895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18896         this_ptr_conv.is_owned = false;
18897         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
18898         return ret_val;
18899 }
18900
18901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18902         LDKUnsignedChannelUpdate this_ptr_conv;
18903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18904         this_ptr_conv.is_owned = false;
18905         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
18906 }
18907
18908 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
18909         LDKUnsignedChannelUpdate this_ptr_conv;
18910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18911         this_ptr_conv.is_owned = false;
18912         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
18913         return ret_val;
18914 }
18915
18916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18917         LDKUnsignedChannelUpdate this_ptr_conv;
18918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18919         this_ptr_conv.is_owned = false;
18920         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
18921 }
18922
18923 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
18924         LDKUnsignedChannelUpdate this_ptr_conv;
18925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18926         this_ptr_conv.is_owned = false;
18927         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
18928         return ret_val;
18929 }
18930
18931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
18932         LDKUnsignedChannelUpdate this_ptr_conv;
18933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18934         this_ptr_conv.is_owned = false;
18935         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
18936 }
18937
18938 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
18939         LDKUnsignedChannelUpdate this_ptr_conv;
18940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18941         this_ptr_conv.is_owned = false;
18942         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
18943         return ret_val;
18944 }
18945
18946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18947         LDKUnsignedChannelUpdate this_ptr_conv;
18948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18949         this_ptr_conv.is_owned = false;
18950         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
18951 }
18952
18953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18954         LDKUnsignedChannelUpdate this_ptr_conv;
18955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18956         this_ptr_conv.is_owned = false;
18957         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
18958         return ret_val;
18959 }
18960
18961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18962         LDKUnsignedChannelUpdate this_ptr_conv;
18963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18964         this_ptr_conv.is_owned = false;
18965         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
18966 }
18967
18968 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18969         LDKUnsignedChannelUpdate this_ptr_conv;
18970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18971         this_ptr_conv.is_owned = false;
18972         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
18973         return ret_val;
18974 }
18975
18976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18977         LDKUnsignedChannelUpdate this_ptr_conv;
18978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18979         this_ptr_conv.is_owned = false;
18980         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
18981 }
18982
18983 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
18984         LDKUnsignedChannelUpdate this_ptr_conv;
18985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18986         this_ptr_conv.is_owned = false;
18987         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
18988         return ret_val;
18989 }
18990
18991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18992         LDKUnsignedChannelUpdate this_ptr_conv;
18993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18994         this_ptr_conv.is_owned = false;
18995         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
18996 }
18997
18998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18999         LDKUnsignedChannelUpdate orig_conv;
19000         orig_conv.inner = (void*)(orig & (~1));
19001         orig_conv.is_owned = false;
19002         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19005         uint64_t ret_ref = (uint64_t)ret_var.inner;
19006         if (ret_var.is_owned) {
19007                 ret_ref |= 1;
19008         }
19009         return ret_ref;
19010 }
19011
19012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19013         LDKChannelUpdate this_obj_conv;
19014         this_obj_conv.inner = (void*)(this_obj & (~1));
19015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19016         ChannelUpdate_free(this_obj_conv);
19017 }
19018
19019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19020         LDKChannelUpdate this_ptr_conv;
19021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19022         this_ptr_conv.is_owned = false;
19023         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
19025         return ret_arr;
19026 }
19027
19028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19029         LDKChannelUpdate this_ptr_conv;
19030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19031         this_ptr_conv.is_owned = false;
19032         LDKSignature val_ref;
19033         CHECK((*env)->GetArrayLength(env, val) == 64);
19034         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19035         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19036 }
19037
19038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19039         LDKChannelUpdate this_ptr_conv;
19040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19041         this_ptr_conv.is_owned = false;
19042         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19045         uint64_t ret_ref = (uint64_t)ret_var.inner;
19046         if (ret_var.is_owned) {
19047                 ret_ref |= 1;
19048         }
19049         return ret_ref;
19050 }
19051
19052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19053         LDKChannelUpdate this_ptr_conv;
19054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19055         this_ptr_conv.is_owned = false;
19056         LDKUnsignedChannelUpdate val_conv;
19057         val_conv.inner = (void*)(val & (~1));
19058         val_conv.is_owned = (val & 1) || (val == 0);
19059         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19060         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19061 }
19062
19063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19064         LDKSignature signature_arg_ref;
19065         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19066         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19067         LDKUnsignedChannelUpdate contents_arg_conv;
19068         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19069         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19070         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19071         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19074         uint64_t ret_ref = (uint64_t)ret_var.inner;
19075         if (ret_var.is_owned) {
19076                 ret_ref |= 1;
19077         }
19078         return ret_ref;
19079 }
19080
19081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19082         LDKChannelUpdate orig_conv;
19083         orig_conv.inner = (void*)(orig & (~1));
19084         orig_conv.is_owned = false;
19085         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19088         uint64_t ret_ref = (uint64_t)ret_var.inner;
19089         if (ret_var.is_owned) {
19090                 ret_ref |= 1;
19091         }
19092         return ret_ref;
19093 }
19094
19095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19096         LDKQueryChannelRange this_obj_conv;
19097         this_obj_conv.inner = (void*)(this_obj & (~1));
19098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19099         QueryChannelRange_free(this_obj_conv);
19100 }
19101
19102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19103         LDKQueryChannelRange this_ptr_conv;
19104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19105         this_ptr_conv.is_owned = false;
19106         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19107         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
19108         return ret_arr;
19109 }
19110
19111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19112         LDKQueryChannelRange this_ptr_conv;
19113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19114         this_ptr_conv.is_owned = false;
19115         LDKThirtyTwoBytes val_ref;
19116         CHECK((*env)->GetArrayLength(env, val) == 32);
19117         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19118         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19119 }
19120
19121 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19122         LDKQueryChannelRange this_ptr_conv;
19123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19124         this_ptr_conv.is_owned = false;
19125         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19126         return ret_val;
19127 }
19128
19129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19130         LDKQueryChannelRange this_ptr_conv;
19131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19132         this_ptr_conv.is_owned = false;
19133         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19134 }
19135
19136 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19137         LDKQueryChannelRange this_ptr_conv;
19138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19139         this_ptr_conv.is_owned = false;
19140         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19141         return ret_val;
19142 }
19143
19144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19145         LDKQueryChannelRange this_ptr_conv;
19146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19147         this_ptr_conv.is_owned = false;
19148         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19149 }
19150
19151 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) {
19152         LDKThirtyTwoBytes chain_hash_arg_ref;
19153         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19154         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19155         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19158         uint64_t ret_ref = (uint64_t)ret_var.inner;
19159         if (ret_var.is_owned) {
19160                 ret_ref |= 1;
19161         }
19162         return ret_ref;
19163 }
19164
19165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19166         LDKQueryChannelRange orig_conv;
19167         orig_conv.inner = (void*)(orig & (~1));
19168         orig_conv.is_owned = false;
19169         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19172         uint64_t ret_ref = (uint64_t)ret_var.inner;
19173         if (ret_var.is_owned) {
19174                 ret_ref |= 1;
19175         }
19176         return ret_ref;
19177 }
19178
19179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19180         LDKReplyChannelRange this_obj_conv;
19181         this_obj_conv.inner = (void*)(this_obj & (~1));
19182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19183         ReplyChannelRange_free(this_obj_conv);
19184 }
19185
19186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19187         LDKReplyChannelRange this_ptr_conv;
19188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19189         this_ptr_conv.is_owned = false;
19190         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
19192         return ret_arr;
19193 }
19194
19195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19196         LDKReplyChannelRange this_ptr_conv;
19197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19198         this_ptr_conv.is_owned = false;
19199         LDKThirtyTwoBytes val_ref;
19200         CHECK((*env)->GetArrayLength(env, val) == 32);
19201         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19202         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19203 }
19204
19205 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
19206         LDKReplyChannelRange this_ptr_conv;
19207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19208         this_ptr_conv.is_owned = false;
19209         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19210         return ret_val;
19211 }
19212
19213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19214         LDKReplyChannelRange this_ptr_conv;
19215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19216         this_ptr_conv.is_owned = false;
19217         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19218 }
19219
19220 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
19221         LDKReplyChannelRange this_ptr_conv;
19222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19223         this_ptr_conv.is_owned = false;
19224         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19225         return ret_val;
19226 }
19227
19228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19229         LDKReplyChannelRange this_ptr_conv;
19230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19231         this_ptr_conv.is_owned = false;
19232         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19233 }
19234
19235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
19236         LDKReplyChannelRange this_ptr_conv;
19237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19238         this_ptr_conv.is_owned = false;
19239         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19240         return ret_val;
19241 }
19242
19243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19244         LDKReplyChannelRange this_ptr_conv;
19245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19246         this_ptr_conv.is_owned = false;
19247         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19248 }
19249
19250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19251         LDKReplyChannelRange this_ptr_conv;
19252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19253         this_ptr_conv.is_owned = false;
19254         LDKCVec_u64Z val_constr;
19255         val_constr.datalen = (*env)->GetArrayLength(env, val);
19256         if (val_constr.datalen > 0)
19257                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19258         else
19259                 val_constr.data = NULL;
19260         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19261         for (size_t g = 0; g < val_constr.datalen; g++) {
19262                 int64_t val_conv_6 = val_vals[g];
19263                 val_constr.data[g] = val_conv_6;
19264         }
19265         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19266         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19267 }
19268
19269 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) {
19270         LDKThirtyTwoBytes chain_hash_arg_ref;
19271         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19272         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19273         LDKCVec_u64Z short_channel_ids_arg_constr;
19274         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19275         if (short_channel_ids_arg_constr.datalen > 0)
19276                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19277         else
19278                 short_channel_ids_arg_constr.data = NULL;
19279         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19280         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19281                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19282                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19283         }
19284         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19285         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19288         uint64_t ret_ref = (uint64_t)ret_var.inner;
19289         if (ret_var.is_owned) {
19290                 ret_ref |= 1;
19291         }
19292         return ret_ref;
19293 }
19294
19295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19296         LDKReplyChannelRange orig_conv;
19297         orig_conv.inner = (void*)(orig & (~1));
19298         orig_conv.is_owned = false;
19299         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19302         uint64_t ret_ref = (uint64_t)ret_var.inner;
19303         if (ret_var.is_owned) {
19304                 ret_ref |= 1;
19305         }
19306         return ret_ref;
19307 }
19308
19309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19310         LDKQueryShortChannelIds this_obj_conv;
19311         this_obj_conv.inner = (void*)(this_obj & (~1));
19312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19313         QueryShortChannelIds_free(this_obj_conv);
19314 }
19315
19316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19317         LDKQueryShortChannelIds this_ptr_conv;
19318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19319         this_ptr_conv.is_owned = false;
19320         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
19322         return ret_arr;
19323 }
19324
19325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19326         LDKQueryShortChannelIds this_ptr_conv;
19327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19328         this_ptr_conv.is_owned = false;
19329         LDKThirtyTwoBytes val_ref;
19330         CHECK((*env)->GetArrayLength(env, val) == 32);
19331         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19332         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19333 }
19334
19335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19336         LDKQueryShortChannelIds this_ptr_conv;
19337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19338         this_ptr_conv.is_owned = false;
19339         LDKCVec_u64Z val_constr;
19340         val_constr.datalen = (*env)->GetArrayLength(env, val);
19341         if (val_constr.datalen > 0)
19342                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19343         else
19344                 val_constr.data = NULL;
19345         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19346         for (size_t g = 0; g < val_constr.datalen; g++) {
19347                 int64_t val_conv_6 = val_vals[g];
19348                 val_constr.data[g] = val_conv_6;
19349         }
19350         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19351         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19352 }
19353
19354 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) {
19355         LDKThirtyTwoBytes chain_hash_arg_ref;
19356         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19357         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19358         LDKCVec_u64Z short_channel_ids_arg_constr;
19359         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
19360         if (short_channel_ids_arg_constr.datalen > 0)
19361                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19362         else
19363                 short_channel_ids_arg_constr.data = NULL;
19364         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
19365         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
19366                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
19367                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
19368         }
19369         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
19370         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19373         uint64_t ret_ref = (uint64_t)ret_var.inner;
19374         if (ret_var.is_owned) {
19375                 ret_ref |= 1;
19376         }
19377         return ret_ref;
19378 }
19379
19380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19381         LDKQueryShortChannelIds orig_conv;
19382         orig_conv.inner = (void*)(orig & (~1));
19383         orig_conv.is_owned = false;
19384         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19387         uint64_t ret_ref = (uint64_t)ret_var.inner;
19388         if (ret_var.is_owned) {
19389                 ret_ref |= 1;
19390         }
19391         return ret_ref;
19392 }
19393
19394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19395         LDKReplyShortChannelIdsEnd this_obj_conv;
19396         this_obj_conv.inner = (void*)(this_obj & (~1));
19397         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19398         ReplyShortChannelIdsEnd_free(this_obj_conv);
19399 }
19400
19401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19402         LDKReplyShortChannelIdsEnd this_ptr_conv;
19403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19404         this_ptr_conv.is_owned = false;
19405         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
19407         return ret_arr;
19408 }
19409
19410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19411         LDKReplyShortChannelIdsEnd this_ptr_conv;
19412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19413         this_ptr_conv.is_owned = false;
19414         LDKThirtyTwoBytes val_ref;
19415         CHECK((*env)->GetArrayLength(env, val) == 32);
19416         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19417         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19418 }
19419
19420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
19421         LDKReplyShortChannelIdsEnd this_ptr_conv;
19422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19423         this_ptr_conv.is_owned = false;
19424         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
19425         return ret_val;
19426 }
19427
19428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
19429         LDKReplyShortChannelIdsEnd this_ptr_conv;
19430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19431         this_ptr_conv.is_owned = false;
19432         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
19433 }
19434
19435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
19436         LDKThirtyTwoBytes chain_hash_arg_ref;
19437         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19438         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19439         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
19440         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19441         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19442         uint64_t ret_ref = (uint64_t)ret_var.inner;
19443         if (ret_var.is_owned) {
19444                 ret_ref |= 1;
19445         }
19446         return ret_ref;
19447 }
19448
19449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19450         LDKReplyShortChannelIdsEnd orig_conv;
19451         orig_conv.inner = (void*)(orig & (~1));
19452         orig_conv.is_owned = false;
19453         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
19454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19456         uint64_t ret_ref = (uint64_t)ret_var.inner;
19457         if (ret_var.is_owned) {
19458                 ret_ref |= 1;
19459         }
19460         return ret_ref;
19461 }
19462
19463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19464         LDKGossipTimestampFilter this_obj_conv;
19465         this_obj_conv.inner = (void*)(this_obj & (~1));
19466         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19467         GossipTimestampFilter_free(this_obj_conv);
19468 }
19469
19470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19471         LDKGossipTimestampFilter this_ptr_conv;
19472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19473         this_ptr_conv.is_owned = false;
19474         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
19476         return ret_arr;
19477 }
19478
19479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19480         LDKGossipTimestampFilter this_ptr_conv;
19481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19482         this_ptr_conv.is_owned = false;
19483         LDKThirtyTwoBytes val_ref;
19484         CHECK((*env)->GetArrayLength(env, val) == 32);
19485         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19486         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
19487 }
19488
19489 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19490         LDKGossipTimestampFilter this_ptr_conv;
19491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19492         this_ptr_conv.is_owned = false;
19493         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
19494         return ret_val;
19495 }
19496
19497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19498         LDKGossipTimestampFilter this_ptr_conv;
19499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19500         this_ptr_conv.is_owned = false;
19501         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
19502 }
19503
19504 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
19505         LDKGossipTimestampFilter this_ptr_conv;
19506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19507         this_ptr_conv.is_owned = false;
19508         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
19509         return ret_val;
19510 }
19511
19512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19513         LDKGossipTimestampFilter this_ptr_conv;
19514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19515         this_ptr_conv.is_owned = false;
19516         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
19517 }
19518
19519 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) {
19520         LDKThirtyTwoBytes chain_hash_arg_ref;
19521         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
19522         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
19523         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
19524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19526         uint64_t ret_ref = (uint64_t)ret_var.inner;
19527         if (ret_var.is_owned) {
19528                 ret_ref |= 1;
19529         }
19530         return ret_ref;
19531 }
19532
19533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19534         LDKGossipTimestampFilter orig_conv;
19535         orig_conv.inner = (void*)(orig & (~1));
19536         orig_conv.is_owned = false;
19537         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
19538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19540         uint64_t ret_ref = (uint64_t)ret_var.inner;
19541         if (ret_var.is_owned) {
19542                 ret_ref |= 1;
19543         }
19544         return ret_ref;
19545 }
19546
19547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19548         if ((this_ptr & 1) != 0) return;
19549         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
19550         FREE((void*)this_ptr);
19551         ErrorAction_free(this_ptr_conv);
19552 }
19553
19554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19555         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
19556         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19557         *ret_copy = ErrorAction_clone(orig_conv);
19558         uint64_t ret_ref = (uint64_t)ret_copy;
19559         return ret_ref;
19560 }
19561
19562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19563         LDKLightningError this_obj_conv;
19564         this_obj_conv.inner = (void*)(this_obj & (~1));
19565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19566         LightningError_free(this_obj_conv);
19567 }
19568
19569 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
19570         LDKLightningError this_ptr_conv;
19571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19572         this_ptr_conv.is_owned = false;
19573         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
19574         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
19575         return ret_conv;
19576 }
19577
19578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
19579         LDKLightningError this_ptr_conv;
19580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19581         this_ptr_conv.is_owned = false;
19582         LDKStr val_conv = java_to_owned_str(env, val);
19583         LightningError_set_err(&this_ptr_conv, val_conv);
19584 }
19585
19586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
19587         LDKLightningError this_ptr_conv;
19588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19589         this_ptr_conv.is_owned = false;
19590         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19591         *ret_copy = LightningError_get_action(&this_ptr_conv);
19592         uint64_t ret_ref = (uint64_t)ret_copy;
19593         return ret_ref;
19594 }
19595
19596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19597         LDKLightningError this_ptr_conv;
19598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19599         this_ptr_conv.is_owned = false;
19600         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
19601         LightningError_set_action(&this_ptr_conv, val_conv);
19602 }
19603
19604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
19605         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
19606         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
19607         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
19608         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19609         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19610         uint64_t ret_ref = (uint64_t)ret_var.inner;
19611         if (ret_var.is_owned) {
19612                 ret_ref |= 1;
19613         }
19614         return ret_ref;
19615 }
19616
19617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19618         LDKLightningError orig_conv;
19619         orig_conv.inner = (void*)(orig & (~1));
19620         orig_conv.is_owned = false;
19621         LDKLightningError ret_var = LightningError_clone(&orig_conv);
19622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19624         uint64_t ret_ref = (uint64_t)ret_var.inner;
19625         if (ret_var.is_owned) {
19626                 ret_ref |= 1;
19627         }
19628         return ret_ref;
19629 }
19630
19631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19632         LDKCommitmentUpdate this_obj_conv;
19633         this_obj_conv.inner = (void*)(this_obj & (~1));
19634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19635         CommitmentUpdate_free(this_obj_conv);
19636 }
19637
19638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19639         LDKCommitmentUpdate this_ptr_conv;
19640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19641         this_ptr_conv.is_owned = false;
19642         LDKCVec_UpdateAddHTLCZ val_constr;
19643         val_constr.datalen = (*env)->GetArrayLength(env, val);
19644         if (val_constr.datalen > 0)
19645                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19646         else
19647                 val_constr.data = NULL;
19648         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19649         for (size_t p = 0; p < val_constr.datalen; p++) {
19650                 int64_t val_conv_15 = val_vals[p];
19651                 LDKUpdateAddHTLC val_conv_15_conv;
19652                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
19653                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
19654                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
19655                 val_constr.data[p] = val_conv_15_conv;
19656         }
19657         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19658         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
19659 }
19660
19661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19662         LDKCommitmentUpdate this_ptr_conv;
19663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19664         this_ptr_conv.is_owned = false;
19665         LDKCVec_UpdateFulfillHTLCZ val_constr;
19666         val_constr.datalen = (*env)->GetArrayLength(env, val);
19667         if (val_constr.datalen > 0)
19668                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19669         else
19670                 val_constr.data = NULL;
19671         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19672         for (size_t t = 0; t < val_constr.datalen; t++) {
19673                 int64_t val_conv_19 = val_vals[t];
19674                 LDKUpdateFulfillHTLC val_conv_19_conv;
19675                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
19676                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
19677                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
19678                 val_constr.data[t] = val_conv_19_conv;
19679         }
19680         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19681         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
19682 }
19683
19684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19685         LDKCommitmentUpdate this_ptr_conv;
19686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19687         this_ptr_conv.is_owned = false;
19688         LDKCVec_UpdateFailHTLCZ val_constr;
19689         val_constr.datalen = (*env)->GetArrayLength(env, val);
19690         if (val_constr.datalen > 0)
19691                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19692         else
19693                 val_constr.data = NULL;
19694         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19695         for (size_t q = 0; q < val_constr.datalen; q++) {
19696                 int64_t val_conv_16 = val_vals[q];
19697                 LDKUpdateFailHTLC val_conv_16_conv;
19698                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
19699                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
19700                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
19701                 val_constr.data[q] = val_conv_16_conv;
19702         }
19703         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19704         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
19705 }
19706
19707 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) {
19708         LDKCommitmentUpdate this_ptr_conv;
19709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19710         this_ptr_conv.is_owned = false;
19711         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
19712         val_constr.datalen = (*env)->GetArrayLength(env, val);
19713         if (val_constr.datalen > 0)
19714                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19715         else
19716                 val_constr.data = NULL;
19717         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19718         for (size_t z = 0; z < val_constr.datalen; z++) {
19719                 int64_t val_conv_25 = val_vals[z];
19720                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
19721                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
19722                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
19723                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
19724                 val_constr.data[z] = val_conv_25_conv;
19725         }
19726         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19727         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
19728 }
19729
19730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
19731         LDKCommitmentUpdate this_ptr_conv;
19732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19733         this_ptr_conv.is_owned = false;
19734         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
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 void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19745         LDKCommitmentUpdate this_ptr_conv;
19746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19747         this_ptr_conv.is_owned = false;
19748         LDKUpdateFee val_conv;
19749         val_conv.inner = (void*)(val & (~1));
19750         val_conv.is_owned = (val & 1) || (val == 0);
19751         val_conv = UpdateFee_clone(&val_conv);
19752         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
19753 }
19754
19755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
19756         LDKCommitmentUpdate this_ptr_conv;
19757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19758         this_ptr_conv.is_owned = false;
19759         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
19760         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19761         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19762         uint64_t ret_ref = (uint64_t)ret_var.inner;
19763         if (ret_var.is_owned) {
19764                 ret_ref |= 1;
19765         }
19766         return ret_ref;
19767 }
19768
19769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19770         LDKCommitmentUpdate this_ptr_conv;
19771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19772         this_ptr_conv.is_owned = false;
19773         LDKCommitmentSigned val_conv;
19774         val_conv.inner = (void*)(val & (~1));
19775         val_conv.is_owned = (val & 1) || (val == 0);
19776         val_conv = CommitmentSigned_clone(&val_conv);
19777         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
19778 }
19779
19780 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) {
19781         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
19782         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
19783         if (update_add_htlcs_arg_constr.datalen > 0)
19784                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19785         else
19786                 update_add_htlcs_arg_constr.data = NULL;
19787         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
19788         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
19789                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
19790                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
19791                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
19792                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
19793                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
19794                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
19795         }
19796         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
19797         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
19798         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
19799         if (update_fulfill_htlcs_arg_constr.datalen > 0)
19800                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19801         else
19802                 update_fulfill_htlcs_arg_constr.data = NULL;
19803         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
19804         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
19805                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
19806                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
19807                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
19808                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
19809                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
19810                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
19811         }
19812         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
19813         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
19814         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
19815         if (update_fail_htlcs_arg_constr.datalen > 0)
19816                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19817         else
19818                 update_fail_htlcs_arg_constr.data = NULL;
19819         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
19820         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
19821                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
19822                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
19823                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
19824                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
19825                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
19826                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
19827         }
19828         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
19829         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
19830         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
19831         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
19832                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19833         else
19834                 update_fail_malformed_htlcs_arg_constr.data = NULL;
19835         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
19836         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
19837                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
19838                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
19839                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
19840                 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);
19841                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
19842                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
19843         }
19844         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
19845         LDKUpdateFee update_fee_arg_conv;
19846         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
19847         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
19848         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
19849         LDKCommitmentSigned commitment_signed_arg_conv;
19850         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
19851         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
19852         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
19853         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);
19854         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19855         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19856         uint64_t ret_ref = (uint64_t)ret_var.inner;
19857         if (ret_var.is_owned) {
19858                 ret_ref |= 1;
19859         }
19860         return ret_ref;
19861 }
19862
19863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19864         LDKCommitmentUpdate orig_conv;
19865         orig_conv.inner = (void*)(orig & (~1));
19866         orig_conv.is_owned = false;
19867         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
19868         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19869         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19870         uint64_t ret_ref = (uint64_t)ret_var.inner;
19871         if (ret_var.is_owned) {
19872                 ret_ref |= 1;
19873         }
19874         return ret_ref;
19875 }
19876
19877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19878         if ((this_ptr & 1) != 0) return;
19879         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
19880         FREE((void*)this_ptr);
19881         HTLCFailChannelUpdate_free(this_ptr_conv);
19882 }
19883
19884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19885         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
19886         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
19887         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
19888         uint64_t ret_ref = (uint64_t)ret_copy;
19889         return ret_ref;
19890 }
19891
19892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19893         if ((this_ptr & 1) != 0) return;
19894         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
19895         FREE((void*)this_ptr);
19896         ChannelMessageHandler_free(this_ptr_conv);
19897 }
19898
19899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19900         if ((this_ptr & 1) != 0) return;
19901         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
19902         FREE((void*)this_ptr);
19903         RoutingMessageHandler_free(this_ptr_conv);
19904 }
19905
19906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
19907         LDKAcceptChannel obj_conv;
19908         obj_conv.inner = (void*)(obj & (~1));
19909         obj_conv.is_owned = false;
19910         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
19911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19913         CVec_u8Z_free(ret_var);
19914         return ret_arr;
19915 }
19916
19917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19918         LDKu8slice ser_ref;
19919         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19920         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19921         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19922         *ret_conv = AcceptChannel_read(ser_ref);
19923         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19924         return (uint64_t)ret_conv;
19925 }
19926
19927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
19928         LDKAnnouncementSignatures obj_conv;
19929         obj_conv.inner = (void*)(obj & (~1));
19930         obj_conv.is_owned = false;
19931         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
19932         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19933         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19934         CVec_u8Z_free(ret_var);
19935         return ret_arr;
19936 }
19937
19938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19939         LDKu8slice ser_ref;
19940         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19941         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19942         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19943         *ret_conv = AnnouncementSignatures_read(ser_ref);
19944         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19945         return (uint64_t)ret_conv;
19946 }
19947
19948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
19949         LDKChannelReestablish obj_conv;
19950         obj_conv.inner = (void*)(obj & (~1));
19951         obj_conv.is_owned = false;
19952         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
19953         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19954         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19955         CVec_u8Z_free(ret_var);
19956         return ret_arr;
19957 }
19958
19959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19960         LDKu8slice ser_ref;
19961         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19962         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19963         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19964         *ret_conv = ChannelReestablish_read(ser_ref);
19965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19966         return (uint64_t)ret_conv;
19967 }
19968
19969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
19970         LDKClosingSigned obj_conv;
19971         obj_conv.inner = (void*)(obj & (~1));
19972         obj_conv.is_owned = false;
19973         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
19974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19976         CVec_u8Z_free(ret_var);
19977         return ret_arr;
19978 }
19979
19980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19981         LDKu8slice ser_ref;
19982         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19983         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19984         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19985         *ret_conv = ClosingSigned_read(ser_ref);
19986         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19987         return (uint64_t)ret_conv;
19988 }
19989
19990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
19991         LDKCommitmentSigned obj_conv;
19992         obj_conv.inner = (void*)(obj & (~1));
19993         obj_conv.is_owned = false;
19994         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
19995         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19996         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19997         CVec_u8Z_free(ret_var);
19998         return ret_arr;
19999 }
20000
20001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20002         LDKu8slice ser_ref;
20003         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20004         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20005         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20006         *ret_conv = CommitmentSigned_read(ser_ref);
20007         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20008         return (uint64_t)ret_conv;
20009 }
20010
20011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
20012         LDKFundingCreated obj_conv;
20013         obj_conv.inner = (void*)(obj & (~1));
20014         obj_conv.is_owned = false;
20015         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20018         CVec_u8Z_free(ret_var);
20019         return ret_arr;
20020 }
20021
20022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20023         LDKu8slice ser_ref;
20024         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20025         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20026         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20027         *ret_conv = FundingCreated_read(ser_ref);
20028         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20029         return (uint64_t)ret_conv;
20030 }
20031
20032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
20033         LDKFundingSigned obj_conv;
20034         obj_conv.inner = (void*)(obj & (~1));
20035         obj_conv.is_owned = false;
20036         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20037         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20038         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20039         CVec_u8Z_free(ret_var);
20040         return ret_arr;
20041 }
20042
20043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20044         LDKu8slice ser_ref;
20045         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20046         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20047         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20048         *ret_conv = FundingSigned_read(ser_ref);
20049         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20050         return (uint64_t)ret_conv;
20051 }
20052
20053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
20054         LDKFundingLocked obj_conv;
20055         obj_conv.inner = (void*)(obj & (~1));
20056         obj_conv.is_owned = false;
20057         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20058         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20059         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20060         CVec_u8Z_free(ret_var);
20061         return ret_arr;
20062 }
20063
20064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20065         LDKu8slice ser_ref;
20066         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20067         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20068         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20069         *ret_conv = FundingLocked_read(ser_ref);
20070         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20071         return (uint64_t)ret_conv;
20072 }
20073
20074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
20075         LDKInit obj_conv;
20076         obj_conv.inner = (void*)(obj & (~1));
20077         obj_conv.is_owned = false;
20078         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20079         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20080         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20081         CVec_u8Z_free(ret_var);
20082         return ret_arr;
20083 }
20084
20085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20086         LDKu8slice ser_ref;
20087         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20088         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20089         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20090         *ret_conv = Init_read(ser_ref);
20091         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20092         return (uint64_t)ret_conv;
20093 }
20094
20095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
20096         LDKOpenChannel obj_conv;
20097         obj_conv.inner = (void*)(obj & (~1));
20098         obj_conv.is_owned = false;
20099         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20100         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20101         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20102         CVec_u8Z_free(ret_var);
20103         return ret_arr;
20104 }
20105
20106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20107         LDKu8slice ser_ref;
20108         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20109         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20110         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20111         *ret_conv = OpenChannel_read(ser_ref);
20112         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20113         return (uint64_t)ret_conv;
20114 }
20115
20116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
20117         LDKRevokeAndACK obj_conv;
20118         obj_conv.inner = (void*)(obj & (~1));
20119         obj_conv.is_owned = false;
20120         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20123         CVec_u8Z_free(ret_var);
20124         return ret_arr;
20125 }
20126
20127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20128         LDKu8slice ser_ref;
20129         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20130         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20131         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20132         *ret_conv = RevokeAndACK_read(ser_ref);
20133         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20134         return (uint64_t)ret_conv;
20135 }
20136
20137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
20138         LDKShutdown obj_conv;
20139         obj_conv.inner = (void*)(obj & (~1));
20140         obj_conv.is_owned = false;
20141         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20144         CVec_u8Z_free(ret_var);
20145         return ret_arr;
20146 }
20147
20148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20149         LDKu8slice ser_ref;
20150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20152         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20153         *ret_conv = Shutdown_read(ser_ref);
20154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20155         return (uint64_t)ret_conv;
20156 }
20157
20158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20159         LDKUpdateFailHTLC obj_conv;
20160         obj_conv.inner = (void*)(obj & (~1));
20161         obj_conv.is_owned = false;
20162         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20165         CVec_u8Z_free(ret_var);
20166         return ret_arr;
20167 }
20168
20169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20170         LDKu8slice ser_ref;
20171         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20172         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20173         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20174         *ret_conv = UpdateFailHTLC_read(ser_ref);
20175         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20176         return (uint64_t)ret_conv;
20177 }
20178
20179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20180         LDKUpdateFailMalformedHTLC obj_conv;
20181         obj_conv.inner = (void*)(obj & (~1));
20182         obj_conv.is_owned = false;
20183         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20184         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20185         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20186         CVec_u8Z_free(ret_var);
20187         return ret_arr;
20188 }
20189
20190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20191         LDKu8slice ser_ref;
20192         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20193         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20194         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20195         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20196         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20197         return (uint64_t)ret_conv;
20198 }
20199
20200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
20201         LDKUpdateFee obj_conv;
20202         obj_conv.inner = (void*)(obj & (~1));
20203         obj_conv.is_owned = false;
20204         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20205         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20206         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20207         CVec_u8Z_free(ret_var);
20208         return ret_arr;
20209 }
20210
20211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20212         LDKu8slice ser_ref;
20213         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20214         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20215         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20216         *ret_conv = UpdateFee_read(ser_ref);
20217         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20218         return (uint64_t)ret_conv;
20219 }
20220
20221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20222         LDKUpdateFulfillHTLC obj_conv;
20223         obj_conv.inner = (void*)(obj & (~1));
20224         obj_conv.is_owned = false;
20225         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20226         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20227         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20228         CVec_u8Z_free(ret_var);
20229         return ret_arr;
20230 }
20231
20232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20233         LDKu8slice ser_ref;
20234         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20235         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20236         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20237         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20238         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20239         return (uint64_t)ret_conv;
20240 }
20241
20242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
20243         LDKUpdateAddHTLC obj_conv;
20244         obj_conv.inner = (void*)(obj & (~1));
20245         obj_conv.is_owned = false;
20246         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20247         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20248         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20249         CVec_u8Z_free(ret_var);
20250         return ret_arr;
20251 }
20252
20253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20254         LDKu8slice ser_ref;
20255         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20256         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20257         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20258         *ret_conv = UpdateAddHTLC_read(ser_ref);
20259         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20260         return (uint64_t)ret_conv;
20261 }
20262
20263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
20264         LDKPing obj_conv;
20265         obj_conv.inner = (void*)(obj & (~1));
20266         obj_conv.is_owned = false;
20267         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20268         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20269         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20270         CVec_u8Z_free(ret_var);
20271         return ret_arr;
20272 }
20273
20274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20275         LDKu8slice ser_ref;
20276         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20277         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20278         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20279         *ret_conv = Ping_read(ser_ref);
20280         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20281         return (uint64_t)ret_conv;
20282 }
20283
20284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
20285         LDKPong obj_conv;
20286         obj_conv.inner = (void*)(obj & (~1));
20287         obj_conv.is_owned = false;
20288         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20291         CVec_u8Z_free(ret_var);
20292         return ret_arr;
20293 }
20294
20295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20296         LDKu8slice ser_ref;
20297         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20298         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20299         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20300         *ret_conv = Pong_read(ser_ref);
20301         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20302         return (uint64_t)ret_conv;
20303 }
20304
20305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20306         LDKUnsignedChannelAnnouncement obj_conv;
20307         obj_conv.inner = (void*)(obj & (~1));
20308         obj_conv.is_owned = false;
20309         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20310         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20311         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20312         CVec_u8Z_free(ret_var);
20313         return ret_arr;
20314 }
20315
20316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20317         LDKu8slice ser_ref;
20318         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20319         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20320         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20321         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20322         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20323         return (uint64_t)ret_conv;
20324 }
20325
20326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20327         LDKChannelAnnouncement obj_conv;
20328         obj_conv.inner = (void*)(obj & (~1));
20329         obj_conv.is_owned = false;
20330         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20331         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20332         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20333         CVec_u8Z_free(ret_var);
20334         return ret_arr;
20335 }
20336
20337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20338         LDKu8slice ser_ref;
20339         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20340         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20341         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20342         *ret_conv = ChannelAnnouncement_read(ser_ref);
20343         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20344         return (uint64_t)ret_conv;
20345 }
20346
20347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20348         LDKUnsignedChannelUpdate obj_conv;
20349         obj_conv.inner = (void*)(obj & (~1));
20350         obj_conv.is_owned = false;
20351         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20354         CVec_u8Z_free(ret_var);
20355         return ret_arr;
20356 }
20357
20358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20359         LDKu8slice ser_ref;
20360         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20361         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20362         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20363         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20364         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20365         return (uint64_t)ret_conv;
20366 }
20367
20368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
20369         LDKChannelUpdate obj_conv;
20370         obj_conv.inner = (void*)(obj & (~1));
20371         obj_conv.is_owned = false;
20372         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20373         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20374         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20375         CVec_u8Z_free(ret_var);
20376         return ret_arr;
20377 }
20378
20379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20380         LDKu8slice ser_ref;
20381         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20382         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20383         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20384         *ret_conv = ChannelUpdate_read(ser_ref);
20385         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20386         return (uint64_t)ret_conv;
20387 }
20388
20389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
20390         LDKErrorMessage obj_conv;
20391         obj_conv.inner = (void*)(obj & (~1));
20392         obj_conv.is_owned = false;
20393         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20396         CVec_u8Z_free(ret_var);
20397         return ret_arr;
20398 }
20399
20400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20401         LDKu8slice ser_ref;
20402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20404         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20405         *ret_conv = ErrorMessage_read(ser_ref);
20406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20407         return (uint64_t)ret_conv;
20408 }
20409
20410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20411         LDKUnsignedNodeAnnouncement obj_conv;
20412         obj_conv.inner = (void*)(obj & (~1));
20413         obj_conv.is_owned = false;
20414         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20415         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20416         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20417         CVec_u8Z_free(ret_var);
20418         return ret_arr;
20419 }
20420
20421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20422         LDKu8slice ser_ref;
20423         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20424         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20425         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20426         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
20427         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20428         return (uint64_t)ret_conv;
20429 }
20430
20431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
20432         LDKNodeAnnouncement obj_conv;
20433         obj_conv.inner = (void*)(obj & (~1));
20434         obj_conv.is_owned = false;
20435         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
20436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20438         CVec_u8Z_free(ret_var);
20439         return ret_arr;
20440 }
20441
20442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20443         LDKu8slice ser_ref;
20444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20446         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20447         *ret_conv = NodeAnnouncement_read(ser_ref);
20448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20449         return (uint64_t)ret_conv;
20450 }
20451
20452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20453         LDKu8slice ser_ref;
20454         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20455         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20456         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20457         *ret_conv = QueryShortChannelIds_read(ser_ref);
20458         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20459         return (uint64_t)ret_conv;
20460 }
20461
20462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
20463         LDKQueryShortChannelIds obj_conv;
20464         obj_conv.inner = (void*)(obj & (~1));
20465         obj_conv.is_owned = false;
20466         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
20467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20469         CVec_u8Z_free(ret_var);
20470         return ret_arr;
20471 }
20472
20473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20474         LDKu8slice ser_ref;
20475         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20476         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20477         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20478         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
20479         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20480         return (uint64_t)ret_conv;
20481 }
20482
20483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
20484         LDKReplyShortChannelIdsEnd obj_conv;
20485         obj_conv.inner = (void*)(obj & (~1));
20486         obj_conv.is_owned = false;
20487         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
20488         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20489         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20490         CVec_u8Z_free(ret_var);
20491         return ret_arr;
20492 }
20493
20494 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
20495         LDKQueryChannelRange this_arg_conv;
20496         this_arg_conv.inner = (void*)(this_arg & (~1));
20497         this_arg_conv.is_owned = false;
20498         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
20499         return ret_val;
20500 }
20501
20502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20503         LDKu8slice ser_ref;
20504         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20505         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20506         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20507         *ret_conv = QueryChannelRange_read(ser_ref);
20508         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20509         return (uint64_t)ret_conv;
20510 }
20511
20512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
20513         LDKQueryChannelRange obj_conv;
20514         obj_conv.inner = (void*)(obj & (~1));
20515         obj_conv.is_owned = false;
20516         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
20517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20519         CVec_u8Z_free(ret_var);
20520         return ret_arr;
20521 }
20522
20523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20524         LDKu8slice ser_ref;
20525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20527         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20528         *ret_conv = ReplyChannelRange_read(ser_ref);
20529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20530         return (uint64_t)ret_conv;
20531 }
20532
20533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
20534         LDKReplyChannelRange obj_conv;
20535         obj_conv.inner = (void*)(obj & (~1));
20536         obj_conv.is_owned = false;
20537         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
20538         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20539         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20540         CVec_u8Z_free(ret_var);
20541         return ret_arr;
20542 }
20543
20544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20545         LDKu8slice ser_ref;
20546         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20547         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20548         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20549         *ret_conv = GossipTimestampFilter_read(ser_ref);
20550         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20551         return (uint64_t)ret_conv;
20552 }
20553
20554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
20555         LDKGossipTimestampFilter obj_conv;
20556         obj_conv.inner = (void*)(obj & (~1));
20557         obj_conv.is_owned = false;
20558         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
20559         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20560         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20561         CVec_u8Z_free(ret_var);
20562         return ret_arr;
20563 }
20564
20565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20566         LDKIgnoringMessageHandler this_obj_conv;
20567         this_obj_conv.inner = (void*)(this_obj & (~1));
20568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20569         IgnoringMessageHandler_free(this_obj_conv);
20570 }
20571
20572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
20573         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
20574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20576         uint64_t ret_ref = (uint64_t)ret_var.inner;
20577         if (ret_var.is_owned) {
20578                 ret_ref |= 1;
20579         }
20580         return ret_ref;
20581 }
20582
20583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20584         LDKIgnoringMessageHandler this_arg_conv;
20585         this_arg_conv.inner = (void*)(this_arg & (~1));
20586         this_arg_conv.is_owned = false;
20587         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20588         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20589         return (uint64_t)ret;
20590 }
20591
20592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20593         LDKIgnoringMessageHandler this_arg_conv;
20594         this_arg_conv.inner = (void*)(this_arg & (~1));
20595         this_arg_conv.is_owned = false;
20596         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20597         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
20598         return (uint64_t)ret;
20599 }
20600
20601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20602         LDKErroringMessageHandler this_obj_conv;
20603         this_obj_conv.inner = (void*)(this_obj & (~1));
20604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20605         ErroringMessageHandler_free(this_obj_conv);
20606 }
20607
20608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
20609         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
20610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20612         uint64_t ret_ref = (uint64_t)ret_var.inner;
20613         if (ret_var.is_owned) {
20614                 ret_ref |= 1;
20615         }
20616         return ret_ref;
20617 }
20618
20619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
20620         LDKErroringMessageHandler this_arg_conv;
20621         this_arg_conv.inner = (void*)(this_arg & (~1));
20622         this_arg_conv.is_owned = false;
20623         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20624         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20625         return (uint64_t)ret;
20626 }
20627
20628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
20629         LDKErroringMessageHandler this_arg_conv;
20630         this_arg_conv.inner = (void*)(this_arg & (~1));
20631         this_arg_conv.is_owned = false;
20632         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
20633         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
20634         return (uint64_t)ret;
20635 }
20636
20637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20638         LDKMessageHandler this_obj_conv;
20639         this_obj_conv.inner = (void*)(this_obj & (~1));
20640         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20641         MessageHandler_free(this_obj_conv);
20642 }
20643
20644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
20645         LDKMessageHandler this_ptr_conv;
20646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20647         this_ptr_conv.is_owned = false;
20648         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
20649         return ret_ret;
20650 }
20651
20652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20653         LDKMessageHandler this_ptr_conv;
20654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20655         this_ptr_conv.is_owned = false;
20656         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
20657         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
20658                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20659                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
20660         }
20661         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
20662 }
20663
20664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
20665         LDKMessageHandler this_ptr_conv;
20666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20667         this_ptr_conv.is_owned = false;
20668         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
20669         return ret_ret;
20670 }
20671
20672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20673         LDKMessageHandler this_ptr_conv;
20674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20675         this_ptr_conv.is_owned = false;
20676         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
20677         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
20678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20679                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
20680         }
20681         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
20682 }
20683
20684 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) {
20685         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
20686         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
20687                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20688                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
20689         }
20690         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
20691         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
20692                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20693                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
20694         }
20695         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
20696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20698         uint64_t ret_ref = (uint64_t)ret_var.inner;
20699         if (ret_var.is_owned) {
20700                 ret_ref |= 1;
20701         }
20702         return ret_ref;
20703 }
20704
20705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20706         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
20707         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
20708         *ret = SocketDescriptor_clone(orig_conv);
20709         return (uint64_t)ret;
20710 }
20711
20712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20713         if ((this_ptr & 1) != 0) return;
20714         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
20715         FREE((void*)this_ptr);
20716         SocketDescriptor_free(this_ptr_conv);
20717 }
20718
20719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20720         LDKPeerHandleError this_obj_conv;
20721         this_obj_conv.inner = (void*)(this_obj & (~1));
20722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20723         PeerHandleError_free(this_obj_conv);
20724 }
20725
20726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
20727         LDKPeerHandleError this_ptr_conv;
20728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20729         this_ptr_conv.is_owned = false;
20730         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
20731         return ret_val;
20732 }
20733
20734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20735         LDKPeerHandleError this_ptr_conv;
20736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20737         this_ptr_conv.is_owned = false;
20738         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
20739 }
20740
20741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
20742         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
20743         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20744         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20745         uint64_t ret_ref = (uint64_t)ret_var.inner;
20746         if (ret_var.is_owned) {
20747                 ret_ref |= 1;
20748         }
20749         return ret_ref;
20750 }
20751
20752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20753         LDKPeerHandleError orig_conv;
20754         orig_conv.inner = (void*)(orig & (~1));
20755         orig_conv.is_owned = false;
20756         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_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 void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20767         LDKPeerManager this_obj_conv;
20768         this_obj_conv.inner = (void*)(this_obj & (~1));
20769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20770         PeerManager_free(this_obj_conv);
20771 }
20772
20773 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) {
20774         LDKMessageHandler message_handler_conv;
20775         message_handler_conv.inner = (void*)(message_handler & (~1));
20776         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
20777         // Warning: we need a move here but no clone is available for LDKMessageHandler
20778         LDKSecretKey our_node_secret_ref;
20779         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
20780         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
20781         unsigned char ephemeral_random_data_arr[32];
20782         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
20783         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
20784         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
20785         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20786         if (logger_conv.free == LDKLogger_JCalls_free) {
20787                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20788                 LDKLogger_JCalls_clone(logger_conv.this_arg);
20789         }
20790         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
20791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20793         uint64_t ret_ref = (uint64_t)ret_var.inner;
20794         if (ret_var.is_owned) {
20795                 ret_ref |= 1;
20796         }
20797         return ret_ref;
20798 }
20799
20800 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
20801         LDKPeerManager this_arg_conv;
20802         this_arg_conv.inner = (void*)(this_arg & (~1));
20803         this_arg_conv.is_owned = false;
20804         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
20805         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
20806         ;
20807         for (size_t i = 0; i < ret_var.datalen; i++) {
20808                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
20809                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
20810                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
20811         }
20812         FREE(ret_var.data);
20813         return ret_arr;
20814 }
20815
20816 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) {
20817         LDKPeerManager this_arg_conv;
20818         this_arg_conv.inner = (void*)(this_arg & (~1));
20819         this_arg_conv.is_owned = false;
20820         LDKPublicKey their_node_id_ref;
20821         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
20822         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
20823         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20824         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
20825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20826                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
20827         }
20828         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20829         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
20830         return (uint64_t)ret_conv;
20831 }
20832
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
20834         LDKPeerManager this_arg_conv;
20835         this_arg_conv.inner = (void*)(this_arg & (~1));
20836         this_arg_conv.is_owned = false;
20837         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20838         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
20839                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20840                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
20841         }
20842         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20843         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
20844         return (uint64_t)ret_conv;
20845 }
20846
20847 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) {
20848         LDKPeerManager this_arg_conv;
20849         this_arg_conv.inner = (void*)(this_arg & (~1));
20850         this_arg_conv.is_owned = false;
20851         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20852         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20853         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
20854         return (uint64_t)ret_conv;
20855 }
20856
20857 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) {
20858         LDKPeerManager this_arg_conv;
20859         this_arg_conv.inner = (void*)(this_arg & (~1));
20860         this_arg_conv.is_owned = false;
20861         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
20862         LDKu8slice data_ref;
20863         data_ref.datalen = (*env)->GetArrayLength(env, data);
20864         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
20865         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20866         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
20867         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
20868         return (uint64_t)ret_conv;
20869 }
20870
20871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
20872         LDKPeerManager this_arg_conv;
20873         this_arg_conv.inner = (void*)(this_arg & (~1));
20874         this_arg_conv.is_owned = false;
20875         PeerManager_process_events(&this_arg_conv);
20876 }
20877
20878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
20879         LDKPeerManager this_arg_conv;
20880         this_arg_conv.inner = (void*)(this_arg & (~1));
20881         this_arg_conv.is_owned = false;
20882         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20883         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
20884 }
20885
20886 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) {
20887         LDKPeerManager this_arg_conv;
20888         this_arg_conv.inner = (void*)(this_arg & (~1));
20889         this_arg_conv.is_owned = false;
20890         LDKPublicKey node_id_ref;
20891         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20892         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20893         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
20894 }
20895
20896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
20897         LDKPeerManager this_arg_conv;
20898         this_arg_conv.inner = (void*)(this_arg & (~1));
20899         this_arg_conv.is_owned = false;
20900         PeerManager_timer_tick_occurred(&this_arg_conv);
20901 }
20902
20903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
20904         unsigned char commitment_seed_arr[32];
20905         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
20906         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
20907         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
20908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
20910         return ret_arr;
20911 }
20912
20913 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) {
20914         LDKPublicKey per_commitment_point_ref;
20915         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20916         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20917         unsigned char base_secret_arr[32];
20918         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
20919         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
20920         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
20921         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
20922         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
20923         return (uint64_t)ret_conv;
20924 }
20925
20926 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) {
20927         LDKPublicKey per_commitment_point_ref;
20928         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20929         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20930         LDKPublicKey base_point_ref;
20931         CHECK((*env)->GetArrayLength(env, base_point) == 33);
20932         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
20933         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20934         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
20935         return (uint64_t)ret_conv;
20936 }
20937
20938 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) {
20939         unsigned char per_commitment_secret_arr[32];
20940         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
20941         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
20942         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
20943         unsigned char countersignatory_revocation_base_secret_arr[32];
20944         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
20945         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
20946         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
20947         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
20948         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
20949         return (uint64_t)ret_conv;
20950 }
20951
20952 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) {
20953         LDKPublicKey per_commitment_point_ref;
20954         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
20955         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
20956         LDKPublicKey countersignatory_revocation_base_point_ref;
20957         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
20958         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
20959         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20960         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
20961         return (uint64_t)ret_conv;
20962 }
20963
20964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20965         LDKTxCreationKeys this_obj_conv;
20966         this_obj_conv.inner = (void*)(this_obj & (~1));
20967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20968         TxCreationKeys_free(this_obj_conv);
20969 }
20970
20971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
20972         LDKTxCreationKeys this_ptr_conv;
20973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20974         this_ptr_conv.is_owned = false;
20975         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20976         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
20977         return ret_arr;
20978 }
20979
20980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20981         LDKTxCreationKeys this_ptr_conv;
20982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20983         this_ptr_conv.is_owned = false;
20984         LDKPublicKey val_ref;
20985         CHECK((*env)->GetArrayLength(env, val) == 33);
20986         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20987         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
20988 }
20989
20990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
20991         LDKTxCreationKeys this_ptr_conv;
20992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20993         this_ptr_conv.is_owned = false;
20994         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20995         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
20996         return ret_arr;
20997 }
20998
20999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21000         LDKTxCreationKeys this_ptr_conv;
21001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21002         this_ptr_conv.is_owned = false;
21003         LDKPublicKey val_ref;
21004         CHECK((*env)->GetArrayLength(env, val) == 33);
21005         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21006         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21007 }
21008
21009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21010         LDKTxCreationKeys this_ptr_conv;
21011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21012         this_ptr_conv.is_owned = false;
21013         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21014         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
21015         return ret_arr;
21016 }
21017
21018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21019         LDKTxCreationKeys this_ptr_conv;
21020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21021         this_ptr_conv.is_owned = false;
21022         LDKPublicKey val_ref;
21023         CHECK((*env)->GetArrayLength(env, val) == 33);
21024         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21025         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21026 }
21027
21028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21029         LDKTxCreationKeys this_ptr_conv;
21030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21031         this_ptr_conv.is_owned = false;
21032         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
21034         return ret_arr;
21035 }
21036
21037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21038         LDKTxCreationKeys this_ptr_conv;
21039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21040         this_ptr_conv.is_owned = false;
21041         LDKPublicKey val_ref;
21042         CHECK((*env)->GetArrayLength(env, val) == 33);
21043         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21044         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21045 }
21046
21047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
21048         LDKTxCreationKeys this_ptr_conv;
21049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21050         this_ptr_conv.is_owned = false;
21051         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21052         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
21053         return ret_arr;
21054 }
21055
21056 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) {
21057         LDKTxCreationKeys this_ptr_conv;
21058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21059         this_ptr_conv.is_owned = false;
21060         LDKPublicKey val_ref;
21061         CHECK((*env)->GetArrayLength(env, val) == 33);
21062         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21063         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21064 }
21065
21066 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) {
21067         LDKPublicKey per_commitment_point_arg_ref;
21068         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
21069         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
21070         LDKPublicKey revocation_key_arg_ref;
21071         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
21072         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
21073         LDKPublicKey broadcaster_htlc_key_arg_ref;
21074         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
21075         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
21076         LDKPublicKey countersignatory_htlc_key_arg_ref;
21077         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
21078         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
21079         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21080         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
21081         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
21082         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);
21083         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21084         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21085         uint64_t ret_ref = (uint64_t)ret_var.inner;
21086         if (ret_var.is_owned) {
21087                 ret_ref |= 1;
21088         }
21089         return ret_ref;
21090 }
21091
21092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21093         LDKTxCreationKeys orig_conv;
21094         orig_conv.inner = (void*)(orig & (~1));
21095         orig_conv.is_owned = false;
21096         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21099         uint64_t ret_ref = (uint64_t)ret_var.inner;
21100         if (ret_var.is_owned) {
21101                 ret_ref |= 1;
21102         }
21103         return ret_ref;
21104 }
21105
21106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21107         LDKTxCreationKeys obj_conv;
21108         obj_conv.inner = (void*)(obj & (~1));
21109         obj_conv.is_owned = false;
21110         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21111         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21112         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21113         CVec_u8Z_free(ret_var);
21114         return ret_arr;
21115 }
21116
21117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21118         LDKu8slice ser_ref;
21119         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21120         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21121         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21122         *ret_conv = TxCreationKeys_read(ser_ref);
21123         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21124         return (uint64_t)ret_conv;
21125 }
21126
21127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21128         LDKChannelPublicKeys this_obj_conv;
21129         this_obj_conv.inner = (void*)(this_obj & (~1));
21130         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21131         ChannelPublicKeys_free(this_obj_conv);
21132 }
21133
21134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21135         LDKChannelPublicKeys this_ptr_conv;
21136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21137         this_ptr_conv.is_owned = false;
21138         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21139         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
21140         return ret_arr;
21141 }
21142
21143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21144         LDKChannelPublicKeys this_ptr_conv;
21145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21146         this_ptr_conv.is_owned = false;
21147         LDKPublicKey val_ref;
21148         CHECK((*env)->GetArrayLength(env, val) == 33);
21149         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21150         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21151 }
21152
21153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21154         LDKChannelPublicKeys this_ptr_conv;
21155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21156         this_ptr_conv.is_owned = false;
21157         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
21159         return ret_arr;
21160 }
21161
21162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21163         LDKChannelPublicKeys this_ptr_conv;
21164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21165         this_ptr_conv.is_owned = false;
21166         LDKPublicKey val_ref;
21167         CHECK((*env)->GetArrayLength(env, val) == 33);
21168         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21169         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21170 }
21171
21172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
21173         LDKChannelPublicKeys this_ptr_conv;
21174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21175         this_ptr_conv.is_owned = false;
21176         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
21178         return ret_arr;
21179 }
21180
21181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21182         LDKChannelPublicKeys this_ptr_conv;
21183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21184         this_ptr_conv.is_owned = false;
21185         LDKPublicKey val_ref;
21186         CHECK((*env)->GetArrayLength(env, val) == 33);
21187         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21188         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21189 }
21190
21191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21192         LDKChannelPublicKeys this_ptr_conv;
21193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21194         this_ptr_conv.is_owned = false;
21195         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
21197         return ret_arr;
21198 }
21199
21200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21201         LDKChannelPublicKeys this_ptr_conv;
21202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21203         this_ptr_conv.is_owned = false;
21204         LDKPublicKey val_ref;
21205         CHECK((*env)->GetArrayLength(env, val) == 33);
21206         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21207         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21208 }
21209
21210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21211         LDKChannelPublicKeys this_ptr_conv;
21212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21213         this_ptr_conv.is_owned = false;
21214         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
21215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
21216         return ret_arr;
21217 }
21218
21219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21220         LDKChannelPublicKeys this_ptr_conv;
21221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21222         this_ptr_conv.is_owned = false;
21223         LDKPublicKey val_ref;
21224         CHECK((*env)->GetArrayLength(env, val) == 33);
21225         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
21226         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21227 }
21228
21229 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) {
21230         LDKPublicKey funding_pubkey_arg_ref;
21231         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
21232         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
21233         LDKPublicKey revocation_basepoint_arg_ref;
21234         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
21235         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
21236         LDKPublicKey payment_point_arg_ref;
21237         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
21238         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
21239         LDKPublicKey delayed_payment_basepoint_arg_ref;
21240         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
21241         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
21242         LDKPublicKey htlc_basepoint_arg_ref;
21243         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
21244         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
21245         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);
21246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21248         uint64_t ret_ref = (uint64_t)ret_var.inner;
21249         if (ret_var.is_owned) {
21250                 ret_ref |= 1;
21251         }
21252         return ret_ref;
21253 }
21254
21255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21256         LDKChannelPublicKeys orig_conv;
21257         orig_conv.inner = (void*)(orig & (~1));
21258         orig_conv.is_owned = false;
21259         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
21260         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21261         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21262         uint64_t ret_ref = (uint64_t)ret_var.inner;
21263         if (ret_var.is_owned) {
21264                 ret_ref |= 1;
21265         }
21266         return ret_ref;
21267 }
21268
21269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
21270         LDKChannelPublicKeys obj_conv;
21271         obj_conv.inner = (void*)(obj & (~1));
21272         obj_conv.is_owned = false;
21273         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21276         CVec_u8Z_free(ret_var);
21277         return ret_arr;
21278 }
21279
21280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21281         LDKu8slice ser_ref;
21282         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21283         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21284         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21285         *ret_conv = ChannelPublicKeys_read(ser_ref);
21286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21287         return (uint64_t)ret_conv;
21288 }
21289
21290 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) {
21291         LDKPublicKey per_commitment_point_ref;
21292         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21293         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21294         LDKPublicKey broadcaster_delayed_payment_base_ref;
21295         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
21296         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
21297         LDKPublicKey broadcaster_htlc_base_ref;
21298         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
21299         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
21300         LDKPublicKey countersignatory_revocation_base_ref;
21301         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
21302         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
21303         LDKPublicKey countersignatory_htlc_base_ref;
21304         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
21305         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
21306         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21307         *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);
21308         return (uint64_t)ret_conv;
21309 }
21310
21311 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) {
21312         LDKPublicKey per_commitment_point_ref;
21313         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
21314         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
21315         LDKChannelPublicKeys broadcaster_keys_conv;
21316         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21317         broadcaster_keys_conv.is_owned = false;
21318         LDKChannelPublicKeys countersignatory_keys_conv;
21319         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21320         countersignatory_keys_conv.is_owned = false;
21321         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21322         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21323         return (uint64_t)ret_conv;
21324 }
21325
21326 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) {
21327         LDKPublicKey revocation_key_ref;
21328         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21329         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21330         LDKPublicKey broadcaster_delayed_payment_key_ref;
21331         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21332         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21333         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21334         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21335         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21336         CVec_u8Z_free(ret_var);
21337         return ret_arr;
21338 }
21339
21340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21341         LDKHTLCOutputInCommitment this_obj_conv;
21342         this_obj_conv.inner = (void*)(this_obj & (~1));
21343         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21344         HTLCOutputInCommitment_free(this_obj_conv);
21345 }
21346
21347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
21348         LDKHTLCOutputInCommitment this_ptr_conv;
21349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21350         this_ptr_conv.is_owned = false;
21351         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21352         return ret_val;
21353 }
21354
21355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21356         LDKHTLCOutputInCommitment this_ptr_conv;
21357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21358         this_ptr_conv.is_owned = false;
21359         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21360 }
21361
21362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21363         LDKHTLCOutputInCommitment this_ptr_conv;
21364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21365         this_ptr_conv.is_owned = false;
21366         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21367         return ret_val;
21368 }
21369
21370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21371         LDKHTLCOutputInCommitment this_ptr_conv;
21372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21373         this_ptr_conv.is_owned = false;
21374         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21375 }
21376
21377 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
21378         LDKHTLCOutputInCommitment this_ptr_conv;
21379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21380         this_ptr_conv.is_owned = false;
21381         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21382         return ret_val;
21383 }
21384
21385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21386         LDKHTLCOutputInCommitment this_ptr_conv;
21387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21388         this_ptr_conv.is_owned = false;
21389         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21390 }
21391
21392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21393         LDKHTLCOutputInCommitment this_ptr_conv;
21394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21395         this_ptr_conv.is_owned = false;
21396         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
21398         return ret_arr;
21399 }
21400
21401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21402         LDKHTLCOutputInCommitment this_ptr_conv;
21403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21404         this_ptr_conv.is_owned = false;
21405         LDKThirtyTwoBytes val_ref;
21406         CHECK((*env)->GetArrayLength(env, val) == 32);
21407         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21408         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21409 }
21410
21411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
21412         LDKHTLCOutputInCommitment this_ptr_conv;
21413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21414         this_ptr_conv.is_owned = false;
21415         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21416         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21417         uint64_t ret_ref = (uint64_t)ret_copy;
21418         return ret_ref;
21419 }
21420
21421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21422         LDKHTLCOutputInCommitment this_ptr_conv;
21423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21424         this_ptr_conv.is_owned = false;
21425         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
21426         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
21427 }
21428
21429 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) {
21430         LDKThirtyTwoBytes payment_hash_arg_ref;
21431         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
21432         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
21433         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
21434         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
21435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21437         uint64_t ret_ref = (uint64_t)ret_var.inner;
21438         if (ret_var.is_owned) {
21439                 ret_ref |= 1;
21440         }
21441         return ret_ref;
21442 }
21443
21444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21445         LDKHTLCOutputInCommitment orig_conv;
21446         orig_conv.inner = (void*)(orig & (~1));
21447         orig_conv.is_owned = false;
21448         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
21449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21451         uint64_t ret_ref = (uint64_t)ret_var.inner;
21452         if (ret_var.is_owned) {
21453                 ret_ref |= 1;
21454         }
21455         return ret_ref;
21456 }
21457
21458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
21459         LDKHTLCOutputInCommitment obj_conv;
21460         obj_conv.inner = (void*)(obj & (~1));
21461         obj_conv.is_owned = false;
21462         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
21463         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21464         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21465         CVec_u8Z_free(ret_var);
21466         return ret_arr;
21467 }
21468
21469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21470         LDKu8slice ser_ref;
21471         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21472         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21473         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
21474         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
21475         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21476         return (uint64_t)ret_conv;
21477 }
21478
21479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
21480         LDKHTLCOutputInCommitment htlc_conv;
21481         htlc_conv.inner = (void*)(htlc & (~1));
21482         htlc_conv.is_owned = false;
21483         LDKTxCreationKeys keys_conv;
21484         keys_conv.inner = (void*)(keys & (~1));
21485         keys_conv.is_owned = false;
21486         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
21487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21489         CVec_u8Z_free(ret_var);
21490         return ret_arr;
21491 }
21492
21493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
21494         LDKPublicKey broadcaster_ref;
21495         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
21496         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
21497         LDKPublicKey countersignatory_ref;
21498         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
21499         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
21500         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
21501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21503         CVec_u8Z_free(ret_var);
21504         return ret_arr;
21505 }
21506
21507 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) {
21508         unsigned char commitment_txid_arr[32];
21509         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
21510         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
21511         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
21512         LDKHTLCOutputInCommitment htlc_conv;
21513         htlc_conv.inner = (void*)(htlc & (~1));
21514         htlc_conv.is_owned = false;
21515         LDKPublicKey broadcaster_delayed_payment_key_ref;
21516         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
21517         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
21518         LDKPublicKey revocation_key_ref;
21519         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
21520         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
21521         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
21522         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21523         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21524         Transaction_free(ret_var);
21525         return ret_arr;
21526 }
21527
21528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21529         LDKChannelTransactionParameters this_obj_conv;
21530         this_obj_conv.inner = (void*)(this_obj & (~1));
21531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21532         ChannelTransactionParameters_free(this_obj_conv);
21533 }
21534
21535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
21536         LDKChannelTransactionParameters this_ptr_conv;
21537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21538         this_ptr_conv.is_owned = false;
21539         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
21540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21542         uint64_t ret_ref = (uint64_t)ret_var.inner;
21543         if (ret_var.is_owned) {
21544                 ret_ref |= 1;
21545         }
21546         return ret_ref;
21547 }
21548
21549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21550         LDKChannelTransactionParameters this_ptr_conv;
21551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21552         this_ptr_conv.is_owned = false;
21553         LDKChannelPublicKeys val_conv;
21554         val_conv.inner = (void*)(val & (~1));
21555         val_conv.is_owned = (val & 1) || (val == 0);
21556         val_conv = ChannelPublicKeys_clone(&val_conv);
21557         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
21558 }
21559
21560 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21561         LDKChannelTransactionParameters this_ptr_conv;
21562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21563         this_ptr_conv.is_owned = false;
21564         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
21565         return ret_val;
21566 }
21567
21568 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) {
21569         LDKChannelTransactionParameters this_ptr_conv;
21570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21571         this_ptr_conv.is_owned = false;
21572         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
21573 }
21574
21575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
21576         LDKChannelTransactionParameters this_ptr_conv;
21577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21578         this_ptr_conv.is_owned = false;
21579         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
21580         return ret_val;
21581 }
21582
21583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21584         LDKChannelTransactionParameters this_ptr_conv;
21585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21586         this_ptr_conv.is_owned = false;
21587         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
21588 }
21589
21590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
21591         LDKChannelTransactionParameters this_ptr_conv;
21592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21593         this_ptr_conv.is_owned = false;
21594         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
21595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21597         uint64_t ret_ref = (uint64_t)ret_var.inner;
21598         if (ret_var.is_owned) {
21599                 ret_ref |= 1;
21600         }
21601         return ret_ref;
21602 }
21603
21604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21605         LDKChannelTransactionParameters this_ptr_conv;
21606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21607         this_ptr_conv.is_owned = false;
21608         LDKCounterpartyChannelTransactionParameters val_conv;
21609         val_conv.inner = (void*)(val & (~1));
21610         val_conv.is_owned = (val & 1) || (val == 0);
21611         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
21612         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
21613 }
21614
21615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21616         LDKChannelTransactionParameters this_ptr_conv;
21617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21618         this_ptr_conv.is_owned = false;
21619         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
21620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21622         uint64_t ret_ref = (uint64_t)ret_var.inner;
21623         if (ret_var.is_owned) {
21624                 ret_ref |= 1;
21625         }
21626         return ret_ref;
21627 }
21628
21629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21630         LDKChannelTransactionParameters this_ptr_conv;
21631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21632         this_ptr_conv.is_owned = false;
21633         LDKOutPoint val_conv;
21634         val_conv.inner = (void*)(val & (~1));
21635         val_conv.is_owned = (val & 1) || (val == 0);
21636         val_conv = OutPoint_clone(&val_conv);
21637         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
21638 }
21639
21640 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) {
21641         LDKChannelPublicKeys holder_pubkeys_arg_conv;
21642         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
21643         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
21644         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
21645         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
21646         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
21647         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
21648         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
21649         LDKOutPoint funding_outpoint_arg_conv;
21650         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
21651         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
21652         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
21653         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);
21654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21656         uint64_t ret_ref = (uint64_t)ret_var.inner;
21657         if (ret_var.is_owned) {
21658                 ret_ref |= 1;
21659         }
21660         return ret_ref;
21661 }
21662
21663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21664         LDKChannelTransactionParameters orig_conv;
21665         orig_conv.inner = (void*)(orig & (~1));
21666         orig_conv.is_owned = false;
21667         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
21668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21670         uint64_t ret_ref = (uint64_t)ret_var.inner;
21671         if (ret_var.is_owned) {
21672                 ret_ref |= 1;
21673         }
21674         return ret_ref;
21675 }
21676
21677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21678         LDKCounterpartyChannelTransactionParameters this_obj_conv;
21679         this_obj_conv.inner = (void*)(this_obj & (~1));
21680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21681         CounterpartyChannelTransactionParameters_free(this_obj_conv);
21682 }
21683
21684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
21685         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21687         this_ptr_conv.is_owned = false;
21688         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
21689         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21690         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21691         uint64_t ret_ref = (uint64_t)ret_var.inner;
21692         if (ret_var.is_owned) {
21693                 ret_ref |= 1;
21694         }
21695         return ret_ref;
21696 }
21697
21698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21699         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21701         this_ptr_conv.is_owned = false;
21702         LDKChannelPublicKeys val_conv;
21703         val_conv.inner = (void*)(val & (~1));
21704         val_conv.is_owned = (val & 1) || (val == 0);
21705         val_conv = ChannelPublicKeys_clone(&val_conv);
21706         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
21707 }
21708
21709 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21710         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21712         this_ptr_conv.is_owned = false;
21713         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
21714         return ret_val;
21715 }
21716
21717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21718         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21720         this_ptr_conv.is_owned = false;
21721         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
21722 }
21723
21724 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) {
21725         LDKChannelPublicKeys pubkeys_arg_conv;
21726         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
21727         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
21728         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
21729         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
21730         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21731         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21732         uint64_t ret_ref = (uint64_t)ret_var.inner;
21733         if (ret_var.is_owned) {
21734                 ret_ref |= 1;
21735         }
21736         return ret_ref;
21737 }
21738
21739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21740         LDKCounterpartyChannelTransactionParameters orig_conv;
21741         orig_conv.inner = (void*)(orig & (~1));
21742         orig_conv.is_owned = false;
21743         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
21744         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21745         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21746         uint64_t ret_ref = (uint64_t)ret_var.inner;
21747         if (ret_var.is_owned) {
21748                 ret_ref |= 1;
21749         }
21750         return ret_ref;
21751 }
21752
21753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
21754         LDKChannelTransactionParameters this_arg_conv;
21755         this_arg_conv.inner = (void*)(this_arg & (~1));
21756         this_arg_conv.is_owned = false;
21757         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
21758         return ret_val;
21759 }
21760
21761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
21762         LDKChannelTransactionParameters this_arg_conv;
21763         this_arg_conv.inner = (void*)(this_arg & (~1));
21764         this_arg_conv.is_owned = false;
21765         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
21766         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21767         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21768         uint64_t ret_ref = (uint64_t)ret_var.inner;
21769         if (ret_var.is_owned) {
21770                 ret_ref |= 1;
21771         }
21772         return ret_ref;
21773 }
21774
21775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
21776         LDKChannelTransactionParameters this_arg_conv;
21777         this_arg_conv.inner = (void*)(this_arg & (~1));
21778         this_arg_conv.is_owned = false;
21779         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
21780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21782         uint64_t ret_ref = (uint64_t)ret_var.inner;
21783         if (ret_var.is_owned) {
21784                 ret_ref |= 1;
21785         }
21786         return ret_ref;
21787 }
21788
21789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
21790         LDKCounterpartyChannelTransactionParameters obj_conv;
21791         obj_conv.inner = (void*)(obj & (~1));
21792         obj_conv.is_owned = false;
21793         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
21794         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21795         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21796         CVec_u8Z_free(ret_var);
21797         return ret_arr;
21798 }
21799
21800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21801         LDKu8slice ser_ref;
21802         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21803         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21804         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
21805         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
21806         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21807         return (uint64_t)ret_conv;
21808 }
21809
21810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
21811         LDKChannelTransactionParameters obj_conv;
21812         obj_conv.inner = (void*)(obj & (~1));
21813         obj_conv.is_owned = false;
21814         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
21815         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21816         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21817         CVec_u8Z_free(ret_var);
21818         return ret_arr;
21819 }
21820
21821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21822         LDKu8slice ser_ref;
21823         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21824         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21825         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
21826         *ret_conv = ChannelTransactionParameters_read(ser_ref);
21827         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21828         return (uint64_t)ret_conv;
21829 }
21830
21831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21832         LDKDirectedChannelTransactionParameters this_obj_conv;
21833         this_obj_conv.inner = (void*)(this_obj & (~1));
21834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21835         DirectedChannelTransactionParameters_free(this_obj_conv);
21836 }
21837
21838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
21839         LDKDirectedChannelTransactionParameters this_arg_conv;
21840         this_arg_conv.inner = (void*)(this_arg & (~1));
21841         this_arg_conv.is_owned = false;
21842         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
21843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21845         uint64_t ret_ref = (uint64_t)ret_var.inner;
21846         if (ret_var.is_owned) {
21847                 ret_ref |= 1;
21848         }
21849         return ret_ref;
21850 }
21851
21852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
21853         LDKDirectedChannelTransactionParameters this_arg_conv;
21854         this_arg_conv.inner = (void*)(this_arg & (~1));
21855         this_arg_conv.is_owned = false;
21856         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
21857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21859         uint64_t ret_ref = (uint64_t)ret_var.inner;
21860         if (ret_var.is_owned) {
21861                 ret_ref |= 1;
21862         }
21863         return ret_ref;
21864 }
21865
21866 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
21867         LDKDirectedChannelTransactionParameters this_arg_conv;
21868         this_arg_conv.inner = (void*)(this_arg & (~1));
21869         this_arg_conv.is_owned = false;
21870         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
21871         return ret_val;
21872 }
21873
21874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
21875         LDKDirectedChannelTransactionParameters this_arg_conv;
21876         this_arg_conv.inner = (void*)(this_arg & (~1));
21877         this_arg_conv.is_owned = false;
21878         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
21879         return ret_val;
21880 }
21881
21882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
21883         LDKDirectedChannelTransactionParameters this_arg_conv;
21884         this_arg_conv.inner = (void*)(this_arg & (~1));
21885         this_arg_conv.is_owned = false;
21886         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
21887         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21888         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21889         uint64_t ret_ref = (uint64_t)ret_var.inner;
21890         if (ret_var.is_owned) {
21891                 ret_ref |= 1;
21892         }
21893         return ret_ref;
21894 }
21895
21896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21897         LDKHolderCommitmentTransaction this_obj_conv;
21898         this_obj_conv.inner = (void*)(this_obj & (~1));
21899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21900         HolderCommitmentTransaction_free(this_obj_conv);
21901 }
21902
21903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
21904         LDKHolderCommitmentTransaction this_ptr_conv;
21905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21906         this_ptr_conv.is_owned = false;
21907         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
21908         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
21909         return ret_arr;
21910 }
21911
21912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21913         LDKHolderCommitmentTransaction this_ptr_conv;
21914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21915         this_ptr_conv.is_owned = false;
21916         LDKSignature val_ref;
21917         CHECK((*env)->GetArrayLength(env, val) == 64);
21918         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
21919         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
21920 }
21921
21922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
21923         LDKHolderCommitmentTransaction this_ptr_conv;
21924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21925         this_ptr_conv.is_owned = false;
21926         LDKCVec_SignatureZ val_constr;
21927         val_constr.datalen = (*env)->GetArrayLength(env, val);
21928         if (val_constr.datalen > 0)
21929                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21930         else
21931                 val_constr.data = NULL;
21932         for (size_t i = 0; i < val_constr.datalen; i++) {
21933                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
21934                 LDKSignature val_conv_8_ref;
21935                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
21936                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
21937                 val_constr.data[i] = val_conv_8_ref;
21938         }
21939         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
21940 }
21941
21942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21943         LDKHolderCommitmentTransaction orig_conv;
21944         orig_conv.inner = (void*)(orig & (~1));
21945         orig_conv.is_owned = false;
21946         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
21947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21949         uint64_t ret_ref = (uint64_t)ret_var.inner;
21950         if (ret_var.is_owned) {
21951                 ret_ref |= 1;
21952         }
21953         return ret_ref;
21954 }
21955
21956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
21957         LDKHolderCommitmentTransaction obj_conv;
21958         obj_conv.inner = (void*)(obj & (~1));
21959         obj_conv.is_owned = false;
21960         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
21961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21963         CVec_u8Z_free(ret_var);
21964         return ret_arr;
21965 }
21966
21967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21968         LDKu8slice ser_ref;
21969         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21970         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21971         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
21972         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
21973         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21974         return (uint64_t)ret_conv;
21975 }
21976
21977 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) {
21978         LDKCommitmentTransaction commitment_tx_conv;
21979         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
21980         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
21981         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
21982         LDKSignature counterparty_sig_ref;
21983         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
21984         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
21985         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
21986         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
21987         if (counterparty_htlc_sigs_constr.datalen > 0)
21988                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
21989         else
21990                 counterparty_htlc_sigs_constr.data = NULL;
21991         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
21992                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
21993                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
21994                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
21995                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
21996                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
21997         }
21998         LDKPublicKey holder_funding_key_ref;
21999         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
22000         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
22001         LDKPublicKey counterparty_funding_key_ref;
22002         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
22003         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
22004         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22007         uint64_t ret_ref = (uint64_t)ret_var.inner;
22008         if (ret_var.is_owned) {
22009                 ret_ref |= 1;
22010         }
22011         return ret_ref;
22012 }
22013
22014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22015         LDKBuiltCommitmentTransaction this_obj_conv;
22016         this_obj_conv.inner = (void*)(this_obj & (~1));
22017         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22018         BuiltCommitmentTransaction_free(this_obj_conv);
22019 }
22020
22021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
22022         LDKBuiltCommitmentTransaction this_ptr_conv;
22023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22024         this_ptr_conv.is_owned = false;
22025         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22028         Transaction_free(ret_var);
22029         return ret_arr;
22030 }
22031
22032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22033         LDKBuiltCommitmentTransaction this_ptr_conv;
22034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22035         this_ptr_conv.is_owned = false;
22036         LDKTransaction val_ref;
22037         val_ref.datalen = (*env)->GetArrayLength(env, val);
22038         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22039         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
22040         val_ref.data_is_owned = true;
22041         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22042 }
22043
22044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22045         LDKBuiltCommitmentTransaction this_ptr_conv;
22046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22047         this_ptr_conv.is_owned = false;
22048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
22050         return ret_arr;
22051 }
22052
22053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22054         LDKBuiltCommitmentTransaction this_ptr_conv;
22055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22056         this_ptr_conv.is_owned = false;
22057         LDKThirtyTwoBytes val_ref;
22058         CHECK((*env)->GetArrayLength(env, val) == 32);
22059         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22060         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22061 }
22062
22063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
22064         LDKTransaction transaction_arg_ref;
22065         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
22066         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22067         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
22068         transaction_arg_ref.data_is_owned = true;
22069         LDKThirtyTwoBytes txid_arg_ref;
22070         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22071         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22072         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22075         uint64_t ret_ref = (uint64_t)ret_var.inner;
22076         if (ret_var.is_owned) {
22077                 ret_ref |= 1;
22078         }
22079         return ret_ref;
22080 }
22081
22082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22083         LDKBuiltCommitmentTransaction orig_conv;
22084         orig_conv.inner = (void*)(orig & (~1));
22085         orig_conv.is_owned = false;
22086         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22089         uint64_t ret_ref = (uint64_t)ret_var.inner;
22090         if (ret_var.is_owned) {
22091                 ret_ref |= 1;
22092         }
22093         return ret_ref;
22094 }
22095
22096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22097         LDKBuiltCommitmentTransaction obj_conv;
22098         obj_conv.inner = (void*)(obj & (~1));
22099         obj_conv.is_owned = false;
22100         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22103         CVec_u8Z_free(ret_var);
22104         return ret_arr;
22105 }
22106
22107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22108         LDKu8slice ser_ref;
22109         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22110         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22111         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22112         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22113         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22114         return (uint64_t)ret_conv;
22115 }
22116
22117 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) {
22118         LDKBuiltCommitmentTransaction this_arg_conv;
22119         this_arg_conv.inner = (void*)(this_arg & (~1));
22120         this_arg_conv.is_owned = false;
22121         LDKu8slice funding_redeemscript_ref;
22122         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22123         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22124         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
22126         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22127         return ret_arr;
22128 }
22129
22130 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) {
22131         LDKBuiltCommitmentTransaction this_arg_conv;
22132         this_arg_conv.inner = (void*)(this_arg & (~1));
22133         this_arg_conv.is_owned = false;
22134         unsigned char funding_key_arr[32];
22135         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
22136         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
22137         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22138         LDKu8slice funding_redeemscript_ref;
22139         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
22140         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
22141         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
22142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
22143         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
22144         return ret_arr;
22145 }
22146
22147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22148         LDKCommitmentTransaction this_obj_conv;
22149         this_obj_conv.inner = (void*)(this_obj & (~1));
22150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22151         CommitmentTransaction_free(this_obj_conv);
22152 }
22153
22154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22155         LDKCommitmentTransaction orig_conv;
22156         orig_conv.inner = (void*)(orig & (~1));
22157         orig_conv.is_owned = false;
22158         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22161         uint64_t ret_ref = (uint64_t)ret_var.inner;
22162         if (ret_var.is_owned) {
22163                 ret_ref |= 1;
22164         }
22165         return ret_ref;
22166 }
22167
22168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
22169         LDKCommitmentTransaction obj_conv;
22170         obj_conv.inner = (void*)(obj & (~1));
22171         obj_conv.is_owned = false;
22172         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22173         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22174         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22175         CVec_u8Z_free(ret_var);
22176         return ret_arr;
22177 }
22178
22179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22180         LDKu8slice ser_ref;
22181         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22182         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22183         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22184         *ret_conv = CommitmentTransaction_read(ser_ref);
22185         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22186         return (uint64_t)ret_conv;
22187 }
22188
22189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
22190         LDKCommitmentTransaction this_arg_conv;
22191         this_arg_conv.inner = (void*)(this_arg & (~1));
22192         this_arg_conv.is_owned = false;
22193         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22194         return ret_val;
22195 }
22196
22197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22198         LDKCommitmentTransaction this_arg_conv;
22199         this_arg_conv.inner = (void*)(this_arg & (~1));
22200         this_arg_conv.is_owned = false;
22201         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22202         return ret_val;
22203 }
22204
22205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
22206         LDKCommitmentTransaction this_arg_conv;
22207         this_arg_conv.inner = (void*)(this_arg & (~1));
22208         this_arg_conv.is_owned = false;
22209         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22210         return ret_val;
22211 }
22212
22213 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
22214         LDKCommitmentTransaction this_arg_conv;
22215         this_arg_conv.inner = (void*)(this_arg & (~1));
22216         this_arg_conv.is_owned = false;
22217         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22218         return ret_val;
22219 }
22220
22221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
22222         LDKCommitmentTransaction this_arg_conv;
22223         this_arg_conv.inner = (void*)(this_arg & (~1));
22224         this_arg_conv.is_owned = false;
22225         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22228         uint64_t ret_ref = (uint64_t)ret_var.inner;
22229         if (ret_var.is_owned) {
22230                 ret_ref |= 1;
22231         }
22232         return ret_ref;
22233 }
22234
22235 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) {
22236         LDKCommitmentTransaction this_arg_conv;
22237         this_arg_conv.inner = (void*)(this_arg & (~1));
22238         this_arg_conv.is_owned = false;
22239         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22240         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22241         channel_parameters_conv.is_owned = false;
22242         LDKChannelPublicKeys broadcaster_keys_conv;
22243         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22244         broadcaster_keys_conv.is_owned = false;
22245         LDKChannelPublicKeys countersignatory_keys_conv;
22246         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22247         countersignatory_keys_conv.is_owned = false;
22248         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22249         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22250         return (uint64_t)ret_conv;
22251 }
22252
22253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22254         LDKTrustedCommitmentTransaction this_obj_conv;
22255         this_obj_conv.inner = (void*)(this_obj & (~1));
22256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22257         TrustedCommitmentTransaction_free(this_obj_conv);
22258 }
22259
22260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
22261         LDKTrustedCommitmentTransaction this_arg_conv;
22262         this_arg_conv.inner = (void*)(this_arg & (~1));
22263         this_arg_conv.is_owned = false;
22264         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22265         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
22266         return ret_arr;
22267 }
22268
22269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
22270         LDKTrustedCommitmentTransaction this_arg_conv;
22271         this_arg_conv.inner = (void*)(this_arg & (~1));
22272         this_arg_conv.is_owned = false;
22273         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22276         uint64_t ret_ref = (uint64_t)ret_var.inner;
22277         if (ret_var.is_owned) {
22278                 ret_ref |= 1;
22279         }
22280         return ret_ref;
22281 }
22282
22283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
22284         LDKTrustedCommitmentTransaction this_arg_conv;
22285         this_arg_conv.inner = (void*)(this_arg & (~1));
22286         this_arg_conv.is_owned = false;
22287         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22290         uint64_t ret_ref = (uint64_t)ret_var.inner;
22291         if (ret_var.is_owned) {
22292                 ret_ref |= 1;
22293         }
22294         return ret_ref;
22295 }
22296
22297 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) {
22298         LDKTrustedCommitmentTransaction this_arg_conv;
22299         this_arg_conv.inner = (void*)(this_arg & (~1));
22300         this_arg_conv.is_owned = false;
22301         unsigned char htlc_base_key_arr[32];
22302         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
22303         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
22304         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22305         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22306         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22307         channel_parameters_conv.is_owned = false;
22308         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22309         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22310         return (uint64_t)ret_conv;
22311 }
22312
22313 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) {
22314         LDKPublicKey broadcaster_payment_basepoint_ref;
22315         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
22316         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
22317         LDKPublicKey countersignatory_payment_basepoint_ref;
22318         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
22319         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
22320         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22321         return ret_val;
22322 }
22323
22324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22325         LDKInitFeatures a_conv;
22326         a_conv.inner = (void*)(a & (~1));
22327         a_conv.is_owned = false;
22328         LDKInitFeatures b_conv;
22329         b_conv.inner = (void*)(b & (~1));
22330         b_conv.is_owned = false;
22331         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22332         return ret_val;
22333 }
22334
22335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22336         LDKNodeFeatures a_conv;
22337         a_conv.inner = (void*)(a & (~1));
22338         a_conv.is_owned = false;
22339         LDKNodeFeatures b_conv;
22340         b_conv.inner = (void*)(b & (~1));
22341         b_conv.is_owned = false;
22342         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22343         return ret_val;
22344 }
22345
22346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22347         LDKChannelFeatures a_conv;
22348         a_conv.inner = (void*)(a & (~1));
22349         a_conv.is_owned = false;
22350         LDKChannelFeatures b_conv;
22351         b_conv.inner = (void*)(b & (~1));
22352         b_conv.is_owned = false;
22353         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22354         return ret_val;
22355 }
22356
22357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22358         LDKInvoiceFeatures a_conv;
22359         a_conv.inner = (void*)(a & (~1));
22360         a_conv.is_owned = false;
22361         LDKInvoiceFeatures b_conv;
22362         b_conv.inner = (void*)(b & (~1));
22363         b_conv.is_owned = false;
22364         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22365         return ret_val;
22366 }
22367
22368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22369         LDKInitFeatures orig_conv;
22370         orig_conv.inner = (void*)(orig & (~1));
22371         orig_conv.is_owned = false;
22372         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22373         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22374         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22375         uint64_t ret_ref = (uint64_t)ret_var.inner;
22376         if (ret_var.is_owned) {
22377                 ret_ref |= 1;
22378         }
22379         return ret_ref;
22380 }
22381
22382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22383         LDKNodeFeatures orig_conv;
22384         orig_conv.inner = (void*)(orig & (~1));
22385         orig_conv.is_owned = false;
22386         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22389         uint64_t ret_ref = (uint64_t)ret_var.inner;
22390         if (ret_var.is_owned) {
22391                 ret_ref |= 1;
22392         }
22393         return ret_ref;
22394 }
22395
22396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22397         LDKChannelFeatures orig_conv;
22398         orig_conv.inner = (void*)(orig & (~1));
22399         orig_conv.is_owned = false;
22400         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22403         uint64_t ret_ref = (uint64_t)ret_var.inner;
22404         if (ret_var.is_owned) {
22405                 ret_ref |= 1;
22406         }
22407         return ret_ref;
22408 }
22409
22410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22411         LDKInvoiceFeatures orig_conv;
22412         orig_conv.inner = (void*)(orig & (~1));
22413         orig_conv.is_owned = false;
22414         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22415         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22416         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22417         uint64_t ret_ref = (uint64_t)ret_var.inner;
22418         if (ret_var.is_owned) {
22419                 ret_ref |= 1;
22420         }
22421         return ret_ref;
22422 }
22423
22424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22425         LDKInitFeatures this_obj_conv;
22426         this_obj_conv.inner = (void*)(this_obj & (~1));
22427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22428         InitFeatures_free(this_obj_conv);
22429 }
22430
22431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22432         LDKNodeFeatures this_obj_conv;
22433         this_obj_conv.inner = (void*)(this_obj & (~1));
22434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22435         NodeFeatures_free(this_obj_conv);
22436 }
22437
22438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22439         LDKChannelFeatures this_obj_conv;
22440         this_obj_conv.inner = (void*)(this_obj & (~1));
22441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22442         ChannelFeatures_free(this_obj_conv);
22443 }
22444
22445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22446         LDKInvoiceFeatures this_obj_conv;
22447         this_obj_conv.inner = (void*)(this_obj & (~1));
22448         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22449         InvoiceFeatures_free(this_obj_conv);
22450 }
22451
22452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
22453         LDKInitFeatures ret_var = InitFeatures_empty();
22454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22456         uint64_t ret_ref = (uint64_t)ret_var.inner;
22457         if (ret_var.is_owned) {
22458                 ret_ref |= 1;
22459         }
22460         return ret_ref;
22461 }
22462
22463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
22464         LDKInitFeatures ret_var = InitFeatures_known();
22465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22467         uint64_t ret_ref = (uint64_t)ret_var.inner;
22468         if (ret_var.is_owned) {
22469                 ret_ref |= 1;
22470         }
22471         return ret_ref;
22472 }
22473
22474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
22475         LDKNodeFeatures ret_var = NodeFeatures_empty();
22476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22478         uint64_t ret_ref = (uint64_t)ret_var.inner;
22479         if (ret_var.is_owned) {
22480                 ret_ref |= 1;
22481         }
22482         return ret_ref;
22483 }
22484
22485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
22486         LDKNodeFeatures ret_var = NodeFeatures_known();
22487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22489         uint64_t ret_ref = (uint64_t)ret_var.inner;
22490         if (ret_var.is_owned) {
22491                 ret_ref |= 1;
22492         }
22493         return ret_ref;
22494 }
22495
22496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
22497         LDKChannelFeatures ret_var = ChannelFeatures_empty();
22498         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22499         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22500         uint64_t ret_ref = (uint64_t)ret_var.inner;
22501         if (ret_var.is_owned) {
22502                 ret_ref |= 1;
22503         }
22504         return ret_ref;
22505 }
22506
22507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
22508         LDKChannelFeatures ret_var = ChannelFeatures_known();
22509         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22510         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22511         uint64_t ret_ref = (uint64_t)ret_var.inner;
22512         if (ret_var.is_owned) {
22513                 ret_ref |= 1;
22514         }
22515         return ret_ref;
22516 }
22517
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
22519         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
22520         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22521         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22522         uint64_t ret_ref = (uint64_t)ret_var.inner;
22523         if (ret_var.is_owned) {
22524                 ret_ref |= 1;
22525         }
22526         return ret_ref;
22527 }
22528
22529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
22530         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
22531         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22532         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22533         uint64_t ret_ref = (uint64_t)ret_var.inner;
22534         if (ret_var.is_owned) {
22535                 ret_ref |= 1;
22536         }
22537         return ret_ref;
22538 }
22539
22540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22541         LDKInitFeatures this_arg_conv;
22542         this_arg_conv.inner = (void*)(this_arg & (~1));
22543         this_arg_conv.is_owned = false;
22544         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
22545         return ret_val;
22546 }
22547
22548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22549         LDKNodeFeatures this_arg_conv;
22550         this_arg_conv.inner = (void*)(this_arg & (~1));
22551         this_arg_conv.is_owned = false;
22552         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
22553         return ret_val;
22554 }
22555
22556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
22557         LDKInvoiceFeatures this_arg_conv;
22558         this_arg_conv.inner = (void*)(this_arg & (~1));
22559         this_arg_conv.is_owned = false;
22560         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
22561         return ret_val;
22562 }
22563
22564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22565         LDKInitFeatures obj_conv;
22566         obj_conv.inner = (void*)(obj & (~1));
22567         obj_conv.is_owned = false;
22568         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
22569         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22570         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22571         CVec_u8Z_free(ret_var);
22572         return ret_arr;
22573 }
22574
22575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22576         LDKNodeFeatures obj_conv;
22577         obj_conv.inner = (void*)(obj & (~1));
22578         obj_conv.is_owned = false;
22579         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
22580         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22581         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22582         CVec_u8Z_free(ret_var);
22583         return ret_arr;
22584 }
22585
22586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22587         LDKChannelFeatures obj_conv;
22588         obj_conv.inner = (void*)(obj & (~1));
22589         obj_conv.is_owned = false;
22590         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
22591         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22592         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22593         CVec_u8Z_free(ret_var);
22594         return ret_arr;
22595 }
22596
22597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
22598         LDKInvoiceFeatures obj_conv;
22599         obj_conv.inner = (void*)(obj & (~1));
22600         obj_conv.is_owned = false;
22601         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
22602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22604         CVec_u8Z_free(ret_var);
22605         return ret_arr;
22606 }
22607
22608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22609         LDKu8slice ser_ref;
22610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22612         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
22613         *ret_conv = InitFeatures_read(ser_ref);
22614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22615         return (uint64_t)ret_conv;
22616 }
22617
22618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22619         LDKu8slice ser_ref;
22620         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22621         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22622         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
22623         *ret_conv = NodeFeatures_read(ser_ref);
22624         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22625         return (uint64_t)ret_conv;
22626 }
22627
22628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22629         LDKu8slice ser_ref;
22630         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22631         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22632         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
22633         *ret_conv = ChannelFeatures_read(ser_ref);
22634         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22635         return (uint64_t)ret_conv;
22636 }
22637
22638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22639         LDKu8slice ser_ref;
22640         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22641         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22642         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
22643         *ret_conv = InvoiceFeatures_read(ser_ref);
22644         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22645         return (uint64_t)ret_conv;
22646 }
22647
22648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22649         LDKRouteHop this_obj_conv;
22650         this_obj_conv.inner = (void*)(this_obj & (~1));
22651         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22652         RouteHop_free(this_obj_conv);
22653 }
22654
22655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22656         LDKRouteHop this_ptr_conv;
22657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22658         this_ptr_conv.is_owned = false;
22659         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
22661         return ret_arr;
22662 }
22663
22664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22665         LDKRouteHop this_ptr_conv;
22666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22667         this_ptr_conv.is_owned = false;
22668         LDKPublicKey val_ref;
22669         CHECK((*env)->GetArrayLength(env, val) == 33);
22670         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22671         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
22672 }
22673
22674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22675         LDKRouteHop this_ptr_conv;
22676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22677         this_ptr_conv.is_owned = false;
22678         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
22679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22681         uint64_t ret_ref = (uint64_t)ret_var.inner;
22682         if (ret_var.is_owned) {
22683                 ret_ref |= 1;
22684         }
22685         return ret_ref;
22686 }
22687
22688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22689         LDKRouteHop this_ptr_conv;
22690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22691         this_ptr_conv.is_owned = false;
22692         LDKNodeFeatures val_conv;
22693         val_conv.inner = (void*)(val & (~1));
22694         val_conv.is_owned = (val & 1) || (val == 0);
22695         val_conv = NodeFeatures_clone(&val_conv);
22696         RouteHop_set_node_features(&this_ptr_conv, val_conv);
22697 }
22698
22699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22700         LDKRouteHop this_ptr_conv;
22701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22702         this_ptr_conv.is_owned = false;
22703         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
22704         return ret_val;
22705 }
22706
22707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22708         LDKRouteHop this_ptr_conv;
22709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22710         this_ptr_conv.is_owned = false;
22711         RouteHop_set_short_channel_id(&this_ptr_conv, val);
22712 }
22713
22714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
22715         LDKRouteHop this_ptr_conv;
22716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22717         this_ptr_conv.is_owned = false;
22718         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
22719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22721         uint64_t ret_ref = (uint64_t)ret_var.inner;
22722         if (ret_var.is_owned) {
22723                 ret_ref |= 1;
22724         }
22725         return ret_ref;
22726 }
22727
22728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22729         LDKRouteHop this_ptr_conv;
22730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22731         this_ptr_conv.is_owned = false;
22732         LDKChannelFeatures val_conv;
22733         val_conv.inner = (void*)(val & (~1));
22734         val_conv.is_owned = (val & 1) || (val == 0);
22735         val_conv = ChannelFeatures_clone(&val_conv);
22736         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
22737 }
22738
22739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22740         LDKRouteHop this_ptr_conv;
22741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22742         this_ptr_conv.is_owned = false;
22743         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
22744         return ret_val;
22745 }
22746
22747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22748         LDKRouteHop this_ptr_conv;
22749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22750         this_ptr_conv.is_owned = false;
22751         RouteHop_set_fee_msat(&this_ptr_conv, val);
22752 }
22753
22754 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
22755         LDKRouteHop this_ptr_conv;
22756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22757         this_ptr_conv.is_owned = false;
22758         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
22759         return ret_val;
22760 }
22761
22762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22763         LDKRouteHop this_ptr_conv;
22764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22765         this_ptr_conv.is_owned = false;
22766         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
22767 }
22768
22769 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) {
22770         LDKPublicKey pubkey_arg_ref;
22771         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
22772         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
22773         LDKNodeFeatures node_features_arg_conv;
22774         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
22775         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
22776         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
22777         LDKChannelFeatures channel_features_arg_conv;
22778         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
22779         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
22780         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
22781         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);
22782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22784         uint64_t ret_ref = (uint64_t)ret_var.inner;
22785         if (ret_var.is_owned) {
22786                 ret_ref |= 1;
22787         }
22788         return ret_ref;
22789 }
22790
22791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22792         LDKRouteHop orig_conv;
22793         orig_conv.inner = (void*)(orig & (~1));
22794         orig_conv.is_owned = false;
22795         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
22796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22798         uint64_t ret_ref = (uint64_t)ret_var.inner;
22799         if (ret_var.is_owned) {
22800                 ret_ref |= 1;
22801         }
22802         return ret_ref;
22803 }
22804
22805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
22806         LDKRouteHop obj_conv;
22807         obj_conv.inner = (void*)(obj & (~1));
22808         obj_conv.is_owned = false;
22809         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
22810         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22811         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22812         CVec_u8Z_free(ret_var);
22813         return ret_arr;
22814 }
22815
22816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22817         LDKu8slice ser_ref;
22818         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22819         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22820         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
22821         *ret_conv = RouteHop_read(ser_ref);
22822         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22823         return (uint64_t)ret_conv;
22824 }
22825
22826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22827         LDKRoute this_obj_conv;
22828         this_obj_conv.inner = (void*)(this_obj & (~1));
22829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22830         Route_free(this_obj_conv);
22831 }
22832
22833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
22834         LDKRoute this_ptr_conv;
22835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22836         this_ptr_conv.is_owned = false;
22837         LDKCVec_CVec_RouteHopZZ val_constr;
22838         val_constr.datalen = (*env)->GetArrayLength(env, val);
22839         if (val_constr.datalen > 0)
22840                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
22841         else
22842                 val_constr.data = NULL;
22843         for (size_t m = 0; m < val_constr.datalen; m++) {
22844                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
22845                 LDKCVec_RouteHopZ val_conv_12_constr;
22846                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
22847                 if (val_conv_12_constr.datalen > 0)
22848                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22849                 else
22850                         val_conv_12_constr.data = NULL;
22851                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
22852                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
22853                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
22854                         LDKRouteHop val_conv_12_conv_10_conv;
22855                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
22856                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
22857                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
22858                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
22859                 }
22860                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
22861                 val_constr.data[m] = val_conv_12_constr;
22862         }
22863         Route_set_paths(&this_ptr_conv, val_constr);
22864 }
22865
22866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
22867         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
22868         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
22869         if (paths_arg_constr.datalen > 0)
22870                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
22871         else
22872                 paths_arg_constr.data = NULL;
22873         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
22874                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
22875                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
22876                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
22877                 if (paths_arg_conv_12_constr.datalen > 0)
22878                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22879                 else
22880                         paths_arg_conv_12_constr.data = NULL;
22881                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
22882                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
22883                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
22884                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
22885                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
22886                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
22887                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
22888                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
22889                 }
22890                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
22891                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
22892         }
22893         LDKRoute ret_var = Route_new(paths_arg_constr);
22894         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22895         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22896         uint64_t ret_ref = (uint64_t)ret_var.inner;
22897         if (ret_var.is_owned) {
22898                 ret_ref |= 1;
22899         }
22900         return ret_ref;
22901 }
22902
22903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22904         LDKRoute orig_conv;
22905         orig_conv.inner = (void*)(orig & (~1));
22906         orig_conv.is_owned = false;
22907         LDKRoute ret_var = Route_clone(&orig_conv);
22908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22910         uint64_t ret_ref = (uint64_t)ret_var.inner;
22911         if (ret_var.is_owned) {
22912                 ret_ref |= 1;
22913         }
22914         return ret_ref;
22915 }
22916
22917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
22918         LDKRoute obj_conv;
22919         obj_conv.inner = (void*)(obj & (~1));
22920         obj_conv.is_owned = false;
22921         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
22922         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22923         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22924         CVec_u8Z_free(ret_var);
22925         return ret_arr;
22926 }
22927
22928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22929         LDKu8slice ser_ref;
22930         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22931         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22932         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
22933         *ret_conv = Route_read(ser_ref);
22934         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22935         return (uint64_t)ret_conv;
22936 }
22937
22938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22939         LDKRouteHint this_obj_conv;
22940         this_obj_conv.inner = (void*)(this_obj & (~1));
22941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22942         RouteHint_free(this_obj_conv);
22943 }
22944
22945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22946         LDKRouteHint a_conv;
22947         a_conv.inner = (void*)(a & (~1));
22948         a_conv.is_owned = false;
22949         LDKRouteHint b_conv;
22950         b_conv.inner = (void*)(b & (~1));
22951         b_conv.is_owned = false;
22952         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
22953         return ret_val;
22954 }
22955
22956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22957         LDKRouteHint orig_conv;
22958         orig_conv.inner = (void*)(orig & (~1));
22959         orig_conv.is_owned = false;
22960         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
22961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22963         uint64_t ret_ref = (uint64_t)ret_var.inner;
22964         if (ret_var.is_owned) {
22965                 ret_ref |= 1;
22966         }
22967         return ret_ref;
22968 }
22969
22970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22971         LDKRouteHintHop this_obj_conv;
22972         this_obj_conv.inner = (void*)(this_obj & (~1));
22973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22974         RouteHintHop_free(this_obj_conv);
22975 }
22976
22977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22978         LDKRouteHintHop this_ptr_conv;
22979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22980         this_ptr_conv.is_owned = false;
22981         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
22983         return ret_arr;
22984 }
22985
22986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22987         LDKRouteHintHop this_ptr_conv;
22988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22989         this_ptr_conv.is_owned = false;
22990         LDKPublicKey val_ref;
22991         CHECK((*env)->GetArrayLength(env, val) == 33);
22992         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22993         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
22994 }
22995
22996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22997         LDKRouteHintHop this_ptr_conv;
22998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22999         this_ptr_conv.is_owned = false;
23000         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23001         return ret_val;
23002 }
23003
23004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23005         LDKRouteHintHop this_ptr_conv;
23006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23007         this_ptr_conv.is_owned = false;
23008         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23009 }
23010
23011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23012         LDKRouteHintHop this_ptr_conv;
23013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23014         this_ptr_conv.is_owned = false;
23015         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23018         uint64_t ret_ref = (uint64_t)ret_var.inner;
23019         if (ret_var.is_owned) {
23020                 ret_ref |= 1;
23021         }
23022         return ret_ref;
23023 }
23024
23025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23026         LDKRouteHintHop this_ptr_conv;
23027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23028         this_ptr_conv.is_owned = false;
23029         LDKRoutingFees val_conv;
23030         val_conv.inner = (void*)(val & (~1));
23031         val_conv.is_owned = (val & 1) || (val == 0);
23032         val_conv = RoutingFees_clone(&val_conv);
23033         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23034 }
23035
23036 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23037         LDKRouteHintHop this_ptr_conv;
23038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23039         this_ptr_conv.is_owned = false;
23040         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23041         return ret_val;
23042 }
23043
23044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23045         LDKRouteHintHop this_ptr_conv;
23046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23047         this_ptr_conv.is_owned = false;
23048         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23049 }
23050
23051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23052         LDKRouteHintHop this_ptr_conv;
23053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23054         this_ptr_conv.is_owned = false;
23055         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23056         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23057         uint64_t ret_ref = (uint64_t)ret_copy;
23058         return ret_ref;
23059 }
23060
23061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23062         LDKRouteHintHop this_ptr_conv;
23063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23064         this_ptr_conv.is_owned = false;
23065         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23066         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23067 }
23068
23069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23070         LDKRouteHintHop this_ptr_conv;
23071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23072         this_ptr_conv.is_owned = false;
23073         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23074         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23075         uint64_t ret_ref = (uint64_t)ret_copy;
23076         return ret_ref;
23077 }
23078
23079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23080         LDKRouteHintHop this_ptr_conv;
23081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23082         this_ptr_conv.is_owned = false;
23083         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23084         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23085 }
23086
23087 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) {
23088         LDKPublicKey src_node_id_arg_ref;
23089         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
23090         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
23091         LDKRoutingFees fees_arg_conv;
23092         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23093         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23094         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23095         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23096         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23097         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);
23098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23100         uint64_t ret_ref = (uint64_t)ret_var.inner;
23101         if (ret_var.is_owned) {
23102                 ret_ref |= 1;
23103         }
23104         return ret_ref;
23105 }
23106
23107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23108         LDKRouteHintHop a_conv;
23109         a_conv.inner = (void*)(a & (~1));
23110         a_conv.is_owned = false;
23111         LDKRouteHintHop b_conv;
23112         b_conv.inner = (void*)(b & (~1));
23113         b_conv.is_owned = false;
23114         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23115         return ret_val;
23116 }
23117
23118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23119         LDKRouteHintHop orig_conv;
23120         orig_conv.inner = (void*)(orig & (~1));
23121         orig_conv.is_owned = false;
23122         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23125         uint64_t ret_ref = (uint64_t)ret_var.inner;
23126         if (ret_var.is_owned) {
23127                 ret_ref |= 1;
23128         }
23129         return ret_ref;
23130 }
23131
23132 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) {
23133         LDKPublicKey our_node_id_ref;
23134         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
23135         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
23136         LDKNetworkGraph network_conv;
23137         network_conv.inner = (void*)(network & (~1));
23138         network_conv.is_owned = false;
23139         LDKPublicKey payee_ref;
23140         CHECK((*env)->GetArrayLength(env, payee) == 33);
23141         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
23142         LDKInvoiceFeatures payee_features_conv;
23143         payee_features_conv.inner = (void*)(payee_features & (~1));
23144         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23145         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23146         LDKCVec_ChannelDetailsZ first_hops_constr;
23147         first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
23148         if (first_hops_constr.datalen > 0)
23149                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23150         else
23151                 first_hops_constr.data = NULL;
23152         int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
23153         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23154                 int64_t first_hops_conv_16 = first_hops_vals[q];
23155                 LDKChannelDetails first_hops_conv_16_conv;
23156                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23157                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23158                 first_hops_constr.data[q] = first_hops_conv_16_conv;
23159         }
23160         (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
23161         LDKCVec_RouteHintZ last_hops_constr;
23162         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
23163         if (last_hops_constr.datalen > 0)
23164                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23165         else
23166                 last_hops_constr.data = NULL;
23167         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
23168         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23169                 int64_t last_hops_conv_11 = last_hops_vals[l];
23170                 LDKRouteHint last_hops_conv_11_conv;
23171                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23172                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23173                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23174                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23175         }
23176         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
23177         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23178         if (logger_conv.free == LDKLogger_JCalls_free) {
23179                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23180                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23181         }
23182         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23183         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23184         FREE(first_hops_constr.data);
23185         return (uint64_t)ret_conv;
23186 }
23187
23188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23189         LDKNetworkGraph this_obj_conv;
23190         this_obj_conv.inner = (void*)(this_obj & (~1));
23191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23192         NetworkGraph_free(this_obj_conv);
23193 }
23194
23195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23196         LDKNetworkGraph orig_conv;
23197         orig_conv.inner = (void*)(orig & (~1));
23198         orig_conv.is_owned = false;
23199         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
23200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23202         uint64_t ret_ref = (uint64_t)ret_var.inner;
23203         if (ret_var.is_owned) {
23204                 ret_ref |= 1;
23205         }
23206         return ret_ref;
23207 }
23208
23209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23210         LDKLockedNetworkGraph this_obj_conv;
23211         this_obj_conv.inner = (void*)(this_obj & (~1));
23212         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23213         LockedNetworkGraph_free(this_obj_conv);
23214 }
23215
23216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23217         LDKNetGraphMsgHandler this_obj_conv;
23218         this_obj_conv.inner = (void*)(this_obj & (~1));
23219         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23220         NetGraphMsgHandler_free(this_obj_conv);
23221 }
23222
23223 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) {
23224         LDKThirtyTwoBytes genesis_hash_ref;
23225         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
23226         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
23227         LDKAccess *chain_access_conv_ptr = NULL;
23228         if (chain_access != 0) {
23229                 LDKAccess chain_access_conv;
23230                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23231                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23232                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23233                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23234                 }
23235                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23236                 *chain_access_conv_ptr = chain_access_conv;
23237         }
23238         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23239         if (logger_conv.free == LDKLogger_JCalls_free) {
23240                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23241                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23242         }
23243         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
23244         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23245         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23246         uint64_t ret_ref = (uint64_t)ret_var.inner;
23247         if (ret_var.is_owned) {
23248                 ret_ref |= 1;
23249         }
23250         return ret_ref;
23251 }
23252
23253 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) {
23254         LDKAccess *chain_access_conv_ptr = NULL;
23255         if (chain_access != 0) {
23256                 LDKAccess chain_access_conv;
23257                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23258                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23259                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23260                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23261                 }
23262                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23263                 *chain_access_conv_ptr = chain_access_conv;
23264         }
23265         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23266         if (logger_conv.free == LDKLogger_JCalls_free) {
23267                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23268                 LDKLogger_JCalls_clone(logger_conv.this_arg);
23269         }
23270         LDKNetworkGraph network_graph_conv;
23271         network_graph_conv.inner = (void*)(network_graph & (~1));
23272         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
23273         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
23274         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
23275         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23276         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23277         uint64_t ret_ref = (uint64_t)ret_var.inner;
23278         if (ret_var.is_owned) {
23279                 ret_ref |= 1;
23280         }
23281         return ret_ref;
23282 }
23283
23284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
23285         LDKNetGraphMsgHandler this_arg_conv;
23286         this_arg_conv.inner = (void*)(this_arg & (~1));
23287         this_arg_conv.is_owned = false;
23288         LDKAccess *chain_access_conv_ptr = NULL;
23289         if (chain_access != 0) {
23290                 LDKAccess chain_access_conv;
23291                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23292                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
23293                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23294                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
23295                 }
23296                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23297                 *chain_access_conv_ptr = chain_access_conv;
23298         }
23299         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
23300 }
23301
23302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23303         LDKNetGraphMsgHandler this_arg_conv;
23304         this_arg_conv.inner = (void*)(this_arg & (~1));
23305         this_arg_conv.is_owned = false;
23306         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
23307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23309         uint64_t ret_ref = (uint64_t)ret_var.inner;
23310         if (ret_var.is_owned) {
23311                 ret_ref |= 1;
23312         }
23313         return ret_ref;
23314 }
23315
23316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
23317         LDKLockedNetworkGraph this_arg_conv;
23318         this_arg_conv.inner = (void*)(this_arg & (~1));
23319         this_arg_conv.is_owned = false;
23320         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
23321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23323         uint64_t ret_ref = (uint64_t)ret_var.inner;
23324         if (ret_var.is_owned) {
23325                 ret_ref |= 1;
23326         }
23327         return ret_ref;
23328 }
23329
23330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
23331         LDKNetGraphMsgHandler this_arg_conv;
23332         this_arg_conv.inner = (void*)(this_arg & (~1));
23333         this_arg_conv.is_owned = false;
23334         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23335         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
23336         return (uint64_t)ret;
23337 }
23338
23339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
23340         LDKNetGraphMsgHandler this_arg_conv;
23341         this_arg_conv.inner = (void*)(this_arg & (~1));
23342         this_arg_conv.is_owned = false;
23343         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23344         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
23345         return (uint64_t)ret;
23346 }
23347
23348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23349         LDKDirectionalChannelInfo this_obj_conv;
23350         this_obj_conv.inner = (void*)(this_obj & (~1));
23351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23352         DirectionalChannelInfo_free(this_obj_conv);
23353 }
23354
23355 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23356         LDKDirectionalChannelInfo this_ptr_conv;
23357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23358         this_ptr_conv.is_owned = false;
23359         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
23360         return ret_val;
23361 }
23362
23363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23364         LDKDirectionalChannelInfo this_ptr_conv;
23365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23366         this_ptr_conv.is_owned = false;
23367         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
23368 }
23369
23370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
23371         LDKDirectionalChannelInfo this_ptr_conv;
23372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23373         this_ptr_conv.is_owned = false;
23374         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
23375         return ret_val;
23376 }
23377
23378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23379         LDKDirectionalChannelInfo this_ptr_conv;
23380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23381         this_ptr_conv.is_owned = false;
23382         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
23383 }
23384
23385 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23386         LDKDirectionalChannelInfo this_ptr_conv;
23387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23388         this_ptr_conv.is_owned = false;
23389         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
23390         return ret_val;
23391 }
23392
23393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23394         LDKDirectionalChannelInfo this_ptr_conv;
23395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23396         this_ptr_conv.is_owned = false;
23397         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23398 }
23399
23400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23401         LDKDirectionalChannelInfo this_ptr_conv;
23402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23403         this_ptr_conv.is_owned = false;
23404         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
23405         return ret_val;
23406 }
23407
23408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23409         LDKDirectionalChannelInfo this_ptr_conv;
23410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23411         this_ptr_conv.is_owned = false;
23412         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
23413 }
23414
23415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23416         LDKDirectionalChannelInfo this_ptr_conv;
23417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23418         this_ptr_conv.is_owned = false;
23419         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23420         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
23421         uint64_t ret_ref = (uint64_t)ret_copy;
23422         return ret_ref;
23423 }
23424
23425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23426         LDKDirectionalChannelInfo this_ptr_conv;
23427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23428         this_ptr_conv.is_owned = false;
23429         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23430         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23431 }
23432
23433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
23434         LDKDirectionalChannelInfo this_ptr_conv;
23435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23436         this_ptr_conv.is_owned = false;
23437         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
23438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23440         uint64_t ret_ref = (uint64_t)ret_var.inner;
23441         if (ret_var.is_owned) {
23442                 ret_ref |= 1;
23443         }
23444         return ret_ref;
23445 }
23446
23447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23448         LDKDirectionalChannelInfo this_ptr_conv;
23449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23450         this_ptr_conv.is_owned = false;
23451         LDKRoutingFees val_conv;
23452         val_conv.inner = (void*)(val & (~1));
23453         val_conv.is_owned = (val & 1) || (val == 0);
23454         val_conv = RoutingFees_clone(&val_conv);
23455         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
23456 }
23457
23458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23459         LDKDirectionalChannelInfo this_ptr_conv;
23460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23461         this_ptr_conv.is_owned = false;
23462         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
23463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23465         uint64_t ret_ref = (uint64_t)ret_var.inner;
23466         if (ret_var.is_owned) {
23467                 ret_ref |= 1;
23468         }
23469         return ret_ref;
23470 }
23471
23472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23473         LDKDirectionalChannelInfo this_ptr_conv;
23474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23475         this_ptr_conv.is_owned = false;
23476         LDKChannelUpdate val_conv;
23477         val_conv.inner = (void*)(val & (~1));
23478         val_conv.is_owned = (val & 1) || (val == 0);
23479         val_conv = ChannelUpdate_clone(&val_conv);
23480         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
23481 }
23482
23483 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) {
23484         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23485         LDKRoutingFees fees_arg_conv;
23486         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23487         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23488         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23489         LDKChannelUpdate last_update_message_arg_conv;
23490         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
23491         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
23492         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
23493         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);
23494         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23495         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23496         uint64_t ret_ref = (uint64_t)ret_var.inner;
23497         if (ret_var.is_owned) {
23498                 ret_ref |= 1;
23499         }
23500         return ret_ref;
23501 }
23502
23503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23504         LDKDirectionalChannelInfo orig_conv;
23505         orig_conv.inner = (void*)(orig & (~1));
23506         orig_conv.is_owned = false;
23507         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
23508         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23509         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23510         uint64_t ret_ref = (uint64_t)ret_var.inner;
23511         if (ret_var.is_owned) {
23512                 ret_ref |= 1;
23513         }
23514         return ret_ref;
23515 }
23516
23517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
23518         LDKDirectionalChannelInfo obj_conv;
23519         obj_conv.inner = (void*)(obj & (~1));
23520         obj_conv.is_owned = false;
23521         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
23522         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23523         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23524         CVec_u8Z_free(ret_var);
23525         return ret_arr;
23526 }
23527
23528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23529         LDKu8slice ser_ref;
23530         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23531         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23532         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
23533         *ret_conv = DirectionalChannelInfo_read(ser_ref);
23534         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23535         return (uint64_t)ret_conv;
23536 }
23537
23538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23539         LDKChannelInfo this_obj_conv;
23540         this_obj_conv.inner = (void*)(this_obj & (~1));
23541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23542         ChannelInfo_free(this_obj_conv);
23543 }
23544
23545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23546         LDKChannelInfo this_ptr_conv;
23547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23548         this_ptr_conv.is_owned = false;
23549         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
23550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23552         uint64_t ret_ref = (uint64_t)ret_var.inner;
23553         if (ret_var.is_owned) {
23554                 ret_ref |= 1;
23555         }
23556         return ret_ref;
23557 }
23558
23559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23560         LDKChannelInfo this_ptr_conv;
23561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23562         this_ptr_conv.is_owned = false;
23563         LDKChannelFeatures val_conv;
23564         val_conv.inner = (void*)(val & (~1));
23565         val_conv.is_owned = (val & 1) || (val == 0);
23566         val_conv = ChannelFeatures_clone(&val_conv);
23567         ChannelInfo_set_features(&this_ptr_conv, val_conv);
23568 }
23569
23570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
23571         LDKChannelInfo this_ptr_conv;
23572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23573         this_ptr_conv.is_owned = false;
23574         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
23576         return ret_arr;
23577 }
23578
23579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23580         LDKChannelInfo this_ptr_conv;
23581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23582         this_ptr_conv.is_owned = false;
23583         LDKPublicKey val_ref;
23584         CHECK((*env)->GetArrayLength(env, val) == 33);
23585         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23586         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
23590         LDKChannelInfo this_ptr_conv;
23591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23592         this_ptr_conv.is_owned = false;
23593         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
23594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23596         uint64_t ret_ref = (uint64_t)ret_var.inner;
23597         if (ret_var.is_owned) {
23598                 ret_ref |= 1;
23599         }
23600         return ret_ref;
23601 }
23602
23603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23604         LDKChannelInfo this_ptr_conv;
23605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23606         this_ptr_conv.is_owned = false;
23607         LDKDirectionalChannelInfo val_conv;
23608         val_conv.inner = (void*)(val & (~1));
23609         val_conv.is_owned = (val & 1) || (val == 0);
23610         val_conv = DirectionalChannelInfo_clone(&val_conv);
23611         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
23612 }
23613
23614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
23615         LDKChannelInfo this_ptr_conv;
23616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23617         this_ptr_conv.is_owned = false;
23618         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
23620         return ret_arr;
23621 }
23622
23623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23624         LDKChannelInfo this_ptr_conv;
23625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23626         this_ptr_conv.is_owned = false;
23627         LDKPublicKey val_ref;
23628         CHECK((*env)->GetArrayLength(env, val) == 33);
23629         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23630         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
23631 }
23632
23633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
23634         LDKChannelInfo this_ptr_conv;
23635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23636         this_ptr_conv.is_owned = false;
23637         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
23638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23640         uint64_t ret_ref = (uint64_t)ret_var.inner;
23641         if (ret_var.is_owned) {
23642                 ret_ref |= 1;
23643         }
23644         return ret_ref;
23645 }
23646
23647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23648         LDKChannelInfo this_ptr_conv;
23649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23650         this_ptr_conv.is_owned = false;
23651         LDKDirectionalChannelInfo val_conv;
23652         val_conv.inner = (void*)(val & (~1));
23653         val_conv.is_owned = (val & 1) || (val == 0);
23654         val_conv = DirectionalChannelInfo_clone(&val_conv);
23655         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
23656 }
23657
23658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
23659         LDKChannelInfo this_ptr_conv;
23660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23661         this_ptr_conv.is_owned = false;
23662         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23663         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
23664         uint64_t ret_ref = (uint64_t)ret_copy;
23665         return ret_ref;
23666 }
23667
23668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23669         LDKChannelInfo this_ptr_conv;
23670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23671         this_ptr_conv.is_owned = false;
23672         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23673         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
23674 }
23675
23676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23677         LDKChannelInfo this_ptr_conv;
23678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23679         this_ptr_conv.is_owned = false;
23680         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
23681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23683         uint64_t ret_ref = (uint64_t)ret_var.inner;
23684         if (ret_var.is_owned) {
23685                 ret_ref |= 1;
23686         }
23687         return ret_ref;
23688 }
23689
23690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23691         LDKChannelInfo this_ptr_conv;
23692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23693         this_ptr_conv.is_owned = false;
23694         LDKChannelAnnouncement val_conv;
23695         val_conv.inner = (void*)(val & (~1));
23696         val_conv.is_owned = (val & 1) || (val == 0);
23697         val_conv = ChannelAnnouncement_clone(&val_conv);
23698         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
23699 }
23700
23701 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) {
23702         LDKChannelFeatures features_arg_conv;
23703         features_arg_conv.inner = (void*)(features_arg & (~1));
23704         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23705         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
23706         LDKPublicKey node_one_arg_ref;
23707         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
23708         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
23709         LDKDirectionalChannelInfo one_to_two_arg_conv;
23710         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
23711         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
23712         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
23713         LDKPublicKey node_two_arg_ref;
23714         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
23715         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
23716         LDKDirectionalChannelInfo two_to_one_arg_conv;
23717         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
23718         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
23719         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
23720         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
23721         LDKChannelAnnouncement announcement_message_arg_conv;
23722         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
23723         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
23724         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
23725         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);
23726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23728         uint64_t ret_ref = (uint64_t)ret_var.inner;
23729         if (ret_var.is_owned) {
23730                 ret_ref |= 1;
23731         }
23732         return ret_ref;
23733 }
23734
23735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23736         LDKChannelInfo orig_conv;
23737         orig_conv.inner = (void*)(orig & (~1));
23738         orig_conv.is_owned = false;
23739         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
23740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23742         uint64_t ret_ref = (uint64_t)ret_var.inner;
23743         if (ret_var.is_owned) {
23744                 ret_ref |= 1;
23745         }
23746         return ret_ref;
23747 }
23748
23749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
23750         LDKChannelInfo obj_conv;
23751         obj_conv.inner = (void*)(obj & (~1));
23752         obj_conv.is_owned = false;
23753         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
23754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23756         CVec_u8Z_free(ret_var);
23757         return ret_arr;
23758 }
23759
23760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23761         LDKu8slice ser_ref;
23762         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23763         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23764         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
23765         *ret_conv = ChannelInfo_read(ser_ref);
23766         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23767         return (uint64_t)ret_conv;
23768 }
23769
23770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23771         LDKRoutingFees this_obj_conv;
23772         this_obj_conv.inner = (void*)(this_obj & (~1));
23773         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23774         RoutingFees_free(this_obj_conv);
23775 }
23776
23777 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23778         LDKRoutingFees this_ptr_conv;
23779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23780         this_ptr_conv.is_owned = false;
23781         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
23782         return ret_val;
23783 }
23784
23785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23786         LDKRoutingFees this_ptr_conv;
23787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23788         this_ptr_conv.is_owned = false;
23789         RoutingFees_set_base_msat(&this_ptr_conv, val);
23790 }
23791
23792 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
23793         LDKRoutingFees this_ptr_conv;
23794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23795         this_ptr_conv.is_owned = false;
23796         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
23797         return ret_val;
23798 }
23799
23800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23801         LDKRoutingFees this_ptr_conv;
23802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23803         this_ptr_conv.is_owned = false;
23804         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
23805 }
23806
23807 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) {
23808         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
23809         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23810         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23811         uint64_t ret_ref = (uint64_t)ret_var.inner;
23812         if (ret_var.is_owned) {
23813                 ret_ref |= 1;
23814         }
23815         return ret_ref;
23816 }
23817
23818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23819         LDKRoutingFees a_conv;
23820         a_conv.inner = (void*)(a & (~1));
23821         a_conv.is_owned = false;
23822         LDKRoutingFees b_conv;
23823         b_conv.inner = (void*)(b & (~1));
23824         b_conv.is_owned = false;
23825         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
23826         return ret_val;
23827 }
23828
23829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23830         LDKRoutingFees orig_conv;
23831         orig_conv.inner = (void*)(orig & (~1));
23832         orig_conv.is_owned = false;
23833         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
23834         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23835         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23836         uint64_t ret_ref = (uint64_t)ret_var.inner;
23837         if (ret_var.is_owned) {
23838                 ret_ref |= 1;
23839         }
23840         return ret_ref;
23841 }
23842
23843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
23844         LDKRoutingFees obj_conv;
23845         obj_conv.inner = (void*)(obj & (~1));
23846         obj_conv.is_owned = false;
23847         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
23848         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23849         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23850         CVec_u8Z_free(ret_var);
23851         return ret_arr;
23852 }
23853
23854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23855         LDKu8slice ser_ref;
23856         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23857         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23858         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
23859         *ret_conv = RoutingFees_read(ser_ref);
23860         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23861         return (uint64_t)ret_conv;
23862 }
23863
23864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23865         LDKNodeAnnouncementInfo this_obj_conv;
23866         this_obj_conv.inner = (void*)(this_obj & (~1));
23867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23868         NodeAnnouncementInfo_free(this_obj_conv);
23869 }
23870
23871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23872         LDKNodeAnnouncementInfo this_ptr_conv;
23873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23874         this_ptr_conv.is_owned = false;
23875         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
23876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23878         uint64_t ret_ref = (uint64_t)ret_var.inner;
23879         if (ret_var.is_owned) {
23880                 ret_ref |= 1;
23881         }
23882         return ret_ref;
23883 }
23884
23885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23886         LDKNodeAnnouncementInfo this_ptr_conv;
23887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23888         this_ptr_conv.is_owned = false;
23889         LDKNodeFeatures val_conv;
23890         val_conv.inner = (void*)(val & (~1));
23891         val_conv.is_owned = (val & 1) || (val == 0);
23892         val_conv = NodeFeatures_clone(&val_conv);
23893         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
23894 }
23895
23896 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
23897         LDKNodeAnnouncementInfo this_ptr_conv;
23898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23899         this_ptr_conv.is_owned = false;
23900         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
23901         return ret_val;
23902 }
23903
23904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23905         LDKNodeAnnouncementInfo this_ptr_conv;
23906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23907         this_ptr_conv.is_owned = false;
23908         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
23909 }
23910
23911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
23912         LDKNodeAnnouncementInfo this_ptr_conv;
23913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23914         this_ptr_conv.is_owned = false;
23915         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
23916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
23917         return ret_arr;
23918 }
23919
23920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23921         LDKNodeAnnouncementInfo this_ptr_conv;
23922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23923         this_ptr_conv.is_owned = false;
23924         LDKThreeBytes val_ref;
23925         CHECK((*env)->GetArrayLength(env, val) == 3);
23926         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
23927         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
23928 }
23929
23930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
23931         LDKNodeAnnouncementInfo this_ptr_conv;
23932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23933         this_ptr_conv.is_owned = false;
23934         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
23936         return ret_arr;
23937 }
23938
23939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23940         LDKNodeAnnouncementInfo this_ptr_conv;
23941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23942         this_ptr_conv.is_owned = false;
23943         LDKThirtyTwoBytes val_ref;
23944         CHECK((*env)->GetArrayLength(env, val) == 32);
23945         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23946         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
23947 }
23948
23949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
23950         LDKNodeAnnouncementInfo this_ptr_conv;
23951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23952         this_ptr_conv.is_owned = false;
23953         LDKCVec_NetAddressZ val_constr;
23954         val_constr.datalen = (*env)->GetArrayLength(env, val);
23955         if (val_constr.datalen > 0)
23956                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
23957         else
23958                 val_constr.data = NULL;
23959         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
23960         for (size_t m = 0; m < val_constr.datalen; m++) {
23961                 int64_t val_conv_12 = val_vals[m];
23962                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
23963                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
23964                 val_constr.data[m] = val_conv_12_conv;
23965         }
23966         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
23967         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
23968 }
23969
23970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
23971         LDKNodeAnnouncementInfo this_ptr_conv;
23972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23973         this_ptr_conv.is_owned = false;
23974         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
23975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23977         uint64_t ret_ref = (uint64_t)ret_var.inner;
23978         if (ret_var.is_owned) {
23979                 ret_ref |= 1;
23980         }
23981         return ret_ref;
23982 }
23983
23984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23985         LDKNodeAnnouncementInfo this_ptr_conv;
23986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23987         this_ptr_conv.is_owned = false;
23988         LDKNodeAnnouncement val_conv;
23989         val_conv.inner = (void*)(val & (~1));
23990         val_conv.is_owned = (val & 1) || (val == 0);
23991         val_conv = NodeAnnouncement_clone(&val_conv);
23992         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
23993 }
23994
23995 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) {
23996         LDKNodeFeatures features_arg_conv;
23997         features_arg_conv.inner = (void*)(features_arg & (~1));
23998         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23999         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24000         LDKThreeBytes rgb_arg_ref;
24001         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
24002         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
24003         LDKThirtyTwoBytes alias_arg_ref;
24004         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
24005         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
24006         LDKCVec_NetAddressZ addresses_arg_constr;
24007         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
24008         if (addresses_arg_constr.datalen > 0)
24009                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24010         else
24011                 addresses_arg_constr.data = NULL;
24012         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
24013         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24014                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
24015                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24016                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24017         }
24018         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
24019         LDKNodeAnnouncement announcement_message_arg_conv;
24020         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24021         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24022         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24023         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24024         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24025         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24026         uint64_t ret_ref = (uint64_t)ret_var.inner;
24027         if (ret_var.is_owned) {
24028                 ret_ref |= 1;
24029         }
24030         return ret_ref;
24031 }
24032
24033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24034         LDKNodeAnnouncementInfo orig_conv;
24035         orig_conv.inner = (void*)(orig & (~1));
24036         orig_conv.is_owned = false;
24037         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24040         uint64_t ret_ref = (uint64_t)ret_var.inner;
24041         if (ret_var.is_owned) {
24042                 ret_ref |= 1;
24043         }
24044         return ret_ref;
24045 }
24046
24047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24048         LDKNodeAnnouncementInfo obj_conv;
24049         obj_conv.inner = (void*)(obj & (~1));
24050         obj_conv.is_owned = false;
24051         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24052         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24053         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24054         CVec_u8Z_free(ret_var);
24055         return ret_arr;
24056 }
24057
24058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24059         LDKu8slice ser_ref;
24060         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24061         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24062         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24063         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24064         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24065         return (uint64_t)ret_conv;
24066 }
24067
24068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24069         LDKNodeInfo this_obj_conv;
24070         this_obj_conv.inner = (void*)(this_obj & (~1));
24071         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24072         NodeInfo_free(this_obj_conv);
24073 }
24074
24075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
24076         LDKNodeInfo this_ptr_conv;
24077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24078         this_ptr_conv.is_owned = false;
24079         LDKCVec_u64Z val_constr;
24080         val_constr.datalen = (*env)->GetArrayLength(env, val);
24081         if (val_constr.datalen > 0)
24082                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24083         else
24084                 val_constr.data = NULL;
24085         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
24086         for (size_t g = 0; g < val_constr.datalen; g++) {
24087                 int64_t val_conv_6 = val_vals[g];
24088                 val_constr.data[g] = val_conv_6;
24089         }
24090         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
24091         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24092 }
24093
24094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24095         LDKNodeInfo this_ptr_conv;
24096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24097         this_ptr_conv.is_owned = false;
24098         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24101         uint64_t ret_ref = (uint64_t)ret_var.inner;
24102         if (ret_var.is_owned) {
24103                 ret_ref |= 1;
24104         }
24105         return ret_ref;
24106 }
24107
24108 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) {
24109         LDKNodeInfo this_ptr_conv;
24110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24111         this_ptr_conv.is_owned = false;
24112         LDKRoutingFees val_conv;
24113         val_conv.inner = (void*)(val & (~1));
24114         val_conv.is_owned = (val & 1) || (val == 0);
24115         val_conv = RoutingFees_clone(&val_conv);
24116         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24117 }
24118
24119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24120         LDKNodeInfo this_ptr_conv;
24121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24122         this_ptr_conv.is_owned = false;
24123         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24126         uint64_t ret_ref = (uint64_t)ret_var.inner;
24127         if (ret_var.is_owned) {
24128                 ret_ref |= 1;
24129         }
24130         return ret_ref;
24131 }
24132
24133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24134         LDKNodeInfo this_ptr_conv;
24135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24136         this_ptr_conv.is_owned = false;
24137         LDKNodeAnnouncementInfo val_conv;
24138         val_conv.inner = (void*)(val & (~1));
24139         val_conv.is_owned = (val & 1) || (val == 0);
24140         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24141         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24142 }
24143
24144 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) {
24145         LDKCVec_u64Z channels_arg_constr;
24146         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
24147         if (channels_arg_constr.datalen > 0)
24148                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24149         else
24150                 channels_arg_constr.data = NULL;
24151         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
24152         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
24153                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
24154                 channels_arg_constr.data[g] = channels_arg_conv_6;
24155         }
24156         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
24157         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24158         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24159         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24160         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24161         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24162         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24163         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24164         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24165         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24168         uint64_t ret_ref = (uint64_t)ret_var.inner;
24169         if (ret_var.is_owned) {
24170                 ret_ref |= 1;
24171         }
24172         return ret_ref;
24173 }
24174
24175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24176         LDKNodeInfo orig_conv;
24177         orig_conv.inner = (void*)(orig & (~1));
24178         orig_conv.is_owned = false;
24179         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
24180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24182         uint64_t ret_ref = (uint64_t)ret_var.inner;
24183         if (ret_var.is_owned) {
24184                 ret_ref |= 1;
24185         }
24186         return ret_ref;
24187 }
24188
24189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24190         LDKNodeInfo obj_conv;
24191         obj_conv.inner = (void*)(obj & (~1));
24192         obj_conv.is_owned = false;
24193         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
24194         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24195         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24196         CVec_u8Z_free(ret_var);
24197         return ret_arr;
24198 }
24199
24200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24201         LDKu8slice ser_ref;
24202         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24203         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24204         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
24205         *ret_conv = NodeInfo_read(ser_ref);
24206         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24207         return (uint64_t)ret_conv;
24208 }
24209
24210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
24211         LDKNetworkGraph obj_conv;
24212         obj_conv.inner = (void*)(obj & (~1));
24213         obj_conv.is_owned = false;
24214         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
24215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24217         CVec_u8Z_free(ret_var);
24218         return ret_arr;
24219 }
24220
24221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24222         LDKu8slice ser_ref;
24223         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24224         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24225         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
24226         *ret_conv = NetworkGraph_read(ser_ref);
24227         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24228         return (uint64_t)ret_conv;
24229 }
24230
24231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
24232         LDKThirtyTwoBytes genesis_hash_ref;
24233         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24234         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24235         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
24236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24238         uint64_t ret_ref = (uint64_t)ret_var.inner;
24239         if (ret_var.is_owned) {
24240                 ret_ref |= 1;
24241         }
24242         return ret_ref;
24243 }
24244
24245 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) {
24246         LDKNetworkGraph this_arg_conv;
24247         this_arg_conv.inner = (void*)(this_arg & (~1));
24248         this_arg_conv.is_owned = false;
24249         LDKNodeAnnouncement msg_conv;
24250         msg_conv.inner = (void*)(msg & (~1));
24251         msg_conv.is_owned = false;
24252         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24253         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
24254         return (uint64_t)ret_conv;
24255 }
24256
24257 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) {
24258         LDKNetworkGraph this_arg_conv;
24259         this_arg_conv.inner = (void*)(this_arg & (~1));
24260         this_arg_conv.is_owned = false;
24261         LDKUnsignedNodeAnnouncement msg_conv;
24262         msg_conv.inner = (void*)(msg & (~1));
24263         msg_conv.is_owned = false;
24264         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24265         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
24266         return (uint64_t)ret_conv;
24267 }
24268
24269 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) {
24270         LDKNetworkGraph this_arg_conv;
24271         this_arg_conv.inner = (void*)(this_arg & (~1));
24272         this_arg_conv.is_owned = false;
24273         LDKChannelAnnouncement msg_conv;
24274         msg_conv.inner = (void*)(msg & (~1));
24275         msg_conv.is_owned = false;
24276         LDKAccess *chain_access_conv_ptr = NULL;
24277         if (chain_access != 0) {
24278                 LDKAccess chain_access_conv;
24279                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24280                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24281                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24282                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24283                 }
24284                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24285                 *chain_access_conv_ptr = chain_access_conv;
24286         }
24287         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24288         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24289         return (uint64_t)ret_conv;
24290 }
24291
24292 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) {
24293         LDKNetworkGraph this_arg_conv;
24294         this_arg_conv.inner = (void*)(this_arg & (~1));
24295         this_arg_conv.is_owned = false;
24296         LDKUnsignedChannelAnnouncement msg_conv;
24297         msg_conv.inner = (void*)(msg & (~1));
24298         msg_conv.is_owned = false;
24299         LDKAccess *chain_access_conv_ptr = NULL;
24300         if (chain_access != 0) {
24301                 LDKAccess chain_access_conv;
24302                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24303                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24304                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24305                         LDKAccess_JCalls_clone(chain_access_conv.this_arg);
24306                 }
24307                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24308                 *chain_access_conv_ptr = chain_access_conv;
24309         }
24310         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24311         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
24312         return (uint64_t)ret_conv;
24313 }
24314
24315 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) {
24316         LDKNetworkGraph this_arg_conv;
24317         this_arg_conv.inner = (void*)(this_arg & (~1));
24318         this_arg_conv.is_owned = false;
24319         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
24320 }
24321
24322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24323         LDKNetworkGraph this_arg_conv;
24324         this_arg_conv.inner = (void*)(this_arg & (~1));
24325         this_arg_conv.is_owned = false;
24326         LDKChannelUpdate msg_conv;
24327         msg_conv.inner = (void*)(msg & (~1));
24328         msg_conv.is_owned = false;
24329         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24330         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
24331         return (uint64_t)ret_conv;
24332 }
24333
24334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
24335         LDKNetworkGraph this_arg_conv;
24336         this_arg_conv.inner = (void*)(this_arg & (~1));
24337         this_arg_conv.is_owned = false;
24338         LDKUnsignedChannelUpdate msg_conv;
24339         msg_conv.inner = (void*)(msg & (~1));
24340         msg_conv.is_owned = false;
24341         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24342         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
24343         return (uint64_t)ret_conv;
24344 }
24345
24346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24347         LDKFilesystemPersister this_obj_conv;
24348         this_obj_conv.inner = (void*)(this_obj & (~1));
24349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24350         FilesystemPersister_free(this_obj_conv);
24351 }
24352
24353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
24354         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
24355         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
24356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24358         uint64_t ret_ref = (uint64_t)ret_var.inner;
24359         if (ret_var.is_owned) {
24360                 ret_ref |= 1;
24361         }
24362         return ret_ref;
24363 }
24364
24365 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
24366         LDKFilesystemPersister this_arg_conv;
24367         this_arg_conv.inner = (void*)(this_arg & (~1));
24368         this_arg_conv.is_owned = false;
24369         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
24370         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24371         return ret_conv;
24372 }
24373
24374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
24375         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
24376         LDKChannelManager manager_conv;
24377         manager_conv.inner = (void*)(manager & (~1));
24378         manager_conv.is_owned = false;
24379         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24380         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
24381         return (uint64_t)ret_conv;
24382 }
24383
24384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
24385         LDKFilesystemPersister this_arg_conv;
24386         this_arg_conv.inner = (void*)(this_arg & (~1));
24387         this_arg_conv.is_owned = false;
24388         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
24389         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24390                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24391                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
24392         }
24393         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
24394         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
24395         return (uint64_t)ret_conv;
24396 }
24397
24398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
24399         LDKFilesystemPersister this_arg_conv;
24400         this_arg_conv.inner = (void*)(this_arg & (~1));
24401         this_arg_conv.is_owned = false;
24402         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
24403         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
24404         return (uint64_t)ret;
24405 }
24406
24407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24408         LDKBackgroundProcessor this_obj_conv;
24409         this_obj_conv.inner = (void*)(this_obj & (~1));
24410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24411         BackgroundProcessor_free(this_obj_conv);
24412 }
24413
24414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24415         if ((this_ptr & 1) != 0) return;
24416         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
24417         FREE((void*)this_ptr);
24418         ChannelManagerPersister_free(this_ptr_conv);
24419 }
24420
24421 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) {
24422         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
24423         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
24424                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24425                 LDKChannelManagerPersister_JCalls_clone(persister_conv.this_arg);
24426         }
24427         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
24428         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
24429                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24430                 LDKEventHandler_JCalls_clone(event_handler_conv.this_arg);
24431         }
24432         LDKChainMonitor chain_monitor_conv;
24433         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
24434         chain_monitor_conv.is_owned = false;
24435         LDKChannelManager channel_manager_conv;
24436         channel_manager_conv.inner = (void*)(channel_manager & (~1));
24437         channel_manager_conv.is_owned = false;
24438         LDKPeerManager peer_manager_conv;
24439         peer_manager_conv.inner = (void*)(peer_manager & (~1));
24440         peer_manager_conv.is_owned = false;
24441         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24442         if (logger_conv.free == LDKLogger_JCalls_free) {
24443                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24444                 LDKLogger_JCalls_clone(logger_conv.this_arg);
24445         }
24446         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
24447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24449         uint64_t ret_ref = (uint64_t)ret_var.inner;
24450         if (ret_var.is_owned) {
24451                 ret_ref |= 1;
24452         }
24453         return ret_ref;
24454 }
24455
24456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
24457         LDKBackgroundProcessor this_arg_conv;
24458         this_arg_conv.inner = (void*)(this_arg & (~1));
24459         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24460         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
24461         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
24462         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
24463         return (uint64_t)ret_conv;
24464 }
24465
24466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
24467         check_platform();
24468 }
24469
24470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24471         LDKInvoice this_obj_conv;
24472         this_obj_conv.inner = (void*)(this_obj & (~1));
24473         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24474         Invoice_free(this_obj_conv);
24475 }
24476
24477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24478         LDKInvoice a_conv;
24479         a_conv.inner = (void*)(a & (~1));
24480         a_conv.is_owned = false;
24481         LDKInvoice b_conv;
24482         b_conv.inner = (void*)(b & (~1));
24483         b_conv.is_owned = false;
24484         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
24485         return ret_val;
24486 }
24487
24488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24489         LDKInvoice orig_conv;
24490         orig_conv.inner = (void*)(orig & (~1));
24491         orig_conv.is_owned = false;
24492         LDKInvoice ret_var = Invoice_clone(&orig_conv);
24493         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24494         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24495         uint64_t ret_ref = (uint64_t)ret_var.inner;
24496         if (ret_var.is_owned) {
24497                 ret_ref |= 1;
24498         }
24499         return ret_ref;
24500 }
24501
24502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24503         LDKSignedRawInvoice this_obj_conv;
24504         this_obj_conv.inner = (void*)(this_obj & (~1));
24505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24506         SignedRawInvoice_free(this_obj_conv);
24507 }
24508
24509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24510         LDKSignedRawInvoice a_conv;
24511         a_conv.inner = (void*)(a & (~1));
24512         a_conv.is_owned = false;
24513         LDKSignedRawInvoice b_conv;
24514         b_conv.inner = (void*)(b & (~1));
24515         b_conv.is_owned = false;
24516         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
24517         return ret_val;
24518 }
24519
24520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24521         LDKSignedRawInvoice orig_conv;
24522         orig_conv.inner = (void*)(orig & (~1));
24523         orig_conv.is_owned = false;
24524         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
24525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24527         uint64_t ret_ref = (uint64_t)ret_var.inner;
24528         if (ret_var.is_owned) {
24529                 ret_ref |= 1;
24530         }
24531         return ret_ref;
24532 }
24533
24534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24535         LDKRawInvoice this_obj_conv;
24536         this_obj_conv.inner = (void*)(this_obj & (~1));
24537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24538         RawInvoice_free(this_obj_conv);
24539 }
24540
24541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
24542         LDKRawInvoice this_ptr_conv;
24543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24544         this_ptr_conv.is_owned = false;
24545         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
24546         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24547         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24548         uint64_t ret_ref = (uint64_t)ret_var.inner;
24549         if (ret_var.is_owned) {
24550                 ret_ref |= 1;
24551         }
24552         return ret_ref;
24553 }
24554
24555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24556         LDKRawInvoice this_ptr_conv;
24557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24558         this_ptr_conv.is_owned = false;
24559         LDKRawDataPart val_conv;
24560         val_conv.inner = (void*)(val & (~1));
24561         val_conv.is_owned = (val & 1) || (val == 0);
24562         val_conv = RawDataPart_clone(&val_conv);
24563         RawInvoice_set_data(&this_ptr_conv, val_conv);
24564 }
24565
24566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24567         LDKRawInvoice a_conv;
24568         a_conv.inner = (void*)(a & (~1));
24569         a_conv.is_owned = false;
24570         LDKRawInvoice b_conv;
24571         b_conv.inner = (void*)(b & (~1));
24572         b_conv.is_owned = false;
24573         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
24574         return ret_val;
24575 }
24576
24577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24578         LDKRawInvoice orig_conv;
24579         orig_conv.inner = (void*)(orig & (~1));
24580         orig_conv.is_owned = false;
24581         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
24582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24584         uint64_t ret_ref = (uint64_t)ret_var.inner;
24585         if (ret_var.is_owned) {
24586                 ret_ref |= 1;
24587         }
24588         return ret_ref;
24589 }
24590
24591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24592         LDKRawDataPart this_obj_conv;
24593         this_obj_conv.inner = (void*)(this_obj & (~1));
24594         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24595         RawDataPart_free(this_obj_conv);
24596 }
24597
24598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
24599         LDKRawDataPart this_ptr_conv;
24600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24601         this_ptr_conv.is_owned = false;
24602         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
24603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24605         uint64_t ret_ref = (uint64_t)ret_var.inner;
24606         if (ret_var.is_owned) {
24607                 ret_ref |= 1;
24608         }
24609         return ret_ref;
24610 }
24611
24612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24613         LDKRawDataPart this_ptr_conv;
24614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24615         this_ptr_conv.is_owned = false;
24616         LDKPositiveTimestamp val_conv;
24617         val_conv.inner = (void*)(val & (~1));
24618         val_conv.is_owned = (val & 1) || (val == 0);
24619         val_conv = PositiveTimestamp_clone(&val_conv);
24620         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
24621 }
24622
24623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24624         LDKRawDataPart a_conv;
24625         a_conv.inner = (void*)(a & (~1));
24626         a_conv.is_owned = false;
24627         LDKRawDataPart b_conv;
24628         b_conv.inner = (void*)(b & (~1));
24629         b_conv.is_owned = false;
24630         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
24631         return ret_val;
24632 }
24633
24634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24635         LDKRawDataPart orig_conv;
24636         orig_conv.inner = (void*)(orig & (~1));
24637         orig_conv.is_owned = false;
24638         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
24639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24641         uint64_t ret_ref = (uint64_t)ret_var.inner;
24642         if (ret_var.is_owned) {
24643                 ret_ref |= 1;
24644         }
24645         return ret_ref;
24646 }
24647
24648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24649         LDKPositiveTimestamp this_obj_conv;
24650         this_obj_conv.inner = (void*)(this_obj & (~1));
24651         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24652         PositiveTimestamp_free(this_obj_conv);
24653 }
24654
24655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24656         LDKPositiveTimestamp a_conv;
24657         a_conv.inner = (void*)(a & (~1));
24658         a_conv.is_owned = false;
24659         LDKPositiveTimestamp b_conv;
24660         b_conv.inner = (void*)(b & (~1));
24661         b_conv.is_owned = false;
24662         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
24663         return ret_val;
24664 }
24665
24666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24667         LDKPositiveTimestamp orig_conv;
24668         orig_conv.inner = (void*)(orig & (~1));
24669         orig_conv.is_owned = false;
24670         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
24671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24673         uint64_t ret_ref = (uint64_t)ret_var.inner;
24674         if (ret_var.is_owned) {
24675                 ret_ref |= 1;
24676         }
24677         return ret_ref;
24678 }
24679
24680 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24681         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
24682         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
24683         return ret_conv;
24684 }
24685
24686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24687         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
24688         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
24689         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
24690         return ret_val;
24691 }
24692
24693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
24694         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
24695         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
24696         return ret_val;
24697 }
24698
24699 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24700         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
24701         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
24702         return ret_conv;
24703 }
24704
24705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24706         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
24707         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
24708         jboolean ret_val = Currency_eq(a_conv, b_conv);
24709         return ret_val;
24710 }
24711
24712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24713         LDKSha256 this_obj_conv;
24714         this_obj_conv.inner = (void*)(this_obj & (~1));
24715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24716         Sha256_free(this_obj_conv);
24717 }
24718
24719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24720         LDKSha256 a_conv;
24721         a_conv.inner = (void*)(a & (~1));
24722         a_conv.is_owned = false;
24723         LDKSha256 b_conv;
24724         b_conv.inner = (void*)(b & (~1));
24725         b_conv.is_owned = false;
24726         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
24727         return ret_val;
24728 }
24729
24730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24731         LDKSha256 orig_conv;
24732         orig_conv.inner = (void*)(orig & (~1));
24733         orig_conv.is_owned = false;
24734         LDKSha256 ret_var = Sha256_clone(&orig_conv);
24735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24737         uint64_t ret_ref = (uint64_t)ret_var.inner;
24738         if (ret_var.is_owned) {
24739                 ret_ref |= 1;
24740         }
24741         return ret_ref;
24742 }
24743
24744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24745         LDKDescription this_obj_conv;
24746         this_obj_conv.inner = (void*)(this_obj & (~1));
24747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24748         Description_free(this_obj_conv);
24749 }
24750
24751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24752         LDKDescription a_conv;
24753         a_conv.inner = (void*)(a & (~1));
24754         a_conv.is_owned = false;
24755         LDKDescription b_conv;
24756         b_conv.inner = (void*)(b & (~1));
24757         b_conv.is_owned = false;
24758         jboolean ret_val = Description_eq(&a_conv, &b_conv);
24759         return ret_val;
24760 }
24761
24762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24763         LDKDescription orig_conv;
24764         orig_conv.inner = (void*)(orig & (~1));
24765         orig_conv.is_owned = false;
24766         LDKDescription ret_var = Description_clone(&orig_conv);
24767         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24768         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24769         uint64_t ret_ref = (uint64_t)ret_var.inner;
24770         if (ret_var.is_owned) {
24771                 ret_ref |= 1;
24772         }
24773         return ret_ref;
24774 }
24775
24776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24777         LDKPayeePubKey this_obj_conv;
24778         this_obj_conv.inner = (void*)(this_obj & (~1));
24779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24780         PayeePubKey_free(this_obj_conv);
24781 }
24782
24783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24784         LDKPayeePubKey a_conv;
24785         a_conv.inner = (void*)(a & (~1));
24786         a_conv.is_owned = false;
24787         LDKPayeePubKey b_conv;
24788         b_conv.inner = (void*)(b & (~1));
24789         b_conv.is_owned = false;
24790         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
24791         return ret_val;
24792 }
24793
24794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24795         LDKPayeePubKey orig_conv;
24796         orig_conv.inner = (void*)(orig & (~1));
24797         orig_conv.is_owned = false;
24798         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
24799         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24800         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24801         uint64_t ret_ref = (uint64_t)ret_var.inner;
24802         if (ret_var.is_owned) {
24803                 ret_ref |= 1;
24804         }
24805         return ret_ref;
24806 }
24807
24808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24809         LDKExpiryTime this_obj_conv;
24810         this_obj_conv.inner = (void*)(this_obj & (~1));
24811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24812         ExpiryTime_free(this_obj_conv);
24813 }
24814
24815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24816         LDKExpiryTime a_conv;
24817         a_conv.inner = (void*)(a & (~1));
24818         a_conv.is_owned = false;
24819         LDKExpiryTime b_conv;
24820         b_conv.inner = (void*)(b & (~1));
24821         b_conv.is_owned = false;
24822         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
24823         return ret_val;
24824 }
24825
24826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24827         LDKExpiryTime orig_conv;
24828         orig_conv.inner = (void*)(orig & (~1));
24829         orig_conv.is_owned = false;
24830         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
24831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24833         uint64_t ret_ref = (uint64_t)ret_var.inner;
24834         if (ret_var.is_owned) {
24835                 ret_ref |= 1;
24836         }
24837         return ret_ref;
24838 }
24839
24840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24841         LDKMinFinalCltvExpiry this_obj_conv;
24842         this_obj_conv.inner = (void*)(this_obj & (~1));
24843         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24844         MinFinalCltvExpiry_free(this_obj_conv);
24845 }
24846
24847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24848         LDKMinFinalCltvExpiry a_conv;
24849         a_conv.inner = (void*)(a & (~1));
24850         a_conv.is_owned = false;
24851         LDKMinFinalCltvExpiry b_conv;
24852         b_conv.inner = (void*)(b & (~1));
24853         b_conv.is_owned = false;
24854         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
24855         return ret_val;
24856 }
24857
24858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24859         LDKMinFinalCltvExpiry orig_conv;
24860         orig_conv.inner = (void*)(orig & (~1));
24861         orig_conv.is_owned = false;
24862         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
24863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24865         uint64_t ret_ref = (uint64_t)ret_var.inner;
24866         if (ret_var.is_owned) {
24867                 ret_ref |= 1;
24868         }
24869         return ret_ref;
24870 }
24871
24872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24873         if ((this_ptr & 1) != 0) return;
24874         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
24875         FREE((void*)this_ptr);
24876         Fallback_free(this_ptr_conv);
24877 }
24878
24879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24880         LDKFallback* orig_conv = (LDKFallback*)orig;
24881         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24882         *ret_copy = Fallback_clone(orig_conv);
24883         uint64_t ret_ref = (uint64_t)ret_copy;
24884         return ret_ref;
24885 }
24886
24887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24888         LDKFallback* a_conv = (LDKFallback*)a;
24889         LDKFallback* b_conv = (LDKFallback*)b;
24890         jboolean ret_val = Fallback_eq(a_conv, b_conv);
24891         return ret_val;
24892 }
24893
24894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24895         LDKInvoiceSignature this_obj_conv;
24896         this_obj_conv.inner = (void*)(this_obj & (~1));
24897         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24898         InvoiceSignature_free(this_obj_conv);
24899 }
24900
24901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24902         LDKInvoiceSignature a_conv;
24903         a_conv.inner = (void*)(a & (~1));
24904         a_conv.is_owned = false;
24905         LDKInvoiceSignature b_conv;
24906         b_conv.inner = (void*)(b & (~1));
24907         b_conv.is_owned = false;
24908         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
24909         return ret_val;
24910 }
24911
24912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24913         LDKInvoiceSignature orig_conv;
24914         orig_conv.inner = (void*)(orig & (~1));
24915         orig_conv.is_owned = false;
24916         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
24917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24919         uint64_t ret_ref = (uint64_t)ret_var.inner;
24920         if (ret_var.is_owned) {
24921                 ret_ref |= 1;
24922         }
24923         return ret_ref;
24924 }
24925
24926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24927         LDKPrivateRoute this_obj_conv;
24928         this_obj_conv.inner = (void*)(this_obj & (~1));
24929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24930         PrivateRoute_free(this_obj_conv);
24931 }
24932
24933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24934         LDKPrivateRoute a_conv;
24935         a_conv.inner = (void*)(a & (~1));
24936         a_conv.is_owned = false;
24937         LDKPrivateRoute b_conv;
24938         b_conv.inner = (void*)(b & (~1));
24939         b_conv.is_owned = false;
24940         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
24941         return ret_val;
24942 }
24943
24944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24945         LDKPrivateRoute orig_conv;
24946         orig_conv.inner = (void*)(orig & (~1));
24947         orig_conv.is_owned = false;
24948         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
24949         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24950         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24951         uint64_t ret_ref = (uint64_t)ret_var.inner;
24952         if (ret_var.is_owned) {
24953                 ret_ref |= 1;
24954         }
24955         return ret_ref;
24956 }
24957
24958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
24959         LDKSignedRawInvoice this_arg_conv;
24960         this_arg_conv.inner = (void*)(this_arg & (~1));
24961         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24962         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
24963         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24964         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
24965         return (uint64_t)ret_ref;
24966 }
24967
24968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
24969         LDKSignedRawInvoice this_arg_conv;
24970         this_arg_conv.inner = (void*)(this_arg & (~1));
24971         this_arg_conv.is_owned = false;
24972         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
24973         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24974         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24975         uint64_t ret_ref = (uint64_t)ret_var.inner;
24976         if (ret_var.is_owned) {
24977                 ret_ref |= 1;
24978         }
24979         return ret_ref;
24980 }
24981
24982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
24983         LDKSignedRawInvoice this_arg_conv;
24984         this_arg_conv.inner = (void*)(this_arg & (~1));
24985         this_arg_conv.is_owned = false;
24986         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
24988         return ret_arr;
24989 }
24990
24991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
24992         LDKSignedRawInvoice this_arg_conv;
24993         this_arg_conv.inner = (void*)(this_arg & (~1));
24994         this_arg_conv.is_owned = false;
24995         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
24996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24998         uint64_t ret_ref = (uint64_t)ret_var.inner;
24999         if (ret_var.is_owned) {
25000                 ret_ref |= 1;
25001         }
25002         return ret_ref;
25003 }
25004
25005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25006         LDKSignedRawInvoice this_arg_conv;
25007         this_arg_conv.inner = (void*)(this_arg & (~1));
25008         this_arg_conv.is_owned = false;
25009         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25010         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25011         return (uint64_t)ret_conv;
25012 }
25013
25014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25015         LDKSignedRawInvoice this_arg_conv;
25016         this_arg_conv.inner = (void*)(this_arg & (~1));
25017         this_arg_conv.is_owned = false;
25018         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25019         return ret_val;
25020 }
25021
25022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25023         LDKRawInvoice this_arg_conv;
25024         this_arg_conv.inner = (void*)(this_arg & (~1));
25025         this_arg_conv.is_owned = false;
25026         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
25028         return ret_arr;
25029 }
25030
25031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25032         LDKRawInvoice this_arg_conv;
25033         this_arg_conv.inner = (void*)(this_arg & (~1));
25034         this_arg_conv.is_owned = false;
25035         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25036         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25037         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25038         uint64_t ret_ref = (uint64_t)ret_var.inner;
25039         if (ret_var.is_owned) {
25040                 ret_ref |= 1;
25041         }
25042         return ret_ref;
25043 }
25044
25045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
25046         LDKRawInvoice this_arg_conv;
25047         this_arg_conv.inner = (void*)(this_arg & (~1));
25048         this_arg_conv.is_owned = false;
25049         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25050         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25051         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25052         uint64_t ret_ref = (uint64_t)ret_var.inner;
25053         if (ret_var.is_owned) {
25054                 ret_ref |= 1;
25055         }
25056         return ret_ref;
25057 }
25058
25059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25060         LDKRawInvoice this_arg_conv;
25061         this_arg_conv.inner = (void*)(this_arg & (~1));
25062         this_arg_conv.is_owned = false;
25063         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25066         uint64_t ret_ref = (uint64_t)ret_var.inner;
25067         if (ret_var.is_owned) {
25068                 ret_ref |= 1;
25069         }
25070         return ret_ref;
25071 }
25072
25073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25074         LDKRawInvoice this_arg_conv;
25075         this_arg_conv.inner = (void*)(this_arg & (~1));
25076         this_arg_conv.is_owned = false;
25077         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25080         uint64_t ret_ref = (uint64_t)ret_var.inner;
25081         if (ret_var.is_owned) {
25082                 ret_ref |= 1;
25083         }
25084         return ret_ref;
25085 }
25086
25087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25088         LDKRawInvoice this_arg_conv;
25089         this_arg_conv.inner = (void*)(this_arg & (~1));
25090         this_arg_conv.is_owned = false;
25091         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25094         uint64_t ret_ref = (uint64_t)ret_var.inner;
25095         if (ret_var.is_owned) {
25096                 ret_ref |= 1;
25097         }
25098         return ret_ref;
25099 }
25100
25101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25102         LDKRawInvoice this_arg_conv;
25103         this_arg_conv.inner = (void*)(this_arg & (~1));
25104         this_arg_conv.is_owned = false;
25105         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25108         uint64_t ret_ref = (uint64_t)ret_var.inner;
25109         if (ret_var.is_owned) {
25110                 ret_ref |= 1;
25111         }
25112         return ret_ref;
25113 }
25114
25115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25116         LDKRawInvoice this_arg_conv;
25117         this_arg_conv.inner = (void*)(this_arg & (~1));
25118         this_arg_conv.is_owned = false;
25119         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25120         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
25121         return ret_arr;
25122 }
25123
25124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25125         LDKRawInvoice this_arg_conv;
25126         this_arg_conv.inner = (void*)(this_arg & (~1));
25127         this_arg_conv.is_owned = false;
25128         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25129         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25130         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25131         uint64_t ret_ref = (uint64_t)ret_var.inner;
25132         if (ret_var.is_owned) {
25133                 ret_ref |= 1;
25134         }
25135         return ret_ref;
25136 }
25137
25138 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25139         LDKRawInvoice this_arg_conv;
25140         this_arg_conv.inner = (void*)(this_arg & (~1));
25141         this_arg_conv.is_owned = false;
25142         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
25143         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25144         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25145         for (size_t o = 0; o < ret_var.datalen; o++) {
25146                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25147                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25148                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25149                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25150                 if (ret_conv_14_var.is_owned) {
25151                         ret_conv_14_ref |= 1;
25152                 }
25153                 ret_arr_ptr[o] = ret_conv_14_ref;
25154         }
25155         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25156         FREE(ret_var.data);
25157         return ret_arr;
25158 }
25159
25160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25161         LDKRawInvoice this_arg_conv;
25162         this_arg_conv.inner = (void*)(this_arg & (~1));
25163         this_arg_conv.is_owned = false;
25164         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25165         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
25166         uint64_t ret_ref = (uint64_t)ret_copy;
25167         return ret_ref;
25168 }
25169
25170 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25171         LDKRawInvoice this_arg_conv;
25172         this_arg_conv.inner = (void*)(this_arg & (~1));
25173         this_arg_conv.is_owned = false;
25174         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
25175         return ret_conv;
25176 }
25177
25178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
25179         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25180         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
25181         return (uint64_t)ret_conv;
25182 }
25183
25184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
25185         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25186         *ret_conv = PositiveTimestamp_from_system_time(time);
25187         return (uint64_t)ret_conv;
25188 }
25189
25190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25191         LDKPositiveTimestamp this_arg_conv;
25192         this_arg_conv.inner = (void*)(this_arg & (~1));
25193         this_arg_conv.is_owned = false;
25194         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
25195         return ret_val;
25196 }
25197
25198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25199         LDKPositiveTimestamp this_arg_conv;
25200         this_arg_conv.inner = (void*)(this_arg & (~1));
25201         this_arg_conv.is_owned = false;
25202         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
25203         return ret_val;
25204 }
25205
25206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
25207         LDKInvoice this_arg_conv;
25208         this_arg_conv.inner = (void*)(this_arg & (~1));
25209         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25210         this_arg_conv = Invoice_clone(&this_arg_conv);
25211         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
25212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25214         uint64_t ret_ref = (uint64_t)ret_var.inner;
25215         if (ret_var.is_owned) {
25216                 ret_ref |= 1;
25217         }
25218         return ret_ref;
25219 }
25220
25221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
25222         LDKInvoice this_arg_conv;
25223         this_arg_conv.inner = (void*)(this_arg & (~1));
25224         this_arg_conv.is_owned = false;
25225         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
25226         *ret_conv = Invoice_check_signature(&this_arg_conv);
25227         return (uint64_t)ret_conv;
25228 }
25229
25230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
25231         LDKSignedRawInvoice signed_invoice_conv;
25232         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
25233         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
25234         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
25235         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
25236         *ret_conv = Invoice_from_signed(signed_invoice_conv);
25237         return (uint64_t)ret_conv;
25238 }
25239
25240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
25241         LDKInvoice this_arg_conv;
25242         this_arg_conv.inner = (void*)(this_arg & (~1));
25243         this_arg_conv.is_owned = false;
25244         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
25245         return ret_val;
25246 }
25247
25248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25249         LDKInvoice this_arg_conv;
25250         this_arg_conv.inner = (void*)(this_arg & (~1));
25251         this_arg_conv.is_owned = false;
25252         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
25254         return ret_arr;
25255 }
25256
25257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25258         LDKInvoice this_arg_conv;
25259         this_arg_conv.inner = (void*)(this_arg & (~1));
25260         this_arg_conv.is_owned = false;
25261         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
25263         return ret_arr;
25264 }
25265
25266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
25267         LDKInvoice this_arg_conv;
25268         this_arg_conv.inner = (void*)(this_arg & (~1));
25269         this_arg_conv.is_owned = false;
25270         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25271         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
25272         return ret_arr;
25273 }
25274
25275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
25276         LDKInvoice this_arg_conv;
25277         this_arg_conv.inner = (void*)(this_arg & (~1));
25278         this_arg_conv.is_owned = false;
25279         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
25280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25282         uint64_t ret_ref = (uint64_t)ret_var.inner;
25283         if (ret_var.is_owned) {
25284                 ret_ref |= 1;
25285         }
25286         return ret_ref;
25287 }
25288
25289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
25290         LDKInvoice this_arg_conv;
25291         this_arg_conv.inner = (void*)(this_arg & (~1));
25292         this_arg_conv.is_owned = false;
25293         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
25295         return ret_arr;
25296 }
25297
25298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
25299         LDKInvoice this_arg_conv;
25300         this_arg_conv.inner = (void*)(this_arg & (~1));
25301         this_arg_conv.is_owned = false;
25302         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
25303         return ret_val;
25304 }
25305
25306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
25307         LDKInvoice this_arg_conv;
25308         this_arg_conv.inner = (void*)(this_arg & (~1));
25309         this_arg_conv.is_owned = false;
25310         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
25311         return ret_val;
25312 }
25313
25314 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
25315         LDKInvoice this_arg_conv;
25316         this_arg_conv.inner = (void*)(this_arg & (~1));
25317         this_arg_conv.is_owned = false;
25318         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
25319         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25320         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25321         for (size_t o = 0; o < ret_var.datalen; o++) {
25322                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25323                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25324                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25325                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25326                 if (ret_conv_14_var.is_owned) {
25327                         ret_conv_14_ref |= 1;
25328                 }
25329                 ret_arr_ptr[o] = ret_conv_14_ref;
25330         }
25331         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25332         FREE(ret_var.data);
25333         return ret_arr;
25334 }
25335
25336 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
25337         LDKInvoice this_arg_conv;
25338         this_arg_conv.inner = (void*)(this_arg & (~1));
25339         this_arg_conv.is_owned = false;
25340         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
25341         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25342         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25343         for (size_t l = 0; l < ret_var.datalen; l++) {
25344                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
25345                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25346                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25347                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
25348                 if (ret_conv_11_var.is_owned) {
25349                         ret_conv_11_ref |= 1;
25350                 }
25351                 ret_arr_ptr[l] = ret_conv_11_ref;
25352         }
25353         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25354         FREE(ret_var.data);
25355         return ret_arr;
25356 }
25357
25358 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
25359         LDKInvoice this_arg_conv;
25360         this_arg_conv.inner = (void*)(this_arg & (~1));
25361         this_arg_conv.is_owned = false;
25362         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
25363         return ret_conv;
25364 }
25365
25366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
25367         LDKInvoice this_arg_conv;
25368         this_arg_conv.inner = (void*)(this_arg & (~1));
25369         this_arg_conv.is_owned = false;
25370         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25371         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
25372         uint64_t ret_ref = (uint64_t)ret_copy;
25373         return ret_ref;
25374 }
25375
25376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
25377         LDKStr description_conv = java_to_owned_str(env, description);
25378         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
25379         *ret_conv = Description_new(description_conv);
25380         return (uint64_t)ret_conv;
25381 }
25382
25383 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25384         LDKDescription this_arg_conv;
25385         this_arg_conv.inner = (void*)(this_arg & (~1));
25386         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25387         this_arg_conv = Description_clone(&this_arg_conv);
25388         LDKStr ret_str = Description_into_inner(this_arg_conv);
25389         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25390         return ret_conv;
25391 }
25392
25393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
25394         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25395         *ret_conv = ExpiryTime_from_seconds(seconds);
25396         return (uint64_t)ret_conv;
25397 }
25398
25399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
25400         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
25401         *ret_conv = ExpiryTime_from_duration(duration);
25402         return (uint64_t)ret_conv;
25403 }
25404
25405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
25406         LDKExpiryTime this_arg_conv;
25407         this_arg_conv.inner = (void*)(this_arg & (~1));
25408         this_arg_conv.is_owned = false;
25409         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
25410         return ret_val;
25411 }
25412
25413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
25414         LDKExpiryTime this_arg_conv;
25415         this_arg_conv.inner = (void*)(this_arg & (~1));
25416         this_arg_conv.is_owned = false;
25417         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
25418         return ret_val;
25419 }
25420
25421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
25422         LDKRouteHint hops_conv;
25423         hops_conv.inner = (void*)(hops & (~1));
25424         hops_conv.is_owned = (hops & 1) || (hops == 0);
25425         hops_conv = RouteHint_clone(&hops_conv);
25426         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
25427         *ret_conv = PrivateRoute_new(hops_conv);
25428         return (uint64_t)ret_conv;
25429 }
25430
25431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
25432         LDKPrivateRoute this_arg_conv;
25433         this_arg_conv.inner = (void*)(this_arg & (~1));
25434         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25435         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
25436         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
25437         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25438         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25439         uint64_t ret_ref = (uint64_t)ret_var.inner;
25440         if (ret_var.is_owned) {
25441                 ret_ref |= 1;
25442         }
25443         return ret_ref;
25444 }
25445
25446 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25447         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
25448         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
25449         return ret_conv;
25450 }
25451
25452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25453         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
25454         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
25455         jboolean ret_val = CreationError_eq(a_conv, b_conv);
25456         return ret_val;
25457 }
25458
25459 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25460         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
25461         LDKStr ret_str = CreationError_to_str(o_conv);
25462         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25463         return ret_conv;
25464 }
25465
25466 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25467         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
25468         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
25469         return ret_conv;
25470 }
25471
25472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25473         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
25474         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
25475         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
25476         return ret_val;
25477 }
25478
25479 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25480         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
25481         LDKStr ret_str = SemanticError_to_str(o_conv);
25482         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25483         return ret_conv;
25484 }
25485
25486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25487         if ((this_ptr & 1) != 0) return;
25488         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
25489         FREE((void*)this_ptr);
25490         SignOrCreationError_free(this_ptr_conv);
25491 }
25492
25493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25494         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
25495         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
25496         *ret_copy = SignOrCreationError_clone(orig_conv);
25497         uint64_t ret_ref = (uint64_t)ret_copy;
25498         return ret_ref;
25499 }
25500
25501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25502         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
25503         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
25504         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
25505         return ret_val;
25506 }
25507
25508 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25509         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
25510         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
25511         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25512         return ret_conv;
25513 }
25514
25515 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) {
25516         LDKChannelManager channelmanager_conv;
25517         channelmanager_conv.inner = (void*)(channelmanager & (~1));
25518         channelmanager_conv.is_owned = false;
25519         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25520         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25521                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25522                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
25523         }
25524         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
25525         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
25526         LDKStr description_conv = java_to_owned_str(env, description);
25527         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25528         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
25529         return (uint64_t)ret_conv;
25530 }
25531
25532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25533         LDKStr s_conv = java_to_owned_str(env, s);
25534         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
25535         *ret_conv = SiPrefix_from_str(s_conv);
25536         return (uint64_t)ret_conv;
25537 }
25538
25539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25540         LDKStr s_conv = java_to_owned_str(env, s);
25541         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
25542         *ret_conv = Invoice_from_str(s_conv);
25543         return (uint64_t)ret_conv;
25544 }
25545
25546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
25547         LDKStr s_conv = java_to_owned_str(env, s);
25548         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
25549         *ret_conv = SignedRawInvoice_from_str(s_conv);
25550         return (uint64_t)ret_conv;
25551 }
25552
25553 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25554         LDKInvoice o_conv;
25555         o_conv.inner = (void*)(o & (~1));
25556         o_conv.is_owned = false;
25557         LDKStr ret_str = Invoice_to_str(&o_conv);
25558         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25559         return ret_conv;
25560 }
25561
25562 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25563         LDKSignedRawInvoice o_conv;
25564         o_conv.inner = (void*)(o & (~1));
25565         o_conv.is_owned = false;
25566         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
25567         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25568         return ret_conv;
25569 }
25570
25571 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25572         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
25573         LDKStr ret_str = Currency_to_str(o_conv);
25574         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25575         return ret_conv;
25576 }
25577
25578 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
25579         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
25580         LDKStr ret_str = SiPrefix_to_str(o_conv);
25581         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25582         return ret_conv;
25583 }
25584