Bump version to 0.0.100.2
[ldk-java] / src / main / jni / bindings.c.body
1 #include <jni.h>
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include "org_ldk_impl_bindings.h"
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
11 #define MALLOC(a, _) malloc(a)
12 #define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
13 #define DO_ASSERT(a) (void)(a)
14 #define CHECK(a)
15
16 static jmethodID ordinal_meth = NULL;
17 static jmethodID slicedef_meth = NULL;
18 static jclass slicedef_cls = NULL;
19 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
20         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
21         CHECK(ordinal_meth != NULL);
22         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
23         CHECK(slicedef_meth != NULL);
24         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
25         CHECK(slicedef_cls != NULL);
26 }
27
28 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
29         return *((bool*)ptr);
30 }
31 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
32         return *((long*)ptr);
33 }
34 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
35         FREE((void*)ptr);
36 }
37 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
38         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
39         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
40         return ret_arr;
41 }
42 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
43         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
44         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
45         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
46         return ret_arr;
47 }
48 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
49         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
50         vec->datalen = (*env)->GetArrayLength(env, bytes);
51         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
52         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
53         return (uint64_t)vec;
54 }
55 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
56         LDKTransaction *txdata = (LDKTransaction*)ptr;
57         LDKu8slice slice;
58         slice.data = txdata->data;
59         slice.datalen = txdata->datalen;
60         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
61 }
62 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
63         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
64         txdata->datalen = (*env)->GetArrayLength(env, bytes);
65         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
66         txdata->data_is_owned = false;
67         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
68         return (uint64_t)txdata;
69 }
70 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
71         LDKTransaction *tx = (LDKTransaction*)ptr;
72         tx->data_is_owned = true;
73         Transaction_free(*tx);
74         FREE((void*)ptr);
75 }
76 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
77         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
78         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
79         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
82         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
83         return (uint64_t)vec->datalen;
84 }
85 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
86         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
87         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
88         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
91         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
92         vec->data = NULL;
93         vec->datalen = 0;
94         return (uint64_t)vec;
95 }
96
97 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
98 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
99 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
100 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
101
102 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
103 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
104 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
105
106 typedef jlongArray int64_tArray;
107 typedef jbyteArray int8_tArray;
108
109 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
110         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
111         char* conv_buf = MALLOC(len + 1, "str conv buf");
112         memcpy(conv_buf, chars, len);
113         conv_buf[len] = 0;
114         jstring ret = (*env)->NewStringUTF(env, conv_buf);
115         FREE(conv_buf);
116         return ret;
117 }
118 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
119         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
120         char* newchars = MALLOC(str_len + 1, "String chars");
121         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
122         memcpy(newchars, jchars, str_len);
123         newchars[str_len] = 0;
124         (*env)->ReleaseStringUTFChars(env, str, jchars);
125         LDKStr res = {
126                 .chars = newchars,
127                 .len = str_len,
128                 .chars_is_owned = true
129         };
130         return res;
131 }
132
133 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
134         return str_ref_to_java(env, "v0.0.100.2", strlen("v0.0.100.2"));
135 }
136 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
137         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
138 }
139 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
140         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
141 }
142 static jclass arr_of_B_clz = NULL;
143 static jclass arr_of_J_clz = NULL;
144 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
145         arr_of_B_clz = (*env)->FindClass(env, "[B");
146         CHECK(arr_of_B_clz != NULL);
147         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
148         arr_of_J_clz = (*env)->FindClass(env, "[J");
149         CHECK(arr_of_J_clz != NULL);
150         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
151 }
152 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
153 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
154         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
155                 case 0: return LDKAccessError_UnknownChain;
156                 case 1: return LDKAccessError_UnknownTx;
157         }
158         abort();
159 }
160 static jclass AccessError_class = NULL;
161 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
162 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
163 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
164         AccessError_class = (*env)->NewGlobalRef(env, clz);
165         CHECK(AccessError_class != NULL);
166         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
167         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
168         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
169         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
170 }
171 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
172         switch (val) {
173                 case LDKAccessError_UnknownChain:
174                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
175                 case LDKAccessError_UnknownTx:
176                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
177                 default: abort();
178         }
179 }
180
181 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
182         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
183                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
184                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
185         }
186         abort();
187 }
188 static jclass ChannelMonitorUpdateErr_class = NULL;
189 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
190 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
191 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
192         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
193         CHECK(ChannelMonitorUpdateErr_class != NULL);
194         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
195         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
196         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
197         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
198 }
199 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
200         switch (val) {
201                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
202                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
203                 case LDKChannelMonitorUpdateErr_PermanentFailure:
204                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
205                 default: abort();
206         }
207 }
208
209 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
210         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
211                 case 0: return LDKConfirmationTarget_Background;
212                 case 1: return LDKConfirmationTarget_Normal;
213                 case 2: return LDKConfirmationTarget_HighPriority;
214         }
215         abort();
216 }
217 static jclass ConfirmationTarget_class = NULL;
218 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
221 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
222         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
223         CHECK(ConfirmationTarget_class != NULL);
224         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
225         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
226         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
227         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
228         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
229         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
230 }
231 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
232         switch (val) {
233                 case LDKConfirmationTarget_Background:
234                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
235                 case LDKConfirmationTarget_Normal:
236                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
237                 case LDKConfirmationTarget_HighPriority:
238                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
239                 default: abort();
240         }
241 }
242
243 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
244         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
245                 case 0: return LDKCreationError_DescriptionTooLong;
246                 case 1: return LDKCreationError_RouteTooLong;
247                 case 2: return LDKCreationError_TimestampOutOfBounds;
248                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
249         }
250         abort();
251 }
252 static jclass CreationError_class = NULL;
253 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
254 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
255 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
256 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
257 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
258         CreationError_class = (*env)->NewGlobalRef(env, clz);
259         CHECK(CreationError_class != NULL);
260         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
261         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
262         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
263         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
264         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
265         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
266         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
267         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
268 }
269 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
270         switch (val) {
271                 case LDKCreationError_DescriptionTooLong:
272                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
273                 case LDKCreationError_RouteTooLong:
274                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
275                 case LDKCreationError_TimestampOutOfBounds:
276                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
277                 case LDKCreationError_ExpiryTimeOutOfBounds:
278                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
279                 default: abort();
280         }
281 }
282
283 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
284         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
285                 case 0: return LDKCurrency_Bitcoin;
286                 case 1: return LDKCurrency_BitcoinTestnet;
287                 case 2: return LDKCurrency_Regtest;
288                 case 3: return LDKCurrency_Simnet;
289                 case 4: return LDKCurrency_Signet;
290         }
291         abort();
292 }
293 static jclass Currency_class = NULL;
294 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
295 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
296 static jfieldID Currency_LDKCurrency_Regtest = NULL;
297 static jfieldID Currency_LDKCurrency_Simnet = NULL;
298 static jfieldID Currency_LDKCurrency_Signet = NULL;
299 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
300         Currency_class = (*env)->NewGlobalRef(env, clz);
301         CHECK(Currency_class != NULL);
302         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
303         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
304         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
305         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
306         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
307         CHECK(Currency_LDKCurrency_Regtest != NULL);
308         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
309         CHECK(Currency_LDKCurrency_Simnet != NULL);
310         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
311         CHECK(Currency_LDKCurrency_Signet != NULL);
312 }
313 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
314         switch (val) {
315                 case LDKCurrency_Bitcoin:
316                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
317                 case LDKCurrency_BitcoinTestnet:
318                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
319                 case LDKCurrency_Regtest:
320                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
321                 case LDKCurrency_Simnet:
322                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
323                 case LDKCurrency_Signet:
324                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
325                 default: abort();
326         }
327 }
328
329 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
330         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
331                 case 0: return LDKIOError_NotFound;
332                 case 1: return LDKIOError_PermissionDenied;
333                 case 2: return LDKIOError_ConnectionRefused;
334                 case 3: return LDKIOError_ConnectionReset;
335                 case 4: return LDKIOError_ConnectionAborted;
336                 case 5: return LDKIOError_NotConnected;
337                 case 6: return LDKIOError_AddrInUse;
338                 case 7: return LDKIOError_AddrNotAvailable;
339                 case 8: return LDKIOError_BrokenPipe;
340                 case 9: return LDKIOError_AlreadyExists;
341                 case 10: return LDKIOError_WouldBlock;
342                 case 11: return LDKIOError_InvalidInput;
343                 case 12: return LDKIOError_InvalidData;
344                 case 13: return LDKIOError_TimedOut;
345                 case 14: return LDKIOError_WriteZero;
346                 case 15: return LDKIOError_Interrupted;
347                 case 16: return LDKIOError_Other;
348                 case 17: return LDKIOError_UnexpectedEof;
349         }
350         abort();
351 }
352 static jclass IOError_class = NULL;
353 static jfieldID IOError_LDKIOError_NotFound = NULL;
354 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
355 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
358 static jfieldID IOError_LDKIOError_NotConnected = NULL;
359 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
360 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
361 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
362 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
363 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
364 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
365 static jfieldID IOError_LDKIOError_InvalidData = NULL;
366 static jfieldID IOError_LDKIOError_TimedOut = NULL;
367 static jfieldID IOError_LDKIOError_WriteZero = NULL;
368 static jfieldID IOError_LDKIOError_Interrupted = NULL;
369 static jfieldID IOError_LDKIOError_Other = NULL;
370 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
371 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
372         IOError_class = (*env)->NewGlobalRef(env, clz);
373         CHECK(IOError_class != NULL);
374         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
375         CHECK(IOError_LDKIOError_NotFound != NULL);
376         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
377         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
378         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
379         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
380         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
381         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
382         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
383         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
384         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
385         CHECK(IOError_LDKIOError_NotConnected != NULL);
386         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
387         CHECK(IOError_LDKIOError_AddrInUse != NULL);
388         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
389         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
390         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
391         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
392         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
393         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
394         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
395         CHECK(IOError_LDKIOError_WouldBlock != NULL);
396         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
397         CHECK(IOError_LDKIOError_InvalidInput != NULL);
398         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
399         CHECK(IOError_LDKIOError_InvalidData != NULL);
400         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
401         CHECK(IOError_LDKIOError_TimedOut != NULL);
402         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
403         CHECK(IOError_LDKIOError_WriteZero != NULL);
404         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
405         CHECK(IOError_LDKIOError_Interrupted != NULL);
406         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
407         CHECK(IOError_LDKIOError_Other != NULL);
408         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
409         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
410 }
411 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
412         switch (val) {
413                 case LDKIOError_NotFound:
414                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
415                 case LDKIOError_PermissionDenied:
416                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
417                 case LDKIOError_ConnectionRefused:
418                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
419                 case LDKIOError_ConnectionReset:
420                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
421                 case LDKIOError_ConnectionAborted:
422                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
423                 case LDKIOError_NotConnected:
424                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
425                 case LDKIOError_AddrInUse:
426                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
427                 case LDKIOError_AddrNotAvailable:
428                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
429                 case LDKIOError_BrokenPipe:
430                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
431                 case LDKIOError_AlreadyExists:
432                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
433                 case LDKIOError_WouldBlock:
434                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
435                 case LDKIOError_InvalidInput:
436                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
437                 case LDKIOError_InvalidData:
438                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
439                 case LDKIOError_TimedOut:
440                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
441                 case LDKIOError_WriteZero:
442                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
443                 case LDKIOError_Interrupted:
444                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
445                 case LDKIOError_Other:
446                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
447                 case LDKIOError_UnexpectedEof:
448                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
449                 default: abort();
450         }
451 }
452
453 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
454         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
455                 case 0: return LDKLevel_Trace;
456                 case 1: return LDKLevel_Debug;
457                 case 2: return LDKLevel_Info;
458                 case 3: return LDKLevel_Warn;
459                 case 4: return LDKLevel_Error;
460         }
461         abort();
462 }
463 static jclass Level_class = NULL;
464 static jfieldID Level_LDKLevel_Trace = NULL;
465 static jfieldID Level_LDKLevel_Debug = NULL;
466 static jfieldID Level_LDKLevel_Info = NULL;
467 static jfieldID Level_LDKLevel_Warn = NULL;
468 static jfieldID Level_LDKLevel_Error = NULL;
469 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
470         Level_class = (*env)->NewGlobalRef(env, clz);
471         CHECK(Level_class != NULL);
472         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
473         CHECK(Level_LDKLevel_Trace != NULL);
474         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
475         CHECK(Level_LDKLevel_Debug != NULL);
476         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Info != NULL);
478         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Warn != NULL);
480         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
481         CHECK(Level_LDKLevel_Error != NULL);
482 }
483 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
484         switch (val) {
485                 case LDKLevel_Trace:
486                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
487                 case LDKLevel_Debug:
488                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
489                 case LDKLevel_Info:
490                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
491                 case LDKLevel_Warn:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
493                 case LDKLevel_Error:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
495                 default: abort();
496         }
497 }
498
499 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
500         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
501                 case 0: return LDKNetwork_Bitcoin;
502                 case 1: return LDKNetwork_Testnet;
503                 case 2: return LDKNetwork_Regtest;
504                 case 3: return LDKNetwork_Signet;
505         }
506         abort();
507 }
508 static jclass Network_class = NULL;
509 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
510 static jfieldID Network_LDKNetwork_Testnet = NULL;
511 static jfieldID Network_LDKNetwork_Regtest = NULL;
512 static jfieldID Network_LDKNetwork_Signet = NULL;
513 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
514         Network_class = (*env)->NewGlobalRef(env, clz);
515         CHECK(Network_class != NULL);
516         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
517         CHECK(Network_LDKNetwork_Bitcoin != NULL);
518         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
519         CHECK(Network_LDKNetwork_Testnet != NULL);
520         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
521         CHECK(Network_LDKNetwork_Regtest != NULL);
522         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
523         CHECK(Network_LDKNetwork_Signet != NULL);
524 }
525 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
526         switch (val) {
527                 case LDKNetwork_Bitcoin:
528                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
529                 case LDKNetwork_Testnet:
530                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
531                 case LDKNetwork_Regtest:
532                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
533                 case LDKNetwork_Signet:
534                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
535                 default: abort();
536         }
537 }
538
539 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
540         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
541                 case 0: return LDKSecp256k1Error_IncorrectSignature;
542                 case 1: return LDKSecp256k1Error_InvalidMessage;
543                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
544                 case 3: return LDKSecp256k1Error_InvalidSignature;
545                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
546                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
547                 case 6: return LDKSecp256k1Error_InvalidTweak;
548                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
549                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
550         }
551         abort();
552 }
553 static jclass Secp256k1Error_class = NULL;
554 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
555 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
563 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
564         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
565         CHECK(Secp256k1Error_class != NULL);
566         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
567         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
568         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
569         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
570         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
571         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
572         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
573         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
574         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
580         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
582         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
584 }
585 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
586         switch (val) {
587                 case LDKSecp256k1Error_IncorrectSignature:
588                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
589                 case LDKSecp256k1Error_InvalidMessage:
590                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
591                 case LDKSecp256k1Error_InvalidPublicKey:
592                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
593                 case LDKSecp256k1Error_InvalidSignature:
594                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
595                 case LDKSecp256k1Error_InvalidSecretKey:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
597                 case LDKSecp256k1Error_InvalidRecoveryId:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
599                 case LDKSecp256k1Error_InvalidTweak:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
601                 case LDKSecp256k1Error_TweakCheckFailed:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
603                 case LDKSecp256k1Error_NotEnoughMemory:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
605                 default: abort();
606         }
607 }
608
609 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
610         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
611                 case 0: return LDKSemanticError_NoPaymentHash;
612                 case 1: return LDKSemanticError_MultiplePaymentHashes;
613                 case 2: return LDKSemanticError_NoDescription;
614                 case 3: return LDKSemanticError_MultipleDescriptions;
615                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
616                 case 5: return LDKSemanticError_InvalidFeatures;
617                 case 6: return LDKSemanticError_InvalidRecoveryId;
618                 case 7: return LDKSemanticError_InvalidSignature;
619         }
620         abort();
621 }
622 static jclass SemanticError_class = NULL;
623 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
624 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
625 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
626 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
627 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
628 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
629 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
630 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
631 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
632         SemanticError_class = (*env)->NewGlobalRef(env, clz);
633         CHECK(SemanticError_class != NULL);
634         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
635         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
636         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
637         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
638         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
639         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
640         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
641         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
642         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
644         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
646         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
648         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
650 }
651 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
652         switch (val) {
653                 case LDKSemanticError_NoPaymentHash:
654                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
655                 case LDKSemanticError_MultiplePaymentHashes:
656                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
657                 case LDKSemanticError_NoDescription:
658                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
659                 case LDKSemanticError_MultipleDescriptions:
660                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
661                 case LDKSemanticError_MultiplePaymentSecrets:
662                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
663                 case LDKSemanticError_InvalidFeatures:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
665                 case LDKSemanticError_InvalidRecoveryId:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
667                 case LDKSemanticError_InvalidSignature:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
669                 default: abort();
670         }
671 }
672
673 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
674         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
675                 case 0: return LDKSiPrefix_Milli;
676                 case 1: return LDKSiPrefix_Micro;
677                 case 2: return LDKSiPrefix_Nano;
678                 case 3: return LDKSiPrefix_Pico;
679         }
680         abort();
681 }
682 static jclass SiPrefix_class = NULL;
683 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
684 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
685 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
686 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
687 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
688         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
689         CHECK(SiPrefix_class != NULL);
690         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
691         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
692         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
693         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
694         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
695         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
696         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
697         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
698 }
699 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
700         switch (val) {
701                 case LDKSiPrefix_Milli:
702                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
703                 case LDKSiPrefix_Micro:
704                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
705                 case LDKSiPrefix_Nano:
706                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
707                 case LDKSiPrefix_Pico:
708                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
709                 default: abort();
710         }
711 }
712
713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u8Z_1new(JNIEnv *env, jclass clz, int8_tArray elems) {
714         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
715         ret->datalen = (*env)->GetArrayLength(env, elems);
716         if (ret->datalen == 0) {
717                 ret->data = NULL;
718         } else {
719                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
720                 int8_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
721                 for (size_t i = 0; i < ret->datalen; i++) {
722                         ret->data[i] = java_elems[i];
723                 }
724                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
725         }
726         return (uint64_t)ret;
727 }
728 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
729         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
730         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
731         return ret;
732 }
733 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
734         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
735         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
738         CVec_u8Z_free(ret_var);
739         return ret_arr;
740 }
741
742 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
743         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
744         int64_t ret_val = TxOut_get_value(thing_conv);
745         return ret_val;
746 }
747
748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
749         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
750 }
751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
752         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
753         CHECK(val->result_ok);
754         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
755         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
756         return res_arr;
757 }
758 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
759         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
760         CHECK(!val->result_ok);
761         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
762         return err_conv;
763 }
764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
765         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
766 }
767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
768         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
769         CHECK(val->result_ok);
770         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
771         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
772         return res_arr;
773 }
774 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
775         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
776         CHECK(!val->result_ok);
777         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
778         return err_conv;
779 }
780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
781         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
782 }
783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
784         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
785         CHECK(val->result_ok);
786         LDKTxCreationKeys res_var = (*val->contents.result);
787         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
788         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
789         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
790         return res_ref;
791 }
792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
793         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
794         CHECK(!val->result_ok);
795         LDKDecodeError err_var = (*val->contents.err);
796         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
797         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
798         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
799         return err_ref;
800 }
801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
802         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
803 }
804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
805         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
806         CHECK(val->result_ok);
807         LDKChannelPublicKeys res_var = (*val->contents.result);
808         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
809         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
810         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
811         return res_ref;
812 }
813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
814         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
815         CHECK(!val->result_ok);
816         LDKDecodeError err_var = (*val->contents.err);
817         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
818         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
819         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
820         return err_ref;
821 }
822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
823         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
824 }
825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
826         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
827         CHECK(val->result_ok);
828         LDKTxCreationKeys res_var = (*val->contents.result);
829         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
830         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
831         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
832         return res_ref;
833 }
834 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
835         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
836         CHECK(!val->result_ok);
837         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
838         return err_conv;
839 }
840 static jclass LDKCOption_u32Z_Some_class = NULL;
841 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
842 static jclass LDKCOption_u32Z_None_class = NULL;
843 static jmethodID LDKCOption_u32Z_None_meth = NULL;
844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
845         LDKCOption_u32Z_Some_class =
846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
847         CHECK(LDKCOption_u32Z_Some_class != NULL);
848         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
849         CHECK(LDKCOption_u32Z_Some_meth != NULL);
850         LDKCOption_u32Z_None_class =
851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
852         CHECK(LDKCOption_u32Z_None_class != NULL);
853         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
854         CHECK(LDKCOption_u32Z_None_meth != NULL);
855 }
856 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
857         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
858         switch(obj->tag) {
859                 case LDKCOption_u32Z_Some: {
860                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
861                 }
862                 case LDKCOption_u32Z_None: {
863                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
864                 }
865                 default: abort();
866         }
867 }
868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
869         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
870 }
871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
872         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
873         CHECK(val->result_ok);
874         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
875         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
876         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
877         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
878         return res_ref;
879 }
880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
881         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
882         CHECK(!val->result_ok);
883         LDKDecodeError err_var = (*val->contents.err);
884         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
885         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
886         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
887         return err_ref;
888 }
889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
890         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
891 }
892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
893         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
894         CHECK(val->result_ok);
895         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
896         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
897         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
898         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
899         return res_ref;
900 }
901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
902         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
903         CHECK(!val->result_ok);
904         LDKDecodeError err_var = (*val->contents.err);
905         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
906         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
907         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
908         return err_ref;
909 }
910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
911         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
912 }
913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
914         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
915         CHECK(val->result_ok);
916         LDKChannelTransactionParameters res_var = (*val->contents.result);
917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
919         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
920         return res_ref;
921 }
922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
923         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
924         CHECK(!val->result_ok);
925         LDKDecodeError err_var = (*val->contents.err);
926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
928         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
929         return err_ref;
930 }
931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
932         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
933 }
934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
935         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
936         CHECK(val->result_ok);
937         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
938         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
939         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
940         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
941         return res_ref;
942 }
943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
944         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
945         CHECK(!val->result_ok);
946         LDKDecodeError err_var = (*val->contents.err);
947         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
948         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
949         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
950         return err_ref;
951 }
952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
953         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
954 }
955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
956         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
957         CHECK(val->result_ok);
958         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
959         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
960         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
961         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
962         return res_ref;
963 }
964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
965         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
966         CHECK(!val->result_ok);
967         LDKDecodeError err_var = (*val->contents.err);
968         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
969         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
970         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
971         return err_ref;
972 }
973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
974         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
975 }
976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
977         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
978         CHECK(val->result_ok);
979         LDKCommitmentTransaction res_var = (*val->contents.result);
980         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
981         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
982         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
983         return res_ref;
984 }
985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
986         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
987         CHECK(!val->result_ok);
988         LDKDecodeError err_var = (*val->contents.err);
989         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
990         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
991         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
992         return err_ref;
993 }
994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
995         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
996 }
997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
998         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
999         CHECK(val->result_ok);
1000         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1001         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1002         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1003         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1004         return res_ref;
1005 }
1006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1007         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1008         CHECK(!val->result_ok);
1009         return *val->contents.err;
1010 }
1011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1012         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1013 }
1014 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1015         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1016         CHECK(val->result_ok);
1017         LDKCVec_SignatureZ res_var = (*val->contents.result);
1018         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1019         ;
1020         for (size_t i = 0; i < res_var.datalen; i++) {
1021                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1022                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1023                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1024         }
1025         return res_arr;
1026 }
1027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1028         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1029         CHECK(!val->result_ok);
1030         return *val->contents.err;
1031 }
1032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1033         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
1034 }
1035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1036         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1037         CHECK(val->result_ok);
1038         LDKShutdownScript res_var = (*val->contents.result);
1039         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1040         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1041         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1042         return res_ref;
1043 }
1044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1045         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1046         CHECK(!val->result_ok);
1047         LDKDecodeError err_var = (*val->contents.err);
1048         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1049         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1050         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1051         return err_ref;
1052 }
1053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1054         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
1055 }
1056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1057         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1058         CHECK(val->result_ok);
1059         LDKShutdownScript res_var = (*val->contents.result);
1060         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1061         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1062         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1063         return res_ref;
1064 }
1065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1066         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1067         CHECK(!val->result_ok);
1068         LDKInvalidShutdownScript err_var = (*val->contents.err);
1069         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1070         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1071         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1072         return err_ref;
1073 }
1074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1075         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1076 }
1077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1078         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1079         CHECK(val->result_ok);
1080         return *val->contents.result;
1081 }
1082 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1083         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1084         CHECK(!val->result_ok);
1085         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1086         return err_conv;
1087 }
1088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1089         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1090 }
1091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1092         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1093         CHECK(val->result_ok);
1094         LDKRouteHop res_var = (*val->contents.result);
1095         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1096         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1097         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1098         return res_ref;
1099 }
1100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1101         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1102         CHECK(!val->result_ok);
1103         LDKDecodeError err_var = (*val->contents.err);
1104         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1107         return err_ref;
1108 }
1109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1110         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1111         ret->datalen = (*env)->GetArrayLength(env, elems);
1112         if (ret->datalen == 0) {
1113                 ret->data = NULL;
1114         } else {
1115                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1116                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1117                 for (size_t i = 0; i < ret->datalen; i++) {
1118                         int64_t arr_elem = java_elems[i];
1119                         LDKRouteHop arr_elem_conv;
1120                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1121                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1122                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1123                         ret->data[i] = arr_elem_conv;
1124                 }
1125                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1126         }
1127         return (uint64_t)ret;
1128 }
1129 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1130         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1131         for (size_t i = 0; i < ret.datalen; i++) {
1132                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1133         }
1134         return ret;
1135 }
1136 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1137         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1138         for (size_t i = 0; i < ret.datalen; i++) {
1139                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1140         }
1141         return ret;
1142 }
1143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1144         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1145 }
1146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1147         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1148         CHECK(val->result_ok);
1149         LDKRoute res_var = (*val->contents.result);
1150         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1151         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1152         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1153         return res_ref;
1154 }
1155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1156         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1157         CHECK(!val->result_ok);
1158         LDKDecodeError err_var = (*val->contents.err);
1159         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1160         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1161         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1162         return err_ref;
1163 }
1164 static jclass LDKCOption_u64Z_Some_class = NULL;
1165 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1166 static jclass LDKCOption_u64Z_None_class = NULL;
1167 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1169         LDKCOption_u64Z_Some_class =
1170                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1171         CHECK(LDKCOption_u64Z_Some_class != NULL);
1172         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1173         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1174         LDKCOption_u64Z_None_class =
1175                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1176         CHECK(LDKCOption_u64Z_None_class != NULL);
1177         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1178         CHECK(LDKCOption_u64Z_None_meth != NULL);
1179 }
1180 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1181         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1182         switch(obj->tag) {
1183                 case LDKCOption_u64Z_Some: {
1184                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1185                 }
1186                 case LDKCOption_u64Z_None: {
1187                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1188                 }
1189                 default: abort();
1190         }
1191 }
1192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1193         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1194         ret->datalen = (*env)->GetArrayLength(env, elems);
1195         if (ret->datalen == 0) {
1196                 ret->data = NULL;
1197         } else {
1198                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1199                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1200                 for (size_t i = 0; i < ret->datalen; i++) {
1201                         int64_t arr_elem = java_elems[i];
1202                         LDKChannelDetails arr_elem_conv;
1203                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1204                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1205                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1206                         ret->data[i] = arr_elem_conv;
1207                 }
1208                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1209         }
1210         return (uint64_t)ret;
1211 }
1212 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1213         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1214         for (size_t i = 0; i < ret.datalen; i++) {
1215                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1216         }
1217         return ret;
1218 }
1219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1220         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1221         ret->datalen = (*env)->GetArrayLength(env, elems);
1222         if (ret->datalen == 0) {
1223                 ret->data = NULL;
1224         } else {
1225                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1226                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1227                 for (size_t i = 0; i < ret->datalen; i++) {
1228                         int64_t arr_elem = java_elems[i];
1229                         LDKRouteHint arr_elem_conv;
1230                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1231                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1232                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1233                         ret->data[i] = arr_elem_conv;
1234                 }
1235                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1236         }
1237         return (uint64_t)ret;
1238 }
1239 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1240         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1241         for (size_t i = 0; i < ret.datalen; i++) {
1242                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1243         }
1244         return ret;
1245 }
1246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1247         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1248 }
1249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1250         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1251         CHECK(val->result_ok);
1252         LDKRoute res_var = (*val->contents.result);
1253         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1254         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1255         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1256         return res_ref;
1257 }
1258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1259         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1260         CHECK(!val->result_ok);
1261         LDKLightningError err_var = (*val->contents.err);
1262         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1263         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1264         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1265         return err_ref;
1266 }
1267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1268         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1269 }
1270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1271         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1272         CHECK(val->result_ok);
1273         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1274         return (uint64_t)res_ref;
1275 }
1276 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1277         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1278         CHECK(!val->result_ok);
1279         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1280         return err_conv;
1281 }
1282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1283         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1284         ret->a = a;
1285         LDKTransaction b_ref;
1286         b_ref.datalen = (*env)->GetArrayLength(env, b);
1287         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1288         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1289         b_ref.data_is_owned = false;
1290         ret->b = b_ref;
1291         return (uint64_t)ret;
1292 }
1293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1294         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1295         return tuple->a;
1296 }
1297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1298         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1299         LDKTransaction b_var = tuple->b;
1300         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1301         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1302         return b_arr;
1303 }
1304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1305         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1306         ret->datalen = (*env)->GetArrayLength(env, elems);
1307         if (ret->datalen == 0) {
1308                 ret->data = NULL;
1309         } else {
1310                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1311                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1312                 for (size_t i = 0; i < ret->datalen; i++) {
1313                         int64_t arr_elem = java_elems[i];
1314                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1315                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1316                         ret->data[i] = arr_elem_conv;
1317                 }
1318                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1319         }
1320         return (uint64_t)ret;
1321 }
1322 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1323         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1324         for (size_t i = 0; i < ret.datalen; i++) {
1325                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1326         }
1327         return ret;
1328 }
1329 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1330         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1331         for (size_t i = 0; i < ret.datalen; i++) {
1332                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1333         }
1334         return ret;
1335 }
1336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1337         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1338 }
1339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1340         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1341         CHECK(val->result_ok);
1342         return *val->contents.result;
1343 }
1344 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1345         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1346         CHECK(!val->result_ok);
1347         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1348         return err_conv;
1349 }
1350 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1351 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1352 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1353 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1355         LDKMonitorEvent_HTLCEvent_class =
1356                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1357         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1358         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1359         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1360         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1361                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1362         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1363         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1364         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1365 }
1366 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1367         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1368         switch(obj->tag) {
1369                 case LDKMonitorEvent_HTLCEvent: {
1370                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1371                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1372                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1373                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1374                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1375                 }
1376                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1377                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1378                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1379                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1380                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1381                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1382                 }
1383                 default: abort();
1384         }
1385 }
1386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1387         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1388         ret->datalen = (*env)->GetArrayLength(env, elems);
1389         if (ret->datalen == 0) {
1390                 ret->data = NULL;
1391         } else {
1392                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1393                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1394                 for (size_t i = 0; i < ret->datalen; i++) {
1395                         int64_t arr_elem = java_elems[i];
1396                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1397                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1398                         ret->data[i] = arr_elem_conv;
1399                 }
1400                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1401         }
1402         return (uint64_t)ret;
1403 }
1404 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1405         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1406         for (size_t i = 0; i < ret.datalen; i++) {
1407                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1408         }
1409         return ret;
1410 }
1411 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1412 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1413 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1414 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1416         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1417                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1418         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1419         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1420         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1421         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1422                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1423         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1424         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1425         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1426 }
1427 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1428         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1429         switch(obj->tag) {
1430                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1431                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1432                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1433                 }
1434                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1435                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1436                 }
1437                 default: abort();
1438         }
1439 }
1440 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1441 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1442 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1443 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1444 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1445 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1447         LDKSpendableOutputDescriptor_StaticOutput_class =
1448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1449         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1450         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1451         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1452         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1453                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1454         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1455         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1456         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1457         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1458                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1459         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1460         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1461         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1462 }
1463 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1464         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1465         switch(obj->tag) {
1466                 case LDKSpendableOutputDescriptor_StaticOutput: {
1467                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1468                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1469                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1470                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1471                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1472                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1473                 }
1474                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1475                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1476                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1477                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1478                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1479                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1480                 }
1481                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1482                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1483                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1484                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1485                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1486                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1487                 }
1488                 default: abort();
1489         }
1490 }
1491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1492         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1493         ret->datalen = (*env)->GetArrayLength(env, elems);
1494         if (ret->datalen == 0) {
1495                 ret->data = NULL;
1496         } else {
1497                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1498                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1499                 for (size_t i = 0; i < ret->datalen; i++) {
1500                         int64_t arr_elem = java_elems[i];
1501                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1502                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1503                         ret->data[i] = arr_elem_conv;
1504                 }
1505                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1506         }
1507         return (uint64_t)ret;
1508 }
1509 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1510         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1511         for (size_t i = 0; i < ret.datalen; i++) {
1512                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1513         }
1514         return ret;
1515 }
1516 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1517 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1518 static jclass LDKErrorAction_IgnoreError_class = NULL;
1519 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1520 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1521 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1522 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1523 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1525         LDKErrorAction_DisconnectPeer_class =
1526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1527         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1528         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1529         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1530         LDKErrorAction_IgnoreError_class =
1531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1532         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1533         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1534         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1535         LDKErrorAction_IgnoreAndLog_class =
1536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1537         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1538         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1539         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1540         LDKErrorAction_SendErrorMessage_class =
1541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1542         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1543         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1544         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1545 }
1546 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1547         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1548         switch(obj->tag) {
1549                 case LDKErrorAction_DisconnectPeer: {
1550                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1551                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1552                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1553                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1554                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1555                 }
1556                 case LDKErrorAction_IgnoreError: {
1557                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1558                 }
1559                 case LDKErrorAction_IgnoreAndLog: {
1560                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1561                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1562                 }
1563                 case LDKErrorAction_SendErrorMessage: {
1564                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1565                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1566                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1567                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1568                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1569                 }
1570                 default: abort();
1571         }
1572 }
1573 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1574 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1575 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1576 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1577 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1578 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1580         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1581                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1582         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1583         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1584         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1585         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1586                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1587         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1588         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1589         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1590         LDKHTLCFailChannelUpdate_NodeFailure_class =
1591                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1592         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1593         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1594         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1595 }
1596 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1597         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1598         switch(obj->tag) {
1599                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1600                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1601                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1602                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1603                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1604                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1605                 }
1606                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1607                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1608                 }
1609                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1610                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1611                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1612                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1613                 }
1614                 default: abort();
1615         }
1616 }
1617 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1618 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1619 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1620 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1621 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1622 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1623 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1624 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1625 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1626 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1627 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1628 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1629 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1630 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1631 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1632 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1633 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1634 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1635 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1636 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1637 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1638 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1639 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1640 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1641 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1642 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1643 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1644 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1645 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1646 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1647 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1648 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1649 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1650 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1651 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1652 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1653 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1654 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1655 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1656 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1658         LDKMessageSendEvent_SendAcceptChannel_class =
1659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1660         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1661         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1662         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1663         LDKMessageSendEvent_SendOpenChannel_class =
1664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1665         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1666         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1667         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1668         LDKMessageSendEvent_SendFundingCreated_class =
1669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1670         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1671         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1672         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1673         LDKMessageSendEvent_SendFundingSigned_class =
1674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1675         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1676         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1677         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1678         LDKMessageSendEvent_SendFundingLocked_class =
1679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1680         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1681         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1682         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1683         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1685         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1686         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1687         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1688         LDKMessageSendEvent_UpdateHTLCs_class =
1689                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1690         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1691         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1692         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1693         LDKMessageSendEvent_SendRevokeAndACK_class =
1694                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1695         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1696         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1697         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1698         LDKMessageSendEvent_SendClosingSigned_class =
1699                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1700         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1701         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1702         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1703         LDKMessageSendEvent_SendShutdown_class =
1704                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1705         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1706         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1707         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1708         LDKMessageSendEvent_SendChannelReestablish_class =
1709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1710         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1711         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1712         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1713         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1715         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1716         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1717         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1718         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1720         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1721         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1722         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1723         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1724                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1725         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1726         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1727         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1728         LDKMessageSendEvent_SendChannelUpdate_class =
1729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1730         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1731         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1732         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1733         LDKMessageSendEvent_HandleError_class =
1734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1735         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1736         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1737         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1738         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1740         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1741         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1742         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1743         LDKMessageSendEvent_SendChannelRangeQuery_class =
1744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1745         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1746         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1747         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1748         LDKMessageSendEvent_SendShortIdsQuery_class =
1749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1750         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1751         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1752         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1753         LDKMessageSendEvent_SendReplyChannelRange_class =
1754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1755         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1756         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1757         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1758 }
1759 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1760         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1761         switch(obj->tag) {
1762                 case LDKMessageSendEvent_SendAcceptChannel: {
1763                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1764                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1765                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1766                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1767                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1768                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1769                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1770                 }
1771                 case LDKMessageSendEvent_SendOpenChannel: {
1772                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1773                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1774                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1775                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1776                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1777                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1778                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1779                 }
1780                 case LDKMessageSendEvent_SendFundingCreated: {
1781                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1782                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1783                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1784                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1785                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1786                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1787                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1788                 }
1789                 case LDKMessageSendEvent_SendFundingSigned: {
1790                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1791                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1792                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1793                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1794                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1795                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1796                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1797                 }
1798                 case LDKMessageSendEvent_SendFundingLocked: {
1799                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1800                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1801                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1802                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1803                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1804                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1805                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1806                 }
1807                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1808                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1809                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1810                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1811                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1812                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1813                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1814                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1815                 }
1816                 case LDKMessageSendEvent_UpdateHTLCs: {
1817                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1818                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1819                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1820                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1821                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1822                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1823                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1824                 }
1825                 case LDKMessageSendEvent_SendRevokeAndACK: {
1826                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1827                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1828                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1829                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1830                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1831                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1832                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1833                 }
1834                 case LDKMessageSendEvent_SendClosingSigned: {
1835                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1836                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1837                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1838                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1839                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1840                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1841                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1842                 }
1843                 case LDKMessageSendEvent_SendShutdown: {
1844                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1845                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1846                         LDKShutdown msg_var = obj->send_shutdown.msg;
1847                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1848                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1849                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1850                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1851                 }
1852                 case LDKMessageSendEvent_SendChannelReestablish: {
1853                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1854                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1855                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1856                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1857                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1858                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1859                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1860                 }
1861                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1862                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1863                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1864                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1865                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1866                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1867                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1868                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1869                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1870                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1871                 }
1872                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1873                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1874                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1875                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1876                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1877                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1878                 }
1879                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1880                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1881                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1882                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1883                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1884                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1885                 }
1886                 case LDKMessageSendEvent_SendChannelUpdate: {
1887                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1888                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1889                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1890                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1891                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1892                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1893                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1894                 }
1895                 case LDKMessageSendEvent_HandleError: {
1896                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1897                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1898                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1899                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1900                 }
1901                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1902                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1903                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1904                 }
1905                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1906                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1907                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1908                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1909                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1910                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1911                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1912                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1913                 }
1914                 case LDKMessageSendEvent_SendShortIdsQuery: {
1915                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1916                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1917                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1918                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1919                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1920                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1921                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1922                 }
1923                 case LDKMessageSendEvent_SendReplyChannelRange: {
1924                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1925                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1926                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1927                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1928                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1929                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1930                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1931                 }
1932                 default: abort();
1933         }
1934 }
1935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1936         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1937         ret->datalen = (*env)->GetArrayLength(env, elems);
1938         if (ret->datalen == 0) {
1939                 ret->data = NULL;
1940         } else {
1941                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1942                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1943                 for (size_t i = 0; i < ret->datalen; i++) {
1944                         int64_t arr_elem = java_elems[i];
1945                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1946                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1947                         ret->data[i] = arr_elem_conv;
1948                 }
1949                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1950         }
1951         return (uint64_t)ret;
1952 }
1953 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1954         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1955         for (size_t i = 0; i < ret.datalen; i++) {
1956                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1957         }
1958         return ret;
1959 }
1960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1961         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1962 }
1963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1964         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1965         CHECK(val->result_ok);
1966         LDKInitFeatures res_var = (*val->contents.result);
1967         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1968         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1969         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1970         return res_ref;
1971 }
1972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1973         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1974         CHECK(!val->result_ok);
1975         LDKDecodeError err_var = (*val->contents.err);
1976         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1977         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1978         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1979         return err_ref;
1980 }
1981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1982         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1983 }
1984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1985         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1986         CHECK(val->result_ok);
1987         LDKNodeFeatures res_var = (*val->contents.result);
1988         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1989         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1990         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1991         return res_ref;
1992 }
1993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1994         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1995         CHECK(!val->result_ok);
1996         LDKDecodeError err_var = (*val->contents.err);
1997         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1998         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1999         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2000         return err_ref;
2001 }
2002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2003         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2004 }
2005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2006         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2007         CHECK(val->result_ok);
2008         LDKChannelFeatures res_var = (*val->contents.result);
2009         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2010         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2011         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2012         return res_ref;
2013 }
2014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2015         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2016         CHECK(!val->result_ok);
2017         LDKDecodeError err_var = (*val->contents.err);
2018         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2019         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2020         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2021         return err_ref;
2022 }
2023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2024         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2025 }
2026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2027         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2028         CHECK(val->result_ok);
2029         LDKInvoiceFeatures res_var = (*val->contents.result);
2030         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2031         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2032         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2033         return res_ref;
2034 }
2035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2036         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2037         CHECK(!val->result_ok);
2038         LDKDecodeError err_var = (*val->contents.err);
2039         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2040         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2041         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2042         return err_ref;
2043 }
2044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2045         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2046 }
2047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2048         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2049         CHECK(val->result_ok);
2050         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2051         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2052         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2053         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2054         return res_ref;
2055 }
2056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2057         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2058         CHECK(!val->result_ok);
2059         LDKDecodeError err_var = (*val->contents.err);
2060         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2061         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2062         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2063         return err_ref;
2064 }
2065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2066         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2067 }
2068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2069         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2070         CHECK(val->result_ok);
2071         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2075         return res_ref;
2076 }
2077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2078         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2079         CHECK(!val->result_ok);
2080         LDKDecodeError err_var = (*val->contents.err);
2081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2083         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2084         return err_ref;
2085 }
2086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2087         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2088 }
2089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2090         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2091         CHECK(val->result_ok);
2092         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2093         return res_ref;
2094 }
2095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2096         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2097         CHECK(!val->result_ok);
2098         LDKDecodeError err_var = (*val->contents.err);
2099         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2100         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2101         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2102         return err_ref;
2103 }
2104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2105         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2106         LDKSignature a_ref;
2107         CHECK((*env)->GetArrayLength(env, a) == 64);
2108         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2109         ret->a = a_ref;
2110         LDKCVec_SignatureZ b_constr;
2111         b_constr.datalen = (*env)->GetArrayLength(env, b);
2112         if (b_constr.datalen > 0)
2113                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2114         else
2115                 b_constr.data = NULL;
2116         for (size_t i = 0; i < b_constr.datalen; i++) {
2117                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2118                 LDKSignature b_conv_8_ref;
2119                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2120                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2121                 b_constr.data[i] = b_conv_8_ref;
2122         }
2123         ret->b = b_constr;
2124         return (uint64_t)ret;
2125 }
2126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2127         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2128         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2129         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2130         return a_arr;
2131 }
2132 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2133         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2134         LDKCVec_SignatureZ b_var = tuple->b;
2135         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2136         ;
2137         for (size_t i = 0; i < b_var.datalen; i++) {
2138                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2139                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2140                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2141         }
2142         return b_arr;
2143 }
2144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2145         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2146 }
2147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2148         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2149         CHECK(val->result_ok);
2150         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2151         return res_ref;
2152 }
2153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2154         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2155         CHECK(!val->result_ok);
2156         return *val->contents.err;
2157 }
2158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2159         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2160 }
2161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2162         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2163         CHECK(val->result_ok);
2164         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2165         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2166         return res_arr;
2167 }
2168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2169         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2170         CHECK(!val->result_ok);
2171         return *val->contents.err;
2172 }
2173 typedef struct LDKBaseSign_JCalls {
2174         atomic_size_t refcnt;
2175         JavaVM *vm;
2176         jweak o;
2177         jmethodID get_per_commitment_point_meth;
2178         jmethodID release_commitment_secret_meth;
2179         jmethodID channel_keys_id_meth;
2180         jmethodID sign_counterparty_commitment_meth;
2181         jmethodID sign_holder_commitment_and_htlcs_meth;
2182         jmethodID sign_justice_revoked_output_meth;
2183         jmethodID sign_justice_revoked_htlc_meth;
2184         jmethodID sign_counterparty_htlc_transaction_meth;
2185         jmethodID sign_closing_transaction_meth;
2186         jmethodID sign_channel_announcement_meth;
2187         jmethodID ready_channel_meth;
2188 } LDKBaseSign_JCalls;
2189 static void LDKBaseSign_JCalls_free(void* this_arg) {
2190         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2191         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2200                 if (get_jenv_res == JNI_EDETACHED) {
2201                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2202                 }
2203                 FREE(j_calls);
2204         }
2205 }
2206 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2207         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2208         JNIEnv *env;
2209         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2210         if (get_jenv_res == JNI_EDETACHED) {
2211                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2212         } else {
2213                 DO_ASSERT(get_jenv_res == JNI_OK);
2214         }
2215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2216         CHECK(obj != NULL);
2217         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2218         if ((*env)->ExceptionCheck(env)) {
2219                 (*env)->ExceptionDescribe(env);
2220                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2221         }
2222         LDKPublicKey ret_ref;
2223         CHECK((*env)->GetArrayLength(env, ret) == 33);
2224         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2225         if (get_jenv_res == JNI_EDETACHED) {
2226                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2227         }
2228         return ret_ref;
2229 }
2230 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2231         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2232         JNIEnv *env;
2233         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2234         if (get_jenv_res == JNI_EDETACHED) {
2235                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2236         } else {
2237                 DO_ASSERT(get_jenv_res == JNI_OK);
2238         }
2239         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2240         CHECK(obj != NULL);
2241         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2242         if ((*env)->ExceptionCheck(env)) {
2243                 (*env)->ExceptionDescribe(env);
2244                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2245         }
2246         LDKThirtyTwoBytes ret_ref;
2247         CHECK((*env)->GetArrayLength(env, ret) == 32);
2248         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2249         if (get_jenv_res == JNI_EDETACHED) {
2250                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2251         }
2252         return ret_ref;
2253 }
2254 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2255         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2256         JNIEnv *env;
2257         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2258         if (get_jenv_res == JNI_EDETACHED) {
2259                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2260         } else {
2261                 DO_ASSERT(get_jenv_res == JNI_OK);
2262         }
2263         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2264         CHECK(obj != NULL);
2265         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2266         if ((*env)->ExceptionCheck(env)) {
2267                 (*env)->ExceptionDescribe(env);
2268                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2269         }
2270         LDKThirtyTwoBytes ret_ref;
2271         CHECK((*env)->GetArrayLength(env, ret) == 32);
2272         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2273         if (get_jenv_res == JNI_EDETACHED) {
2274                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2275         }
2276         return ret_ref;
2277 }
2278 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2279         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2280         JNIEnv *env;
2281         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2282         if (get_jenv_res == JNI_EDETACHED) {
2283                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2284         } else {
2285                 DO_ASSERT(get_jenv_res == JNI_OK);
2286         }
2287         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2288         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2289         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2290         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2291         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2292         if (commitment_tx_var.is_owned) {
2293                 commitment_tx_ref |= 1;
2294         }
2295         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2296         CHECK(obj != NULL);
2297         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2298         if ((*env)->ExceptionCheck(env)) {
2299                 (*env)->ExceptionDescribe(env);
2300                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2301         }
2302         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2303         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2304         if (get_jenv_res == JNI_EDETACHED) {
2305                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2306         }
2307         return ret_conv;
2308 }
2309 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2310         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2311         JNIEnv *env;
2312         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2313         if (get_jenv_res == JNI_EDETACHED) {
2314                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2315         } else {
2316                 DO_ASSERT(get_jenv_res == JNI_OK);
2317         }
2318         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2319         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2320         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2321         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2322         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2323         if (commitment_tx_var.is_owned) {
2324                 commitment_tx_ref |= 1;
2325         }
2326         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2327         CHECK(obj != NULL);
2328         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2329         if ((*env)->ExceptionCheck(env)) {
2330                 (*env)->ExceptionDescribe(env);
2331                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2332         }
2333         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2334         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2335         if (get_jenv_res == JNI_EDETACHED) {
2336                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2337         }
2338         return ret_conv;
2339 }
2340 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]) {
2341         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2342         JNIEnv *env;
2343         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2344         if (get_jenv_res == JNI_EDETACHED) {
2345                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2346         } else {
2347                 DO_ASSERT(get_jenv_res == JNI_OK);
2348         }
2349         LDKTransaction justice_tx_var = justice_tx;
2350         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2351         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2352         Transaction_free(justice_tx_var);
2353         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2354         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2356         CHECK(obj != NULL);
2357         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2358         if ((*env)->ExceptionCheck(env)) {
2359                 (*env)->ExceptionDescribe(env);
2360                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2361         }
2362         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2363         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2364         if (get_jenv_res == JNI_EDETACHED) {
2365                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2366         }
2367         return ret_conv;
2368 }
2369 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) {
2370         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2371         JNIEnv *env;
2372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2373         if (get_jenv_res == JNI_EDETACHED) {
2374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2375         } else {
2376                 DO_ASSERT(get_jenv_res == JNI_OK);
2377         }
2378         LDKTransaction justice_tx_var = justice_tx;
2379         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2380         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2381         Transaction_free(justice_tx_var);
2382         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2383         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2384         LDKHTLCOutputInCommitment htlc_var = *htlc;
2385         htlc_var = HTLCOutputInCommitment_clone(htlc);
2386         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2387         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2388         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2389         if (htlc_var.is_owned) {
2390                 htlc_ref |= 1;
2391         }
2392         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2393         CHECK(obj != NULL);
2394         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2395         if ((*env)->ExceptionCheck(env)) {
2396                 (*env)->ExceptionDescribe(env);
2397                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2398         }
2399         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2400         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2401         if (get_jenv_res == JNI_EDETACHED) {
2402                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2403         }
2404         return ret_conv;
2405 }
2406 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) {
2407         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2408         JNIEnv *env;
2409         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2410         if (get_jenv_res == JNI_EDETACHED) {
2411                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2412         } else {
2413                 DO_ASSERT(get_jenv_res == JNI_OK);
2414         }
2415         LDKTransaction htlc_tx_var = htlc_tx;
2416         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2417         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2418         Transaction_free(htlc_tx_var);
2419         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2420         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2421         LDKHTLCOutputInCommitment htlc_var = *htlc;
2422         htlc_var = HTLCOutputInCommitment_clone(htlc);
2423         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2424         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2425         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2426         if (htlc_var.is_owned) {
2427                 htlc_ref |= 1;
2428         }
2429         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2430         CHECK(obj != NULL);
2431         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2432         if ((*env)->ExceptionCheck(env)) {
2433                 (*env)->ExceptionDescribe(env);
2434                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2435         }
2436         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2437         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2438         if (get_jenv_res == JNI_EDETACHED) {
2439                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2440         }
2441         return ret_conv;
2442 }
2443 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2444         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2445         JNIEnv *env;
2446         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2447         if (get_jenv_res == JNI_EDETACHED) {
2448                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2449         } else {
2450                 DO_ASSERT(get_jenv_res == JNI_OK);
2451         }
2452         LDKTransaction closing_tx_var = closing_tx;
2453         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2454         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2455         Transaction_free(closing_tx_var);
2456         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2457         CHECK(obj != NULL);
2458         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2459         if ((*env)->ExceptionCheck(env)) {
2460                 (*env)->ExceptionDescribe(env);
2461                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2462         }
2463         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2464         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2465         if (get_jenv_res == JNI_EDETACHED) {
2466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2467         }
2468         return ret_conv;
2469 }
2470 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2471         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2472         JNIEnv *env;
2473         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2474         if (get_jenv_res == JNI_EDETACHED) {
2475                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2476         } else {
2477                 DO_ASSERT(get_jenv_res == JNI_OK);
2478         }
2479         LDKUnsignedChannelAnnouncement msg_var = *msg;
2480         msg_var = UnsignedChannelAnnouncement_clone(msg);
2481         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2482         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2483         uint64_t msg_ref = (uint64_t)msg_var.inner;
2484         if (msg_var.is_owned) {
2485                 msg_ref |= 1;
2486         }
2487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2488         CHECK(obj != NULL);
2489         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2490         if ((*env)->ExceptionCheck(env)) {
2491                 (*env)->ExceptionDescribe(env);
2492                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2493         }
2494         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2495         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2496         if (get_jenv_res == JNI_EDETACHED) {
2497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2498         }
2499         return ret_conv;
2500 }
2501 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2502         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2503         JNIEnv *env;
2504         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2505         if (get_jenv_res == JNI_EDETACHED) {
2506                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2507         } else {
2508                 DO_ASSERT(get_jenv_res == JNI_OK);
2509         }
2510         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2511         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2512         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2513         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2514         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2515         if (channel_parameters_var.is_owned) {
2516                 channel_parameters_ref |= 1;
2517         }
2518         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2519         CHECK(obj != NULL);
2520         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2521         if ((*env)->ExceptionCheck(env)) {
2522                 (*env)->ExceptionDescribe(env);
2523                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2524         }
2525         if (get_jenv_res == JNI_EDETACHED) {
2526                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2527         }
2528 }
2529 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2530         jclass c = (*env)->GetObjectClass(env, o);
2531         CHECK(c != NULL);
2532         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2533         atomic_init(&calls->refcnt, 1);
2534         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2535         calls->o = (*env)->NewWeakGlobalRef(env, o);
2536         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2537         CHECK(calls->get_per_commitment_point_meth != NULL);
2538         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2539         CHECK(calls->release_commitment_secret_meth != NULL);
2540         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2541         CHECK(calls->channel_keys_id_meth != NULL);
2542         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2543         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2544         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2545         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2546         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2547         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2548         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2549         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2550         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2551         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2552         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2553         CHECK(calls->sign_closing_transaction_meth != NULL);
2554         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2555         CHECK(calls->sign_channel_announcement_meth != NULL);
2556         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2557         CHECK(calls->ready_channel_meth != NULL);
2558
2559         LDKChannelPublicKeys pubkeys_conv;
2560         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2561         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2562         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2563
2564         LDKBaseSign ret = {
2565                 .this_arg = (void*) calls,
2566                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2567                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2568                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2569                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2570                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2571                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2572                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2573                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2574                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2575                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2576                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2577                 .free = LDKBaseSign_JCalls_free,
2578                 .pubkeys = pubkeys_conv,
2579                 .set_pubkeys = NULL,
2580         };
2581         return ret;
2582 }
2583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2584         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2585         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2586         return (uint64_t)res_ptr;
2587 }
2588 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) {
2589         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2590         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2592         return ret_arr;
2593 }
2594
2595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2596         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2597         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2599         return ret_arr;
2600 }
2601
2602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2603         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2604         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2605         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2606         return ret_arr;
2607 }
2608
2609 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) {
2610         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2611         LDKCommitmentTransaction commitment_tx_conv;
2612         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2613         commitment_tx_conv.is_owned = false;
2614         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2615         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2616         return (uint64_t)ret_conv;
2617 }
2618
2619 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) {
2620         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2621         LDKHolderCommitmentTransaction commitment_tx_conv;
2622         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2623         commitment_tx_conv.is_owned = false;
2624         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2625         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2626         return (uint64_t)ret_conv;
2627 }
2628
2629 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) {
2630         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2631         LDKTransaction justice_tx_ref;
2632         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2633         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2634         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2635         justice_tx_ref.data_is_owned = true;
2636         unsigned char per_commitment_key_arr[32];
2637         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2638         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2639         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2640         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2641         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2642         return (uint64_t)ret_conv;
2643 }
2644
2645 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) {
2646         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2647         LDKTransaction justice_tx_ref;
2648         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2649         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2650         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2651         justice_tx_ref.data_is_owned = true;
2652         unsigned char per_commitment_key_arr[32];
2653         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2654         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2655         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2656         LDKHTLCOutputInCommitment htlc_conv;
2657         htlc_conv.inner = (void*)(htlc & (~1));
2658         htlc_conv.is_owned = false;
2659         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2660         *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);
2661         return (uint64_t)ret_conv;
2662 }
2663
2664 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) {
2665         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2666         LDKTransaction htlc_tx_ref;
2667         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2668         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2669         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2670         htlc_tx_ref.data_is_owned = true;
2671         LDKPublicKey per_commitment_point_ref;
2672         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2673         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2674         LDKHTLCOutputInCommitment htlc_conv;
2675         htlc_conv.inner = (void*)(htlc & (~1));
2676         htlc_conv.is_owned = false;
2677         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2678         *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);
2679         return (uint64_t)ret_conv;
2680 }
2681
2682 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) {
2683         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2684         LDKTransaction closing_tx_ref;
2685         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2686         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2687         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2688         closing_tx_ref.data_is_owned = true;
2689         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2690         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2691         return (uint64_t)ret_conv;
2692 }
2693
2694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2695         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2696         LDKUnsignedChannelAnnouncement msg_conv;
2697         msg_conv.inner = (void*)(msg & (~1));
2698         msg_conv.is_owned = false;
2699         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2700         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2701         return (uint64_t)ret_conv;
2702 }
2703
2704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2705         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2706         LDKChannelTransactionParameters channel_parameters_conv;
2707         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2708         channel_parameters_conv.is_owned = false;
2709         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2710 }
2711
2712 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2713         if (this_arg->set_pubkeys != NULL)
2714                 this_arg->set_pubkeys(this_arg);
2715         return this_arg->pubkeys;
2716 }
2717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2718         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2719         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2720         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2721         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2722         uint64_t ret_ref = (uint64_t)ret_var.inner;
2723         if (ret_var.is_owned) {
2724                 ret_ref |= 1;
2725         }
2726         return ret_ref;
2727 }
2728
2729 typedef struct LDKSign_JCalls {
2730         atomic_size_t refcnt;
2731         JavaVM *vm;
2732         jweak o;
2733         LDKBaseSign_JCalls* BaseSign;
2734         jmethodID write_meth;
2735 } LDKSign_JCalls;
2736 static void LDKSign_JCalls_free(void* this_arg) {
2737         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2738         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2739                 JNIEnv *env;
2740                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2741                 if (get_jenv_res == JNI_EDETACHED) {
2742                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2743                 } else {
2744                         DO_ASSERT(get_jenv_res == JNI_OK);
2745                 }
2746                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2747                 if (get_jenv_res == JNI_EDETACHED) {
2748                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2749                 }
2750                 FREE(j_calls);
2751         }
2752 }
2753 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2754         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2755         JNIEnv *env;
2756         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2757         if (get_jenv_res == JNI_EDETACHED) {
2758                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2759         } else {
2760                 DO_ASSERT(get_jenv_res == JNI_OK);
2761         }
2762         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2763         CHECK(obj != NULL);
2764         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2765         if ((*env)->ExceptionCheck(env)) {
2766                 (*env)->ExceptionDescribe(env);
2767                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2768         }
2769         LDKCVec_u8Z ret_ref;
2770         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2771         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2772         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2773         if (get_jenv_res == JNI_EDETACHED) {
2774                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2775         }
2776         return ret_ref;
2777 }
2778 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2779         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2780         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2781         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2782 }
2783 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2784         jclass c = (*env)->GetObjectClass(env, o);
2785         CHECK(c != NULL);
2786         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2787         atomic_init(&calls->refcnt, 1);
2788         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2789         calls->o = (*env)->NewWeakGlobalRef(env, o);
2790         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2791         CHECK(calls->write_meth != NULL);
2792
2793         LDKChannelPublicKeys pubkeys_conv;
2794         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2795         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2796         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2797
2798         LDKSign ret = {
2799                 .this_arg = (void*) calls,
2800                 .write = write_LDKSign_jcall,
2801                 .cloned = LDKSign_JCalls_cloned,
2802                 .free = LDKSign_JCalls_free,
2803                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2804         };
2805         calls->BaseSign = ret.BaseSign.this_arg;
2806         return ret;
2807 }
2808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2809         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2810         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2811         return (uint64_t)res_ptr;
2812 }
2813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2814         LDKSign *inp = (LDKSign *)(arg & ~1);
2815         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2816         DO_ASSERT((res_ptr & 1) == 0);
2817         return (int64_t)(res_ptr | 1);
2818 }
2819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2820         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2821         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2822         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2823         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2824         CVec_u8Z_free(ret_var);
2825         return ret_arr;
2826 }
2827
2828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2829         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2830 }
2831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2832         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2833         CHECK(val->result_ok);
2834         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2835         *ret = Sign_clone(&(*val->contents.result));
2836         return (uint64_t)ret;
2837 }
2838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2839         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2840         CHECK(!val->result_ok);
2841         LDKDecodeError err_var = (*val->contents.err);
2842         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2843         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2844         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2845         return err_ref;
2846 }
2847 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2848         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2849 }
2850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2851         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2852         CHECK(val->result_ok);
2853         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2854         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2855         return es_arr;
2856 }
2857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2858         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2859         CHECK(!val->result_ok);
2860         return *val->contents.err;
2861 }
2862 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2863         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2864         for (size_t i = 0; i < ret.datalen; i++) {
2865                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2866         }
2867         return ret;
2868 }
2869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2870         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2871 }
2872 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2873         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2874         CHECK(val->result_ok);
2875         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2876         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2877         ;
2878         for (size_t i = 0; i < res_var.datalen; i++) {
2879                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2880                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2881                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2882                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2883         }
2884         return res_arr;
2885 }
2886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2887         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2888         CHECK(!val->result_ok);
2889         return *val->contents.err;
2890 }
2891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2892         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2893 }
2894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2895         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2896         CHECK(val->result_ok);
2897         LDKInMemorySigner res_var = (*val->contents.result);
2898         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2899         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2900         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2901         return res_ref;
2902 }
2903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2904         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2905         CHECK(!val->result_ok);
2906         LDKDecodeError err_var = (*val->contents.err);
2907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2909         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2910         return err_ref;
2911 }
2912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2913         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2914         ret->datalen = (*env)->GetArrayLength(env, elems);
2915         if (ret->datalen == 0) {
2916                 ret->data = NULL;
2917         } else {
2918                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2919                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2920                 for (size_t i = 0; i < ret->datalen; i++) {
2921                         int64_t arr_elem = java_elems[i];
2922                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2923                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2924                         ret->data[i] = arr_elem_conv;
2925                 }
2926                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2927         }
2928         return (uint64_t)ret;
2929 }
2930 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2931         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2932         for (size_t i = 0; i < ret.datalen; i++) {
2933                 ret.data[i] = TxOut_clone(&orig->data[i]);
2934         }
2935         return ret;
2936 }
2937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2938         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2939 }
2940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2941         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2942         CHECK(val->result_ok);
2943         LDKTransaction res_var = (*val->contents.result);
2944         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2945         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2946         return res_arr;
2947 }
2948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2949         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2950         CHECK(!val->result_ok);
2951         return *val->contents.err;
2952 }
2953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2954         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2955         LDKThirtyTwoBytes a_ref;
2956         CHECK((*env)->GetArrayLength(env, a) == 32);
2957         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2958         ret->a = a_ref;
2959         LDKChannelMonitor b_conv;
2960         b_conv.inner = (void*)(b & (~1));
2961         b_conv.is_owned = (b & 1) || (b == 0);
2962         b_conv = ChannelMonitor_clone(&b_conv);
2963         ret->b = b_conv;
2964         return (uint64_t)ret;
2965 }
2966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2967         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2968         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2969         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2970         return a_arr;
2971 }
2972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2973         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2974         LDKChannelMonitor b_var = tuple->b;
2975         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2976         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2977         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2978         return b_ref;
2979 }
2980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2981         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2982         ret->datalen = (*env)->GetArrayLength(env, elems);
2983         if (ret->datalen == 0) {
2984                 ret->data = NULL;
2985         } else {
2986                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2987                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2988                 for (size_t i = 0; i < ret->datalen; i++) {
2989                         int64_t arr_elem = java_elems[i];
2990                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2991                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2992                         ret->data[i] = arr_elem_conv;
2993                 }
2994                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2995         }
2996         return (uint64_t)ret;
2997 }
2998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2999         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3000 }
3001 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3002         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3003         CHECK(val->result_ok);
3004         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3005         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
3006         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3007         for (size_t i = 0; i < res_var.datalen; i++) {
3008                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
3009                 res_arr_ptr[i] = res_conv_34_ref;
3010         }
3011         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3012         return res_arr;
3013 }
3014 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3015         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3016         CHECK(!val->result_ok);
3017         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3018         return err_conv;
3019 }
3020 static jclass LDKCOption_u16Z_Some_class = NULL;
3021 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3022 static jclass LDKCOption_u16Z_None_class = NULL;
3023 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3025         LDKCOption_u16Z_Some_class =
3026                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3027         CHECK(LDKCOption_u16Z_Some_class != NULL);
3028         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3029         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3030         LDKCOption_u16Z_None_class =
3031                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3032         CHECK(LDKCOption_u16Z_None_class != NULL);
3033         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3034         CHECK(LDKCOption_u16Z_None_meth != NULL);
3035 }
3036 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3037         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3038         switch(obj->tag) {
3039                 case LDKCOption_u16Z_Some: {
3040                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3041                 }
3042                 case LDKCOption_u16Z_None: {
3043                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3044                 }
3045                 default: abort();
3046         }
3047 }
3048 static jclass LDKAPIError_APIMisuseError_class = NULL;
3049 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3050 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3051 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3052 static jclass LDKAPIError_RouteError_class = NULL;
3053 static jmethodID LDKAPIError_RouteError_meth = NULL;
3054 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3055 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3056 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3057 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3058 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3059 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3061         LDKAPIError_APIMisuseError_class =
3062                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3063         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3064         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3065         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3066         LDKAPIError_FeeRateTooHigh_class =
3067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3068         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3069         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3070         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3071         LDKAPIError_RouteError_class =
3072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3073         CHECK(LDKAPIError_RouteError_class != NULL);
3074         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3075         CHECK(LDKAPIError_RouteError_meth != NULL);
3076         LDKAPIError_ChannelUnavailable_class =
3077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3078         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3079         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3080         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3081         LDKAPIError_MonitorUpdateFailed_class =
3082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3083         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3084         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3085         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3086         LDKAPIError_IncompatibleShutdownScript_class =
3087                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3088         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3089         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3090         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3091 }
3092 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3093         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3094         switch(obj->tag) {
3095                 case LDKAPIError_APIMisuseError: {
3096                         LDKStr err_str = obj->api_misuse_error.err;
3097                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3098                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3099                 }
3100                 case LDKAPIError_FeeRateTooHigh: {
3101                         LDKStr err_str = obj->fee_rate_too_high.err;
3102                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3103                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3104                 }
3105                 case LDKAPIError_RouteError: {
3106                         LDKStr err_str = obj->route_error.err;
3107                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3108                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3109                 }
3110                 case LDKAPIError_ChannelUnavailable: {
3111                         LDKStr err_str = obj->channel_unavailable.err;
3112                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3113                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3114                 }
3115                 case LDKAPIError_MonitorUpdateFailed: {
3116                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3117                 }
3118                 case LDKAPIError_IncompatibleShutdownScript: {
3119                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3120                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3121                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3122                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
3123                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3124                 }
3125                 default: abort();
3126         }
3127 }
3128 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3129         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3130 }
3131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3132         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3133         CHECK(val->result_ok);
3134         return *val->contents.result;
3135 }
3136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3137         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3138         CHECK(!val->result_ok);
3139         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3140         return err_ref;
3141 }
3142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3143         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3144         ret->datalen = (*env)->GetArrayLength(env, elems);
3145         if (ret->datalen == 0) {
3146                 ret->data = NULL;
3147         } else {
3148                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3149                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3150                 for (size_t i = 0; i < ret->datalen; i++) {
3151                         int64_t arr_elem = java_elems[i];
3152                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3153                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3154                         ret->data[i] = arr_elem_conv;
3155                 }
3156                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3157         }
3158         return (uint64_t)ret;
3159 }
3160 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3161         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3162         for (size_t i = 0; i < ret.datalen; i++) {
3163                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3164         }
3165         return ret;
3166 }
3167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3168         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3169         ret->datalen = (*env)->GetArrayLength(env, elems);
3170         if (ret->datalen == 0) {
3171                 ret->data = NULL;
3172         } else {
3173                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3174                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3175                 for (size_t i = 0; i < ret->datalen; i++) {
3176                         int64_t arr_elem = java_elems[i];
3177                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3178                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3179                         ret->data[i] = arr_elem_conv;
3180                 }
3181                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3182         }
3183         return (uint64_t)ret;
3184 }
3185 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3186         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3187         for (size_t i = 0; i < ret.datalen; i++) {
3188                 ret.data[i] = APIError_clone(&orig->data[i]);
3189         }
3190         return ret;
3191 }
3192 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3193 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3194 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3195 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3196 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3197 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3198 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3199 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3201         LDKPaymentSendFailure_ParameterError_class =
3202                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3203         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3204         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3205         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3206         LDKPaymentSendFailure_PathParameterError_class =
3207                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3208         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3209         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3210         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3211         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3212                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3213         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3214         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3215         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3216         LDKPaymentSendFailure_PartialFailure_class =
3217                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3218         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3219         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3220         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3221 }
3222 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3223         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3224         switch(obj->tag) {
3225                 case LDKPaymentSendFailure_ParameterError: {
3226                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3227                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3228                 }
3229                 case LDKPaymentSendFailure_PathParameterError: {
3230                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3231                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3232                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3233                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3234                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3235                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3236                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3237                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3238                         }
3239                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3240                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3241                 }
3242                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3243                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3244                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3245                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3246                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3247                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3248                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3249                         }
3250                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3251                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3252                 }
3253                 case LDKPaymentSendFailure_PartialFailure: {
3254                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3255                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3256                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3257                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3258                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3259                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3260                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3261                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3262                         }
3263                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3264                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3265                 }
3266                 default: abort();
3267         }
3268 }
3269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3270         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3271 }
3272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3273         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3274         CHECK(val->result_ok);
3275         return *val->contents.result;
3276 }
3277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3278         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3279         CHECK(!val->result_ok);
3280         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3281         return err_ref;
3282 }
3283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3284         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
3285 }
3286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3287         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3288         CHECK(val->result_ok);
3289         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3290         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3291         return res_arr;
3292 }
3293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3294         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
3295         CHECK(!val->result_ok);
3296         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3297         return err_ref;
3298 }
3299 static jclass LDKNetAddress_IPv4_class = NULL;
3300 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3301 static jclass LDKNetAddress_IPv6_class = NULL;
3302 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3303 static jclass LDKNetAddress_OnionV2_class = NULL;
3304 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3305 static jclass LDKNetAddress_OnionV3_class = NULL;
3306 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3308         LDKNetAddress_IPv4_class =
3309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3310         CHECK(LDKNetAddress_IPv4_class != NULL);
3311         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3312         CHECK(LDKNetAddress_IPv4_meth != NULL);
3313         LDKNetAddress_IPv6_class =
3314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3315         CHECK(LDKNetAddress_IPv6_class != NULL);
3316         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3317         CHECK(LDKNetAddress_IPv6_meth != NULL);
3318         LDKNetAddress_OnionV2_class =
3319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3320         CHECK(LDKNetAddress_OnionV2_class != NULL);
3321         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3322         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3323         LDKNetAddress_OnionV3_class =
3324                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3325         CHECK(LDKNetAddress_OnionV3_class != NULL);
3326         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3327         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3328 }
3329 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3330         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3331         switch(obj->tag) {
3332                 case LDKNetAddress_IPv4: {
3333                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3334                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3335                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3336                 }
3337                 case LDKNetAddress_IPv6: {
3338                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3339                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3340                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3341                 }
3342                 case LDKNetAddress_OnionV2: {
3343                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3344                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3345                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3346                 }
3347                 case LDKNetAddress_OnionV3: {
3348                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3349                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3350                         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);
3351                 }
3352                 default: abort();
3353         }
3354 }
3355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3356         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3357         ret->datalen = (*env)->GetArrayLength(env, elems);
3358         if (ret->datalen == 0) {
3359                 ret->data = NULL;
3360         } else {
3361                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3362                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3363                 for (size_t i = 0; i < ret->datalen; i++) {
3364                         int64_t arr_elem = java_elems[i];
3365                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3366                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3367                         ret->data[i] = arr_elem_conv;
3368                 }
3369                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3370         }
3371         return (uint64_t)ret;
3372 }
3373 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3374         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3375         for (size_t i = 0; i < ret.datalen; i++) {
3376                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3377         }
3378         return ret;
3379 }
3380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3381         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3382         LDKThirtyTwoBytes a_ref;
3383         CHECK((*env)->GetArrayLength(env, a) == 32);
3384         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3385         ret->a = a_ref;
3386         LDKThirtyTwoBytes b_ref;
3387         CHECK((*env)->GetArrayLength(env, b) == 32);
3388         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3389         ret->b = b_ref;
3390         return (uint64_t)ret;
3391 }
3392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3393         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3394         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3395         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3396         return a_arr;
3397 }
3398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3399         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3400         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3401         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3402         return b_arr;
3403 }
3404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3405         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3406 }
3407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3408         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3409         CHECK(val->result_ok);
3410         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3411         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3412         return res_arr;
3413 }
3414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3415         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3416         CHECK(!val->result_ok);
3417         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3418         return err_ref;
3419 }
3420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3421         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3422         ret->datalen = (*env)->GetArrayLength(env, elems);
3423         if (ret->datalen == 0) {
3424                 ret->data = NULL;
3425         } else {
3426                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3427                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3428                 for (size_t i = 0; i < ret->datalen; i++) {
3429                         int64_t arr_elem = java_elems[i];
3430                         LDKChannelMonitor arr_elem_conv;
3431                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3432                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3433                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3434                         ret->data[i] = arr_elem_conv;
3435                 }
3436                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3437         }
3438         return (uint64_t)ret;
3439 }
3440 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3441         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3442         for (size_t i = 0; i < ret.datalen; i++) {
3443                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3444         }
3445         return ret;
3446 }
3447 typedef struct LDKWatch_JCalls {
3448         atomic_size_t refcnt;
3449         JavaVM *vm;
3450         jweak o;
3451         jmethodID watch_channel_meth;
3452         jmethodID update_channel_meth;
3453         jmethodID release_pending_monitor_events_meth;
3454 } LDKWatch_JCalls;
3455 static void LDKWatch_JCalls_free(void* this_arg) {
3456         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3457         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3458                 JNIEnv *env;
3459                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3460                 if (get_jenv_res == JNI_EDETACHED) {
3461                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3462                 } else {
3463                         DO_ASSERT(get_jenv_res == JNI_OK);
3464                 }
3465                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3466                 if (get_jenv_res == JNI_EDETACHED) {
3467                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3468                 }
3469                 FREE(j_calls);
3470         }
3471 }
3472 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3473         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3474         JNIEnv *env;
3475         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3476         if (get_jenv_res == JNI_EDETACHED) {
3477                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3478         } else {
3479                 DO_ASSERT(get_jenv_res == JNI_OK);
3480         }
3481         LDKOutPoint funding_txo_var = funding_txo;
3482         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3483         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3484         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3485         if (funding_txo_var.is_owned) {
3486                 funding_txo_ref |= 1;
3487         }
3488         LDKChannelMonitor monitor_var = monitor;
3489         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3490         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3491         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3492         if (monitor_var.is_owned) {
3493                 monitor_ref |= 1;
3494         }
3495         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3496         CHECK(obj != NULL);
3497         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3498         if ((*env)->ExceptionCheck(env)) {
3499                 (*env)->ExceptionDescribe(env);
3500                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3501         }
3502         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3503         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3504         if (get_jenv_res == JNI_EDETACHED) {
3505                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3506         }
3507         return ret_conv;
3508 }
3509 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3510         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3511         JNIEnv *env;
3512         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3513         if (get_jenv_res == JNI_EDETACHED) {
3514                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3515         } else {
3516                 DO_ASSERT(get_jenv_res == JNI_OK);
3517         }
3518         LDKOutPoint funding_txo_var = funding_txo;
3519         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3520         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3521         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3522         if (funding_txo_var.is_owned) {
3523                 funding_txo_ref |= 1;
3524         }
3525         LDKChannelMonitorUpdate update_var = update;
3526         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3527         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3528         uint64_t update_ref = (uint64_t)update_var.inner;
3529         if (update_var.is_owned) {
3530                 update_ref |= 1;
3531         }
3532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3533         CHECK(obj != NULL);
3534         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3535         if ((*env)->ExceptionCheck(env)) {
3536                 (*env)->ExceptionDescribe(env);
3537                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3538         }
3539         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3540         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3541         if (get_jenv_res == JNI_EDETACHED) {
3542                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3543         }
3544         return ret_conv;
3545 }
3546 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3547         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3548         JNIEnv *env;
3549         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3550         if (get_jenv_res == JNI_EDETACHED) {
3551                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3552         } else {
3553                 DO_ASSERT(get_jenv_res == JNI_OK);
3554         }
3555         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3556         CHECK(obj != NULL);
3557         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3558         if ((*env)->ExceptionCheck(env)) {
3559                 (*env)->ExceptionDescribe(env);
3560                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3561         }
3562         LDKCVec_MonitorEventZ ret_constr;
3563         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3564         if (ret_constr.datalen > 0)
3565                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3566         else
3567                 ret_constr.data = NULL;
3568         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3569         for (size_t o = 0; o < ret_constr.datalen; o++) {
3570                 int64_t ret_conv_14 = ret_vals[o];
3571                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3572                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3573                 ret_constr.data[o] = ret_conv_14_conv;
3574         }
3575         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3576         if (get_jenv_res == JNI_EDETACHED) {
3577                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3578         }
3579         return ret_constr;
3580 }
3581 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3582         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3583         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3584 }
3585 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3586         jclass c = (*env)->GetObjectClass(env, o);
3587         CHECK(c != NULL);
3588         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3589         atomic_init(&calls->refcnt, 1);
3590         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3591         calls->o = (*env)->NewWeakGlobalRef(env, o);
3592         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3593         CHECK(calls->watch_channel_meth != NULL);
3594         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3595         CHECK(calls->update_channel_meth != NULL);
3596         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3597         CHECK(calls->release_pending_monitor_events_meth != NULL);
3598
3599         LDKWatch ret = {
3600                 .this_arg = (void*) calls,
3601                 .watch_channel = watch_channel_LDKWatch_jcall,
3602                 .update_channel = update_channel_LDKWatch_jcall,
3603                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3604                 .free = LDKWatch_JCalls_free,
3605         };
3606         return ret;
3607 }
3608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3609         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3610         *res_ptr = LDKWatch_init(env, clz, o);
3611         return (uint64_t)res_ptr;
3612 }
3613 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) {
3614         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3615         LDKOutPoint funding_txo_conv;
3616         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3617         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3618         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3619         LDKChannelMonitor monitor_conv;
3620         monitor_conv.inner = (void*)(monitor & (~1));
3621         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3622         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3623         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3624         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3625         return (uint64_t)ret_conv;
3626 }
3627
3628 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) {
3629         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3630         LDKOutPoint funding_txo_conv;
3631         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3632         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3633         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3634         LDKChannelMonitorUpdate update_conv;
3635         update_conv.inner = (void*)(update & (~1));
3636         update_conv.is_owned = (update & 1) || (update == 0);
3637         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3638         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3639         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3640         return (uint64_t)ret_conv;
3641 }
3642
3643 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3644         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3645         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3646         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3647         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3648         for (size_t o = 0; o < ret_var.datalen; o++) {
3649                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3650                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3651                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3652                 ret_arr_ptr[o] = ret_conv_14_ref;
3653         }
3654         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3655         FREE(ret_var.data);
3656         return ret_arr;
3657 }
3658
3659 typedef struct LDKBroadcasterInterface_JCalls {
3660         atomic_size_t refcnt;
3661         JavaVM *vm;
3662         jweak o;
3663         jmethodID broadcast_transaction_meth;
3664 } LDKBroadcasterInterface_JCalls;
3665 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3666         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3667         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3668                 JNIEnv *env;
3669                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3670                 if (get_jenv_res == JNI_EDETACHED) {
3671                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3672                 } else {
3673                         DO_ASSERT(get_jenv_res == JNI_OK);
3674                 }
3675                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3676                 if (get_jenv_res == JNI_EDETACHED) {
3677                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3678                 }
3679                 FREE(j_calls);
3680         }
3681 }
3682 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3683         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3684         JNIEnv *env;
3685         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3686         if (get_jenv_res == JNI_EDETACHED) {
3687                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3688         } else {
3689                 DO_ASSERT(get_jenv_res == JNI_OK);
3690         }
3691         LDKTransaction tx_var = tx;
3692         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3693         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3694         Transaction_free(tx_var);
3695         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3696         CHECK(obj != NULL);
3697         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3698         if ((*env)->ExceptionCheck(env)) {
3699                 (*env)->ExceptionDescribe(env);
3700                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3701         }
3702         if (get_jenv_res == JNI_EDETACHED) {
3703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3704         }
3705 }
3706 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3707         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3708         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3709 }
3710 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3711         jclass c = (*env)->GetObjectClass(env, o);
3712         CHECK(c != NULL);
3713         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3714         atomic_init(&calls->refcnt, 1);
3715         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3716         calls->o = (*env)->NewWeakGlobalRef(env, o);
3717         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3718         CHECK(calls->broadcast_transaction_meth != NULL);
3719
3720         LDKBroadcasterInterface ret = {
3721                 .this_arg = (void*) calls,
3722                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3723                 .free = LDKBroadcasterInterface_JCalls_free,
3724         };
3725         return ret;
3726 }
3727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3728         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3729         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3730         return (uint64_t)res_ptr;
3731 }
3732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3733         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3734         LDKTransaction tx_ref;
3735         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3736         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3737         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3738         tx_ref.data_is_owned = true;
3739         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3740 }
3741
3742 typedef struct LDKKeysInterface_JCalls {
3743         atomic_size_t refcnt;
3744         JavaVM *vm;
3745         jweak o;
3746         jmethodID get_node_secret_meth;
3747         jmethodID get_destination_script_meth;
3748         jmethodID get_shutdown_scriptpubkey_meth;
3749         jmethodID get_channel_signer_meth;
3750         jmethodID get_secure_random_bytes_meth;
3751         jmethodID read_chan_signer_meth;
3752         jmethodID sign_invoice_meth;
3753 } LDKKeysInterface_JCalls;
3754 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3755         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3756         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3757                 JNIEnv *env;
3758                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3759                 if (get_jenv_res == JNI_EDETACHED) {
3760                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3761                 } else {
3762                         DO_ASSERT(get_jenv_res == JNI_OK);
3763                 }
3764                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3765                 if (get_jenv_res == JNI_EDETACHED) {
3766                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3767                 }
3768                 FREE(j_calls);
3769         }
3770 }
3771 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3772         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3773         JNIEnv *env;
3774         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3775         if (get_jenv_res == JNI_EDETACHED) {
3776                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3777         } else {
3778                 DO_ASSERT(get_jenv_res == JNI_OK);
3779         }
3780         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3781         CHECK(obj != NULL);
3782         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3783         if ((*env)->ExceptionCheck(env)) {
3784                 (*env)->ExceptionDescribe(env);
3785                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3786         }
3787         LDKSecretKey ret_ref;
3788         CHECK((*env)->GetArrayLength(env, ret) == 32);
3789         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3790         if (get_jenv_res == JNI_EDETACHED) {
3791                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3792         }
3793         return ret_ref;
3794 }
3795 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3796         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3797         JNIEnv *env;
3798         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3799         if (get_jenv_res == JNI_EDETACHED) {
3800                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3801         } else {
3802                 DO_ASSERT(get_jenv_res == JNI_OK);
3803         }
3804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3805         CHECK(obj != NULL);
3806         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3807         if ((*env)->ExceptionCheck(env)) {
3808                 (*env)->ExceptionDescribe(env);
3809                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3810         }
3811         LDKCVec_u8Z ret_ref;
3812         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3813         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3814         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3815         if (get_jenv_res == JNI_EDETACHED) {
3816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3817         }
3818         return ret_ref;
3819 }
3820 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
3821         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3822         JNIEnv *env;
3823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3824         if (get_jenv_res == JNI_EDETACHED) {
3825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3826         } else {
3827                 DO_ASSERT(get_jenv_res == JNI_OK);
3828         }
3829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3830         CHECK(obj != NULL);
3831         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
3832         if ((*env)->ExceptionCheck(env)) {
3833                 (*env)->ExceptionDescribe(env);
3834                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
3835         }
3836         LDKShutdownScript ret_conv;
3837         ret_conv.inner = (void*)(ret & (~1));
3838         ret_conv.is_owned = (ret & 1) || (ret == 0);
3839         ret_conv = ShutdownScript_clone(&ret_conv);
3840         if (get_jenv_res == JNI_EDETACHED) {
3841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3842         }
3843         return ret_conv;
3844 }
3845 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3846         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3847         JNIEnv *env;
3848         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3849         if (get_jenv_res == JNI_EDETACHED) {
3850                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3851         } else {
3852                 DO_ASSERT(get_jenv_res == JNI_OK);
3853         }
3854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3855         CHECK(obj != NULL);
3856         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3857         if ((*env)->ExceptionCheck(env)) {
3858                 (*env)->ExceptionDescribe(env);
3859                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3860         }
3861         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3862         ret_conv = Sign_clone(&ret_conv);
3863         if (get_jenv_res == JNI_EDETACHED) {
3864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3865         }
3866         return ret_conv;
3867 }
3868 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3869         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3870         JNIEnv *env;
3871         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3872         if (get_jenv_res == JNI_EDETACHED) {
3873                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3874         } else {
3875                 DO_ASSERT(get_jenv_res == JNI_OK);
3876         }
3877         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3878         CHECK(obj != NULL);
3879         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
3880         if ((*env)->ExceptionCheck(env)) {
3881                 (*env)->ExceptionDescribe(env);
3882                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3883         }
3884         LDKThirtyTwoBytes ret_ref;
3885         CHECK((*env)->GetArrayLength(env, ret) == 32);
3886         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3887         if (get_jenv_res == JNI_EDETACHED) {
3888                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3889         }
3890         return ret_ref;
3891 }
3892 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3893         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3894         JNIEnv *env;
3895         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3896         if (get_jenv_res == JNI_EDETACHED) {
3897                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3898         } else {
3899                 DO_ASSERT(get_jenv_res == JNI_OK);
3900         }
3901         LDKu8slice reader_var = reader;
3902         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3903         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3904         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3905         CHECK(obj != NULL);
3906         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3907         if ((*env)->ExceptionCheck(env)) {
3908                 (*env)->ExceptionDescribe(env);
3909                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3910         }
3911         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3912         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3913         if (get_jenv_res == JNI_EDETACHED) {
3914                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3915         }
3916         return ret_conv;
3917 }
3918 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3919         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3920         JNIEnv *env;
3921         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3922         if (get_jenv_res == JNI_EDETACHED) {
3923                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3924         } else {
3925                 DO_ASSERT(get_jenv_res == JNI_OK);
3926         }
3927         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3928         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3929         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3930         CVec_u8Z_free(invoice_preimage_var);
3931         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3932         CHECK(obj != NULL);
3933         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3934         if ((*env)->ExceptionCheck(env)) {
3935                 (*env)->ExceptionDescribe(env);
3936                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3937         }
3938         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3939         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3940         if (get_jenv_res == JNI_EDETACHED) {
3941                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3942         }
3943         return ret_conv;
3944 }
3945 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3946         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3947         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3948 }
3949 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3950         jclass c = (*env)->GetObjectClass(env, o);
3951         CHECK(c != NULL);
3952         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3953         atomic_init(&calls->refcnt, 1);
3954         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3955         calls->o = (*env)->NewWeakGlobalRef(env, o);
3956         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3957         CHECK(calls->get_node_secret_meth != NULL);
3958         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3959         CHECK(calls->get_destination_script_meth != NULL);
3960         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
3961         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
3962         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3963         CHECK(calls->get_channel_signer_meth != NULL);
3964         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3965         CHECK(calls->get_secure_random_bytes_meth != NULL);
3966         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3967         CHECK(calls->read_chan_signer_meth != NULL);
3968         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3969         CHECK(calls->sign_invoice_meth != NULL);
3970
3971         LDKKeysInterface ret = {
3972                 .this_arg = (void*) calls,
3973                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3974                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3975                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
3976                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3977                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3978                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3979                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3980                 .free = LDKKeysInterface_JCalls_free,
3981         };
3982         return ret;
3983 }
3984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3985         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3986         *res_ptr = LDKKeysInterface_init(env, clz, o);
3987         return (uint64_t)res_ptr;
3988 }
3989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3990         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3991         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3993         return ret_arr;
3994 }
3995
3996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3997         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3998         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4001         CVec_u8Z_free(ret_var);
4002         return ret_arr;
4003 }
4004
4005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4006         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4007         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4010         uint64_t ret_ref = (uint64_t)ret_var.inner;
4011         if (ret_var.is_owned) {
4012                 ret_ref |= 1;
4013         }
4014         return ret_ref;
4015 }
4016
4017 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) {
4018         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4019         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
4020         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4021         return (uint64_t)ret;
4022 }
4023
4024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4025         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4026         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4028         return ret_arr;
4029 }
4030
4031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4032         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4033         LDKu8slice reader_ref;
4034         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4035         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4036         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4037         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4038         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4039         return (uint64_t)ret_conv;
4040 }
4041
4042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4043         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
4044         LDKCVec_u8Z invoice_preimage_ref;
4045         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4046         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4047         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4048         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4049         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4050         return (uint64_t)ret_conv;
4051 }
4052
4053 typedef struct LDKFeeEstimator_JCalls {
4054         atomic_size_t refcnt;
4055         JavaVM *vm;
4056         jweak o;
4057         jmethodID get_est_sat_per_1000_weight_meth;
4058 } LDKFeeEstimator_JCalls;
4059 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4060         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4061         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4062                 JNIEnv *env;
4063                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4064                 if (get_jenv_res == JNI_EDETACHED) {
4065                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4066                 } else {
4067                         DO_ASSERT(get_jenv_res == JNI_OK);
4068                 }
4069                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4070                 if (get_jenv_res == JNI_EDETACHED) {
4071                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4072                 }
4073                 FREE(j_calls);
4074         }
4075 }
4076 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4077         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4078         JNIEnv *env;
4079         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4080         if (get_jenv_res == JNI_EDETACHED) {
4081                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4082         } else {
4083                 DO_ASSERT(get_jenv_res == JNI_OK);
4084         }
4085         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4087         CHECK(obj != NULL);
4088         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4089         if ((*env)->ExceptionCheck(env)) {
4090                 (*env)->ExceptionDescribe(env);
4091                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4092         }
4093         if (get_jenv_res == JNI_EDETACHED) {
4094                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4095         }
4096         return ret;
4097 }
4098 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4099         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4100         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4101 }
4102 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4103         jclass c = (*env)->GetObjectClass(env, o);
4104         CHECK(c != NULL);
4105         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4106         atomic_init(&calls->refcnt, 1);
4107         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4108         calls->o = (*env)->NewWeakGlobalRef(env, o);
4109         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4110         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4111
4112         LDKFeeEstimator ret = {
4113                 .this_arg = (void*) calls,
4114                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4115                 .free = LDKFeeEstimator_JCalls_free,
4116         };
4117         return ret;
4118 }
4119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4120         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4121         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4122         return (uint64_t)res_ptr;
4123 }
4124 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) {
4125         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4126         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4127         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4128         return ret_val;
4129 }
4130
4131 typedef struct LDKLogger_JCalls {
4132         atomic_size_t refcnt;
4133         JavaVM *vm;
4134         jweak o;
4135         jmethodID log_meth;
4136 } LDKLogger_JCalls;
4137 static void LDKLogger_JCalls_free(void* this_arg) {
4138         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4139         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4140                 JNIEnv *env;
4141                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4142                 if (get_jenv_res == JNI_EDETACHED) {
4143                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4144                 } else {
4145                         DO_ASSERT(get_jenv_res == JNI_OK);
4146                 }
4147                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4148                 if (get_jenv_res == JNI_EDETACHED) {
4149                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4150                 }
4151                 FREE(j_calls);
4152         }
4153 }
4154 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4155         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4156         JNIEnv *env;
4157         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4158         if (get_jenv_res == JNI_EDETACHED) {
4159                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4160         } else {
4161                 DO_ASSERT(get_jenv_res == JNI_OK);
4162         }
4163         const char* record_str = record;
4164         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4165         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4166         CHECK(obj != NULL);
4167         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4168         if ((*env)->ExceptionCheck(env)) {
4169                 (*env)->ExceptionDescribe(env);
4170                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4171         }
4172         if (get_jenv_res == JNI_EDETACHED) {
4173                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4174         }
4175 }
4176 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4177         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4178         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4179 }
4180 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4181         jclass c = (*env)->GetObjectClass(env, o);
4182         CHECK(c != NULL);
4183         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4184         atomic_init(&calls->refcnt, 1);
4185         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4186         calls->o = (*env)->NewWeakGlobalRef(env, o);
4187         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4188         CHECK(calls->log_meth != NULL);
4189
4190         LDKLogger ret = {
4191                 .this_arg = (void*) calls,
4192                 .log = log_LDKLogger_jcall,
4193                 .free = LDKLogger_JCalls_free,
4194         };
4195         return ret;
4196 }
4197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4198         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4199         *res_ptr = LDKLogger_init(env, clz, o);
4200         return (uint64_t)res_ptr;
4201 }
4202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4203         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4204         LDKThirtyTwoBytes a_ref;
4205         CHECK((*env)->GetArrayLength(env, a) == 32);
4206         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4207         ret->a = a_ref;
4208         LDKChannelManager b_conv;
4209         b_conv.inner = (void*)(b & (~1));
4210         b_conv.is_owned = (b & 1) || (b == 0);
4211         // Warning: we need a move here but no clone is available for LDKChannelManager
4212         ret->b = b_conv;
4213         return (uint64_t)ret;
4214 }
4215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4216         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4217         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4218         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4219         return a_arr;
4220 }
4221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4222         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4223         LDKChannelManager b_var = tuple->b;
4224         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4227         return b_ref;
4228 }
4229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4230         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4231 }
4232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4233         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4234         CHECK(val->result_ok);
4235         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4236         return res_ref;
4237 }
4238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4239         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4240         CHECK(!val->result_ok);
4241         LDKDecodeError err_var = (*val->contents.err);
4242         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4243         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4244         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4245         return err_ref;
4246 }
4247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4248         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4249 }
4250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4251         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4252         CHECK(val->result_ok);
4253         LDKChannelConfig res_var = (*val->contents.result);
4254         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4255         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4256         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4257         return res_ref;
4258 }
4259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4260         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4261         CHECK(!val->result_ok);
4262         LDKDecodeError err_var = (*val->contents.err);
4263         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4264         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4265         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4266         return err_ref;
4267 }
4268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4269         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4270 }
4271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4272         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4273         CHECK(val->result_ok);
4274         LDKOutPoint res_var = (*val->contents.result);
4275         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4278         return res_ref;
4279 }
4280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4281         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4282         CHECK(!val->result_ok);
4283         LDKDecodeError err_var = (*val->contents.err);
4284         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4285         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4286         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4287         return err_ref;
4288 }
4289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4290         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4291 }
4292 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4293         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4294         CHECK(val->result_ok);
4295         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4296         return res_conv;
4297 }
4298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4299         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4300         CHECK(!val->result_ok);
4301         return *val->contents.err;
4302 }
4303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4304         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4305 }
4306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4307         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4308         CHECK(val->result_ok);
4309         LDKInvoice res_var = (*val->contents.result);
4310         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4311         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4312         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4313         return res_ref;
4314 }
4315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4316         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4317         CHECK(!val->result_ok);
4318         return *val->contents.err;
4319 }
4320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4321         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4322 }
4323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4324         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4325         CHECK(val->result_ok);
4326         LDKSignedRawInvoice res_var = (*val->contents.result);
4327         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4328         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4329         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4330         return res_ref;
4331 }
4332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4333         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4334         CHECK(!val->result_ok);
4335         return *val->contents.err;
4336 }
4337 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) {
4338         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4339         LDKRawInvoice a_conv;
4340         a_conv.inner = (void*)(a & (~1));
4341         a_conv.is_owned = (a & 1) || (a == 0);
4342         a_conv = RawInvoice_clone(&a_conv);
4343         ret->a = a_conv;
4344         LDKThirtyTwoBytes b_ref;
4345         CHECK((*env)->GetArrayLength(env, b) == 32);
4346         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4347         ret->b = b_ref;
4348         LDKInvoiceSignature c_conv;
4349         c_conv.inner = (void*)(c & (~1));
4350         c_conv.is_owned = (c & 1) || (c == 0);
4351         c_conv = InvoiceSignature_clone(&c_conv);
4352         ret->c = c_conv;
4353         return (uint64_t)ret;
4354 }
4355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4356         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4357         LDKRawInvoice a_var = tuple->a;
4358         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4359         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4360         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4361         return a_ref;
4362 }
4363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4364         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4365         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4366         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4367         return b_arr;
4368 }
4369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4370         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4371         LDKInvoiceSignature c_var = tuple->c;
4372         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4373         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4374         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4375         return c_ref;
4376 }
4377 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4378         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4379 }
4380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4381         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4382         CHECK(val->result_ok);
4383         LDKPayeePubKey res_var = (*val->contents.result);
4384         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4385         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4386         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4387         return res_ref;
4388 }
4389 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4390         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4391         CHECK(!val->result_ok);
4392         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4393         return err_conv;
4394 }
4395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4396         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4397         ret->datalen = (*env)->GetArrayLength(env, elems);
4398         if (ret->datalen == 0) {
4399                 ret->data = NULL;
4400         } else {
4401                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4402                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4403                 for (size_t i = 0; i < ret->datalen; i++) {
4404                         int64_t arr_elem = java_elems[i];
4405                         LDKPrivateRoute arr_elem_conv;
4406                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4407                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4408                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4409                         ret->data[i] = arr_elem_conv;
4410                 }
4411                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4412         }
4413         return (uint64_t)ret;
4414 }
4415 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4416         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4417         for (size_t i = 0; i < ret.datalen; i++) {
4418                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4419         }
4420         return ret;
4421 }
4422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4423         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4424 }
4425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4426         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4427         CHECK(val->result_ok);
4428         LDKPositiveTimestamp res_var = (*val->contents.result);
4429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4431         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4432         return res_ref;
4433 }
4434 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4435         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4436         CHECK(!val->result_ok);
4437         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4438         return err_conv;
4439 }
4440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4441         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4442 }
4443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4444         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4445         CHECK(val->result_ok);
4446         return *val->contents.result;
4447 }
4448 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4449         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4450         CHECK(!val->result_ok);
4451         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4452         return err_conv;
4453 }
4454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4455         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4456 }
4457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4458         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4459         CHECK(val->result_ok);
4460         LDKInvoice res_var = (*val->contents.result);
4461         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4464         return res_ref;
4465 }
4466 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4467         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4468         CHECK(!val->result_ok);
4469         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4470         return err_conv;
4471 }
4472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4473         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4474 }
4475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4476         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4477         CHECK(val->result_ok);
4478         LDKDescription res_var = (*val->contents.result);
4479         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4480         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4481         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4482         return res_ref;
4483 }
4484 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4485         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4486         CHECK(!val->result_ok);
4487         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4488         return err_conv;
4489 }
4490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4491         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4492 }
4493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4494         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4495         CHECK(val->result_ok);
4496         LDKExpiryTime res_var = (*val->contents.result);
4497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4499         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4500         return res_ref;
4501 }
4502 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4503         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4504         CHECK(!val->result_ok);
4505         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4506         return err_conv;
4507 }
4508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4509         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4510 }
4511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4512         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4513         CHECK(val->result_ok);
4514         LDKPrivateRoute res_var = (*val->contents.result);
4515         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4516         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4517         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4518         return res_ref;
4519 }
4520 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4521         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4522         CHECK(!val->result_ok);
4523         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4524         return err_conv;
4525 }
4526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4527         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4528 }
4529 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4530         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4531         CHECK(val->result_ok);
4532         LDKStr res_str = (*val->contents.result);
4533         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4534         return res_conv;
4535 }
4536 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4537         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4538         CHECK(!val->result_ok);
4539         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4540         return err_conv;
4541 }
4542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4543         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4544 }
4545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4546         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4547         CHECK(val->result_ok);
4548         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4549         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4550         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4551         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4552         return res_ref;
4553 }
4554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4555         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4556         CHECK(!val->result_ok);
4557         LDKDecodeError err_var = (*val->contents.err);
4558         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4559         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4560         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4561         return err_ref;
4562 }
4563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4564         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4565 }
4566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4567         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4568         CHECK(val->result_ok);
4569         LDKHTLCUpdate res_var = (*val->contents.result);
4570         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4571         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4572         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4573         return res_ref;
4574 }
4575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4576         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4577         CHECK(!val->result_ok);
4578         LDKDecodeError err_var = (*val->contents.err);
4579         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4580         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4581         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4582         return err_ref;
4583 }
4584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4585         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4586 }
4587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4588         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4589         CHECK(val->result_ok);
4590         return *val->contents.result;
4591 }
4592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4593         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4594         CHECK(!val->result_ok);
4595         LDKMonitorUpdateError err_var = (*val->contents.err);
4596         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4597         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4598         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4599         return err_ref;
4600 }
4601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4602         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4603         LDKOutPoint a_conv;
4604         a_conv.inner = (void*)(a & (~1));
4605         a_conv.is_owned = (a & 1) || (a == 0);
4606         a_conv = OutPoint_clone(&a_conv);
4607         ret->a = a_conv;
4608         LDKCVec_u8Z b_ref;
4609         b_ref.datalen = (*env)->GetArrayLength(env, b);
4610         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4611         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4612         ret->b = b_ref;
4613         return (uint64_t)ret;
4614 }
4615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4616         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4617         LDKOutPoint a_var = tuple->a;
4618         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4619         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4620         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4621         return a_ref;
4622 }
4623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4624         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4625         LDKCVec_u8Z b_var = tuple->b;
4626         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4627         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4628         return b_arr;
4629 }
4630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4631         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4632         ret->a = a;
4633         LDKCVec_u8Z b_ref;
4634         b_ref.datalen = (*env)->GetArrayLength(env, b);
4635         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4636         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4637         ret->b = b_ref;
4638         return (uint64_t)ret;
4639 }
4640 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4641         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4642         return tuple->a;
4643 }
4644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4645         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4646         LDKCVec_u8Z b_var = tuple->b;
4647         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4648         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4649         return b_arr;
4650 }
4651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4652         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4653         ret->datalen = (*env)->GetArrayLength(env, elems);
4654         if (ret->datalen == 0) {
4655                 ret->data = NULL;
4656         } else {
4657                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4658                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4659                 for (size_t i = 0; i < ret->datalen; i++) {
4660                         int64_t arr_elem = java_elems[i];
4661                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4662                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4663                         ret->data[i] = arr_elem_conv;
4664                 }
4665                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4666         }
4667         return (uint64_t)ret;
4668 }
4669 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4670         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4671         for (size_t i = 0; i < ret.datalen; i++) {
4672                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4673         }
4674         return ret;
4675 }
4676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4677         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4678         LDKThirtyTwoBytes a_ref;
4679         CHECK((*env)->GetArrayLength(env, a) == 32);
4680         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4681         ret->a = a_ref;
4682         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4683         b_constr.datalen = (*env)->GetArrayLength(env, b);
4684         if (b_constr.datalen > 0)
4685                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4686         else
4687                 b_constr.data = NULL;
4688         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4689         for (size_t b = 0; b < b_constr.datalen; b++) {
4690                 int64_t b_conv_27 = b_vals[b];
4691                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4692                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4693                 b_constr.data[b] = b_conv_27_conv;
4694         }
4695         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4696         ret->b = b_constr;
4697         return (uint64_t)ret;
4698 }
4699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4700         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4701         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4702         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4703         return a_arr;
4704 }
4705 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4706         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4707         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4708         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4709         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4710         for (size_t b = 0; b < b_var.datalen; b++) {
4711                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4712                 b_arr_ptr[b] = b_conv_27_ref;
4713         }
4714         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4715         return b_arr;
4716 }
4717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4718         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4719         ret->datalen = (*env)->GetArrayLength(env, elems);
4720         if (ret->datalen == 0) {
4721                 ret->data = NULL;
4722         } else {
4723                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4724                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4725                 for (size_t i = 0; i < ret->datalen; i++) {
4726                         int64_t arr_elem = java_elems[i];
4727                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4728                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4729                         ret->data[i] = arr_elem_conv;
4730                 }
4731                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4732         }
4733         return (uint64_t)ret;
4734 }
4735 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4736         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 };
4737         for (size_t i = 0; i < ret.datalen; i++) {
4738                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4739         }
4740         return ret;
4741 }
4742 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
4743 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
4744 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
4745 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
4746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
4747         LDKPaymentPurpose_InvoicePayment_class =
4748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
4749         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
4750         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
4751         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
4752         LDKPaymentPurpose_SpontaneousPayment_class =
4753                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
4754         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
4755         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
4756         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
4757 }
4758 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4759         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
4760         switch(obj->tag) {
4761                 case LDKPaymentPurpose_InvoicePayment: {
4762                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4763                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
4764                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4765                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
4766                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
4767                 }
4768                 case LDKPaymentPurpose_SpontaneousPayment: {
4769                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
4770                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
4771                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
4772                 }
4773                 default: abort();
4774         }
4775 }
4776 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4777 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4778 static jclass LDKEvent_PaymentReceived_class = NULL;
4779 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4780 static jclass LDKEvent_PaymentSent_class = NULL;
4781 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4782 static jclass LDKEvent_PaymentFailed_class = NULL;
4783 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4784 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4785 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4786 static jclass LDKEvent_SpendableOutputs_class = NULL;
4787 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4788 static jclass LDKEvent_PaymentForwarded_class = NULL;
4789 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
4790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4791         LDKEvent_FundingGenerationReady_class =
4792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4793         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4794         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4795         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4796         LDKEvent_PaymentReceived_class =
4797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4798         CHECK(LDKEvent_PaymentReceived_class != NULL);
4799         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
4800         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4801         LDKEvent_PaymentSent_class =
4802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4803         CHECK(LDKEvent_PaymentSent_class != NULL);
4804         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4805         CHECK(LDKEvent_PaymentSent_meth != NULL);
4806         LDKEvent_PaymentFailed_class =
4807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4808         CHECK(LDKEvent_PaymentFailed_class != NULL);
4809         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4810         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4811         LDKEvent_PendingHTLCsForwardable_class =
4812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4813         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4814         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4815         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4816         LDKEvent_SpendableOutputs_class =
4817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4818         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4819         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4820         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4821         LDKEvent_PaymentForwarded_class =
4822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
4823         CHECK(LDKEvent_PaymentForwarded_class != NULL);
4824         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
4825         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
4826 }
4827 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4828         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4829         switch(obj->tag) {
4830                 case LDKEvent_FundingGenerationReady: {
4831                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4832                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4833                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4834                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4835                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4836                         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);
4837                 }
4838                 case LDKEvent_PaymentReceived: {
4839                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4840                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4841                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
4842                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
4843                 }
4844                 case LDKEvent_PaymentSent: {
4845                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4846                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4847                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4848                 }
4849                 case LDKEvent_PaymentFailed: {
4850                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4851                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4852                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4853                 }
4854                 case LDKEvent_PendingHTLCsForwardable: {
4855                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4856                 }
4857                 case LDKEvent_SpendableOutputs: {
4858                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4859                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4860                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4861                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4862                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4863                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4864                         }
4865                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4866                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4867                 }
4868                 case LDKEvent_PaymentForwarded: {
4869                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
4870                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
4871                 }
4872                 default: abort();
4873         }
4874 }
4875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4876         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4877         ret->datalen = (*env)->GetArrayLength(env, elems);
4878         if (ret->datalen == 0) {
4879                 ret->data = NULL;
4880         } else {
4881                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4882                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4883                 for (size_t i = 0; i < ret->datalen; i++) {
4884                         int64_t arr_elem = java_elems[i];
4885                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4886                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4887                         ret->data[i] = arr_elem_conv;
4888                 }
4889                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4890         }
4891         return (uint64_t)ret;
4892 }
4893 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4894         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4895         for (size_t i = 0; i < ret.datalen; i++) {
4896                 ret.data[i] = Event_clone(&orig->data[i]);
4897         }
4898         return ret;
4899 }
4900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4901         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4902         ret->a = a;
4903         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4904         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4905         ret->b = b_conv;
4906         return (uint64_t)ret;
4907 }
4908 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4909         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4910         return tuple->a;
4911 }
4912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4913         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4914         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4915         return (uint64_t)b_ref;
4916 }
4917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4918         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4919         ret->datalen = (*env)->GetArrayLength(env, elems);
4920         if (ret->datalen == 0) {
4921                 ret->data = NULL;
4922         } else {
4923                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4924                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4925                 for (size_t i = 0; i < ret->datalen; i++) {
4926                         int64_t arr_elem = java_elems[i];
4927                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4928                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4929                         ret->data[i] = arr_elem_conv;
4930                 }
4931                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4932         }
4933         return (uint64_t)ret;
4934 }
4935 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4936         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4937         for (size_t i = 0; i < ret.datalen; i++) {
4938                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4939         }
4940         return ret;
4941 }
4942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4943         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4944         LDKThirtyTwoBytes a_ref;
4945         CHECK((*env)->GetArrayLength(env, a) == 32);
4946         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4947         ret->a = a_ref;
4948         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4949         b_constr.datalen = (*env)->GetArrayLength(env, b);
4950         if (b_constr.datalen > 0)
4951                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4952         else
4953                 b_constr.data = NULL;
4954         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4955         for (size_t a = 0; a < b_constr.datalen; a++) {
4956                 int64_t b_conv_26 = b_vals[a];
4957                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4958                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4959                 b_constr.data[a] = b_conv_26_conv;
4960         }
4961         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4962         ret->b = b_constr;
4963         return (uint64_t)ret;
4964 }
4965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4966         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4967         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4968         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4969         return a_arr;
4970 }
4971 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4972         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4973         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4974         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4975         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4976         for (size_t a = 0; a < b_var.datalen; a++) {
4977                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4978                 b_arr_ptr[a] = b_conv_26_ref;
4979         }
4980         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4981         return b_arr;
4982 }
4983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4984         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4985         ret->datalen = (*env)->GetArrayLength(env, elems);
4986         if (ret->datalen == 0) {
4987                 ret->data = NULL;
4988         } else {
4989                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4990                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4991                 for (size_t i = 0; i < ret->datalen; i++) {
4992                         int64_t arr_elem = java_elems[i];
4993                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4994                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4995                         ret->data[i] = arr_elem_conv;
4996                 }
4997                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4998         }
4999         return (uint64_t)ret;
5000 }
5001 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5002         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 };
5003         for (size_t i = 0; i < ret.datalen; i++) {
5004                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5005         }
5006         return ret;
5007 }
5008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5009         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
5010 }
5011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5012         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5013         CHECK(val->result_ok);
5014         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
5015         return res_ref;
5016 }
5017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5018         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5019         CHECK(!val->result_ok);
5020         LDKDecodeError err_var = (*val->contents.err);
5021         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5022         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5023         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5024         return err_ref;
5025 }
5026 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5027         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
5028 }
5029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5030         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5031         CHECK(val->result_ok);
5032         return *val->contents.result;
5033 }
5034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5035         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5036         CHECK(!val->result_ok);
5037         LDKLightningError err_var = (*val->contents.err);
5038         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5039         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5040         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5041         return err_ref;
5042 }
5043 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) {
5044         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5045         LDKChannelAnnouncement a_conv;
5046         a_conv.inner = (void*)(a & (~1));
5047         a_conv.is_owned = (a & 1) || (a == 0);
5048         a_conv = ChannelAnnouncement_clone(&a_conv);
5049         ret->a = a_conv;
5050         LDKChannelUpdate b_conv;
5051         b_conv.inner = (void*)(b & (~1));
5052         b_conv.is_owned = (b & 1) || (b == 0);
5053         b_conv = ChannelUpdate_clone(&b_conv);
5054         ret->b = b_conv;
5055         LDKChannelUpdate c_conv;
5056         c_conv.inner = (void*)(c & (~1));
5057         c_conv.is_owned = (c & 1) || (c == 0);
5058         c_conv = ChannelUpdate_clone(&c_conv);
5059         ret->c = c_conv;
5060         return (uint64_t)ret;
5061 }
5062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
5063         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5064         LDKChannelAnnouncement a_var = tuple->a;
5065         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5066         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5067         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
5068         return a_ref;
5069 }
5070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
5071         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5072         LDKChannelUpdate b_var = tuple->b;
5073         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5074         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5075         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
5076         return b_ref;
5077 }
5078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
5079         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
5080         LDKChannelUpdate c_var = tuple->c;
5081         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5082         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5083         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
5084         return c_ref;
5085 }
5086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5087         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
5088         ret->datalen = (*env)->GetArrayLength(env, elems);
5089         if (ret->datalen == 0) {
5090                 ret->data = NULL;
5091         } else {
5092                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
5093                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5094                 for (size_t i = 0; i < ret->datalen; i++) {
5095                         int64_t arr_elem = java_elems[i];
5096                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
5097                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
5098                         ret->data[i] = arr_elem_conv;
5099                 }
5100                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5101         }
5102         return (uint64_t)ret;
5103 }
5104 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5105         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5106         for (size_t i = 0; i < ret.datalen; i++) {
5107                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5108         }
5109         return ret;
5110 }
5111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5112         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
5113         ret->datalen = (*env)->GetArrayLength(env, elems);
5114         if (ret->datalen == 0) {
5115                 ret->data = NULL;
5116         } else {
5117                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
5118                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5119                 for (size_t i = 0; i < ret->datalen; i++) {
5120                         int64_t arr_elem = java_elems[i];
5121                         LDKNodeAnnouncement arr_elem_conv;
5122                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5123                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5124                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5125                         ret->data[i] = arr_elem_conv;
5126                 }
5127                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5128         }
5129         return (uint64_t)ret;
5130 }
5131 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5132         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5133         for (size_t i = 0; i < ret.datalen; i++) {
5134                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5135         }
5136         return ret;
5137 }
5138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5139         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5140 }
5141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5142         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5143         CHECK(val->result_ok);
5144         return *val->contents.result;
5145 }
5146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5147         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5148         CHECK(!val->result_ok);
5149         LDKLightningError err_var = (*val->contents.err);
5150         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5151         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5152         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5153         return err_ref;
5154 }
5155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5156         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5157 }
5158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5159         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5160         CHECK(val->result_ok);
5161         LDKCVec_u8Z res_var = (*val->contents.result);
5162         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5163         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5164         return res_arr;
5165 }
5166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5167         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5168         CHECK(!val->result_ok);
5169         LDKPeerHandleError err_var = (*val->contents.err);
5170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5172         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5173         return err_ref;
5174 }
5175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5176         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5177 }
5178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5179         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5180         CHECK(val->result_ok);
5181         return *val->contents.result;
5182 }
5183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5184         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5185         CHECK(!val->result_ok);
5186         LDKPeerHandleError err_var = (*val->contents.err);
5187         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5188         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5189         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5190         return err_ref;
5191 }
5192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5193         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5194 }
5195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5196         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5197         CHECK(val->result_ok);
5198         return *val->contents.result;
5199 }
5200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5201         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5202         CHECK(!val->result_ok);
5203         LDKPeerHandleError err_var = (*val->contents.err);
5204         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5205         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5206         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5207         return err_ref;
5208 }
5209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5210         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5211 }
5212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5213         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5214         CHECK(val->result_ok);
5215         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5216         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5217         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5218         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5219         return res_ref;
5220 }
5221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5222         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5223         CHECK(!val->result_ok);
5224         LDKDecodeError err_var = (*val->contents.err);
5225         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5228         return err_ref;
5229 }
5230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5231         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5232 }
5233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5234         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5235         CHECK(val->result_ok);
5236         LDKChannelInfo res_var = (*val->contents.result);
5237         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5238         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5239         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5240         return res_ref;
5241 }
5242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5243         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5244         CHECK(!val->result_ok);
5245         LDKDecodeError err_var = (*val->contents.err);
5246         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5247         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5248         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5249         return err_ref;
5250 }
5251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5252         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5253 }
5254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5255         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5256         CHECK(val->result_ok);
5257         LDKRoutingFees res_var = (*val->contents.result);
5258         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5259         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5260         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5261         return res_ref;
5262 }
5263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5264         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5265         CHECK(!val->result_ok);
5266         LDKDecodeError err_var = (*val->contents.err);
5267         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5268         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5269         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5270         return err_ref;
5271 }
5272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5273         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5274 }
5275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5276         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5277         CHECK(val->result_ok);
5278         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5279         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5280         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5281         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5282         return res_ref;
5283 }
5284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5285         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5286         CHECK(!val->result_ok);
5287         LDKDecodeError err_var = (*val->contents.err);
5288         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5289         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5290         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5291         return err_ref;
5292 }
5293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5294         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5295         ret->datalen = (*env)->GetArrayLength(env, elems);
5296         if (ret->datalen == 0) {
5297                 ret->data = NULL;
5298         } else {
5299                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5300                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5301                 for (size_t i = 0; i < ret->datalen; i++) {
5302                         ret->data[i] = java_elems[i];
5303                 }
5304                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5305         }
5306         return (uint64_t)ret;
5307 }
5308 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5309         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5310         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5311         return ret;
5312 }
5313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5314         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5315 }
5316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5317         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5318         CHECK(val->result_ok);
5319         LDKNodeInfo res_var = (*val->contents.result);
5320         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5321         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5322         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5323         return res_ref;
5324 }
5325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5326         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5327         CHECK(!val->result_ok);
5328         LDKDecodeError err_var = (*val->contents.err);
5329         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5330         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5331         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5332         return err_ref;
5333 }
5334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5335         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5336 }
5337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5338         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5339         CHECK(val->result_ok);
5340         LDKNetworkGraph res_var = (*val->contents.result);
5341         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5342         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5343         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5344         return res_ref;
5345 }
5346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5347         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5348         CHECK(!val->result_ok);
5349         LDKDecodeError err_var = (*val->contents.err);
5350         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5351         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5352         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5353         return err_ref;
5354 }
5355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5356         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5357 }
5358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5359         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5360         CHECK(val->result_ok);
5361         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5362         return res_ref;
5363 }
5364 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5365         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5366         CHECK(!val->result_ok);
5367         return *val->contents.err;
5368 }
5369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5370         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5371 }
5372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5373         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5374         CHECK(val->result_ok);
5375         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5376         *res_conv = (*val->contents.result);
5377         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5378         return (uint64_t)res_conv;
5379 }
5380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5381         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5382         CHECK(!val->result_ok);
5383         LDKDecodeError err_var = (*val->contents.err);
5384         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5385         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5386         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5387         return err_ref;
5388 }
5389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5390         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5391 }
5392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5393         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5394         CHECK(val->result_ok);
5395         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5396         return res_ref;
5397 }
5398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5399         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5400         CHECK(!val->result_ok);
5401         LDKDecodeError err_var = (*val->contents.err);
5402         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5403         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5404         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5405         return err_ref;
5406 }
5407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5408         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5409         ret->datalen = (*env)->GetArrayLength(env, elems);
5410         if (ret->datalen == 0) {
5411                 ret->data = NULL;
5412         } else {
5413                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5414                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5415                 for (size_t i = 0; i < ret->datalen; i++) {
5416                         int64_t arr_elem = java_elems[i];
5417                         LDKUpdateAddHTLC arr_elem_conv;
5418                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5419                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5420                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5421                         ret->data[i] = arr_elem_conv;
5422                 }
5423                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5424         }
5425         return (uint64_t)ret;
5426 }
5427 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5428         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5429         for (size_t i = 0; i < ret.datalen; i++) {
5430                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5431         }
5432         return ret;
5433 }
5434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5435         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5436         ret->datalen = (*env)->GetArrayLength(env, elems);
5437         if (ret->datalen == 0) {
5438                 ret->data = NULL;
5439         } else {
5440                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5441                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5442                 for (size_t i = 0; i < ret->datalen; i++) {
5443                         int64_t arr_elem = java_elems[i];
5444                         LDKUpdateFulfillHTLC arr_elem_conv;
5445                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5446                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5447                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5448                         ret->data[i] = arr_elem_conv;
5449                 }
5450                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5451         }
5452         return (uint64_t)ret;
5453 }
5454 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5455         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5456         for (size_t i = 0; i < ret.datalen; i++) {
5457                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5458         }
5459         return ret;
5460 }
5461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5462         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5463         ret->datalen = (*env)->GetArrayLength(env, elems);
5464         if (ret->datalen == 0) {
5465                 ret->data = NULL;
5466         } else {
5467                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5468                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5469                 for (size_t i = 0; i < ret->datalen; i++) {
5470                         int64_t arr_elem = java_elems[i];
5471                         LDKUpdateFailHTLC arr_elem_conv;
5472                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5473                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5474                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5475                         ret->data[i] = arr_elem_conv;
5476                 }
5477                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5478         }
5479         return (uint64_t)ret;
5480 }
5481 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5482         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5483         for (size_t i = 0; i < ret.datalen; i++) {
5484                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5485         }
5486         return ret;
5487 }
5488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5489         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5490         ret->datalen = (*env)->GetArrayLength(env, elems);
5491         if (ret->datalen == 0) {
5492                 ret->data = NULL;
5493         } else {
5494                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5495                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5496                 for (size_t i = 0; i < ret->datalen; i++) {
5497                         int64_t arr_elem = java_elems[i];
5498                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5499                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5500                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5501                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5502                         ret->data[i] = arr_elem_conv;
5503                 }
5504                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5505         }
5506         return (uint64_t)ret;
5507 }
5508 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5509         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5510         for (size_t i = 0; i < ret.datalen; i++) {
5511                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5512         }
5513         return ret;
5514 }
5515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5516         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5517 }
5518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5519         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5520         CHECK(val->result_ok);
5521         LDKAcceptChannel res_var = (*val->contents.result);
5522         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5523         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5524         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5525         return res_ref;
5526 }
5527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5528         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5529         CHECK(!val->result_ok);
5530         LDKDecodeError err_var = (*val->contents.err);
5531         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5532         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5533         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5534         return err_ref;
5535 }
5536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5537         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5538 }
5539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5540         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5541         CHECK(val->result_ok);
5542         LDKAnnouncementSignatures res_var = (*val->contents.result);
5543         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5544         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5545         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5546         return res_ref;
5547 }
5548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5549         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5550         CHECK(!val->result_ok);
5551         LDKDecodeError err_var = (*val->contents.err);
5552         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5553         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5554         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5555         return err_ref;
5556 }
5557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5558         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5559 }
5560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5561         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5562         CHECK(val->result_ok);
5563         LDKChannelReestablish res_var = (*val->contents.result);
5564         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5565         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5566         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5567         return res_ref;
5568 }
5569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5570         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5571         CHECK(!val->result_ok);
5572         LDKDecodeError err_var = (*val->contents.err);
5573         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5574         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5575         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5576         return err_ref;
5577 }
5578 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5579         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5580 }
5581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5582         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5583         CHECK(val->result_ok);
5584         LDKClosingSigned res_var = (*val->contents.result);
5585         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5586         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5587         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5588         return res_ref;
5589 }
5590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5591         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5592         CHECK(!val->result_ok);
5593         LDKDecodeError err_var = (*val->contents.err);
5594         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5595         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5596         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5597         return err_ref;
5598 }
5599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5600         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
5601 }
5602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5603         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
5604         CHECK(val->result_ok);
5605         LDKClosingSignedFeeRange res_var = (*val->contents.result);
5606         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5607         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5608         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5609         return res_ref;
5610 }
5611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5612         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
5613         CHECK(!val->result_ok);
5614         LDKDecodeError err_var = (*val->contents.err);
5615         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5616         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5617         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5618         return err_ref;
5619 }
5620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5621         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5622 }
5623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5624         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5625         CHECK(val->result_ok);
5626         LDKCommitmentSigned res_var = (*val->contents.result);
5627         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5628         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5629         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5630         return res_ref;
5631 }
5632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5633         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5634         CHECK(!val->result_ok);
5635         LDKDecodeError err_var = (*val->contents.err);
5636         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5637         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5638         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5639         return err_ref;
5640 }
5641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5642         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5643 }
5644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5645         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5646         CHECK(val->result_ok);
5647         LDKFundingCreated res_var = (*val->contents.result);
5648         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5649         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5650         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5651         return res_ref;
5652 }
5653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5654         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5655         CHECK(!val->result_ok);
5656         LDKDecodeError err_var = (*val->contents.err);
5657         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5658         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5659         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5660         return err_ref;
5661 }
5662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5663         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5664 }
5665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5666         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5667         CHECK(val->result_ok);
5668         LDKFundingSigned res_var = (*val->contents.result);
5669         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5670         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5671         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5672         return res_ref;
5673 }
5674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5675         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5676         CHECK(!val->result_ok);
5677         LDKDecodeError err_var = (*val->contents.err);
5678         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5679         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5680         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5681         return err_ref;
5682 }
5683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5684         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5685 }
5686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5687         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5688         CHECK(val->result_ok);
5689         LDKFundingLocked res_var = (*val->contents.result);
5690         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5691         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5692         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5693         return res_ref;
5694 }
5695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5696         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5697         CHECK(!val->result_ok);
5698         LDKDecodeError err_var = (*val->contents.err);
5699         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5700         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5701         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5702         return err_ref;
5703 }
5704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5705         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5706 }
5707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5708         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5709         CHECK(val->result_ok);
5710         LDKInit res_var = (*val->contents.result);
5711         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5712         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5713         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5714         return res_ref;
5715 }
5716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5717         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5718         CHECK(!val->result_ok);
5719         LDKDecodeError err_var = (*val->contents.err);
5720         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5721         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5722         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5723         return err_ref;
5724 }
5725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5726         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5727 }
5728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5729         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5730         CHECK(val->result_ok);
5731         LDKOpenChannel res_var = (*val->contents.result);
5732         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5733         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5734         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5735         return res_ref;
5736 }
5737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5738         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5739         CHECK(!val->result_ok);
5740         LDKDecodeError err_var = (*val->contents.err);
5741         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5742         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5743         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5744         return err_ref;
5745 }
5746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5747         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5748 }
5749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5750         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5751         CHECK(val->result_ok);
5752         LDKRevokeAndACK res_var = (*val->contents.result);
5753         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5754         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5755         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5756         return res_ref;
5757 }
5758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5759         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5760         CHECK(!val->result_ok);
5761         LDKDecodeError err_var = (*val->contents.err);
5762         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5763         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5764         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5765         return err_ref;
5766 }
5767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5768         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5769 }
5770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5771         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5772         CHECK(val->result_ok);
5773         LDKShutdown res_var = (*val->contents.result);
5774         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5775         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5776         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5777         return res_ref;
5778 }
5779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5780         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5781         CHECK(!val->result_ok);
5782         LDKDecodeError err_var = (*val->contents.err);
5783         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5784         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5785         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5786         return err_ref;
5787 }
5788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5789         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5790 }
5791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5792         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5793         CHECK(val->result_ok);
5794         LDKUpdateFailHTLC res_var = (*val->contents.result);
5795         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5796         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5797         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5798         return res_ref;
5799 }
5800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5801         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5802         CHECK(!val->result_ok);
5803         LDKDecodeError err_var = (*val->contents.err);
5804         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5805         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5806         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5807         return err_ref;
5808 }
5809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5810         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5811 }
5812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5813         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5814         CHECK(val->result_ok);
5815         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5816         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5817         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5818         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5819         return res_ref;
5820 }
5821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5822         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5823         CHECK(!val->result_ok);
5824         LDKDecodeError err_var = (*val->contents.err);
5825         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5826         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5827         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5828         return err_ref;
5829 }
5830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5831         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5832 }
5833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5834         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5835         CHECK(val->result_ok);
5836         LDKUpdateFee res_var = (*val->contents.result);
5837         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5838         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5839         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5840         return res_ref;
5841 }
5842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5843         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5844         CHECK(!val->result_ok);
5845         LDKDecodeError err_var = (*val->contents.err);
5846         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5847         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5848         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5849         return err_ref;
5850 }
5851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5852         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5853 }
5854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5855         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5856         CHECK(val->result_ok);
5857         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5858         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5859         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5860         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5861         return res_ref;
5862 }
5863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5864         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5865         CHECK(!val->result_ok);
5866         LDKDecodeError err_var = (*val->contents.err);
5867         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5868         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5869         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5870         return err_ref;
5871 }
5872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5873         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5874 }
5875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5876         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5877         CHECK(val->result_ok);
5878         LDKUpdateAddHTLC res_var = (*val->contents.result);
5879         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5880         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5881         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5882         return res_ref;
5883 }
5884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5885         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5886         CHECK(!val->result_ok);
5887         LDKDecodeError err_var = (*val->contents.err);
5888         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5889         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5890         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5891         return err_ref;
5892 }
5893 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5894         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5895 }
5896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5897         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5898         CHECK(val->result_ok);
5899         LDKPing res_var = (*val->contents.result);
5900         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5901         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5902         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5903         return res_ref;
5904 }
5905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5906         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5907         CHECK(!val->result_ok);
5908         LDKDecodeError err_var = (*val->contents.err);
5909         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5910         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5911         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5912         return err_ref;
5913 }
5914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5915         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5916 }
5917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5918         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5919         CHECK(val->result_ok);
5920         LDKPong res_var = (*val->contents.result);
5921         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5922         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5923         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5924         return res_ref;
5925 }
5926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5927         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5928         CHECK(!val->result_ok);
5929         LDKDecodeError err_var = (*val->contents.err);
5930         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5931         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5932         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5933         return err_ref;
5934 }
5935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5936         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5937 }
5938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5939         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5940         CHECK(val->result_ok);
5941         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5942         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5943         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5944         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5945         return res_ref;
5946 }
5947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5948         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5949         CHECK(!val->result_ok);
5950         LDKDecodeError err_var = (*val->contents.err);
5951         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5952         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5953         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5954         return err_ref;
5955 }
5956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5957         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5958 }
5959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5960         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5961         CHECK(val->result_ok);
5962         LDKChannelAnnouncement res_var = (*val->contents.result);
5963         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5964         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5965         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5966         return res_ref;
5967 }
5968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5969         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5970         CHECK(!val->result_ok);
5971         LDKDecodeError err_var = (*val->contents.err);
5972         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5973         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5974         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5975         return err_ref;
5976 }
5977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5978         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5979 }
5980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5981         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5982         CHECK(val->result_ok);
5983         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5984         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5985         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5986         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5987         return res_ref;
5988 }
5989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5990         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5991         CHECK(!val->result_ok);
5992         LDKDecodeError err_var = (*val->contents.err);
5993         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5994         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5995         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5996         return err_ref;
5997 }
5998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5999         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
6000 }
6001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6002         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6003         CHECK(val->result_ok);
6004         LDKChannelUpdate res_var = (*val->contents.result);
6005         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6006         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6007         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6008         return res_ref;
6009 }
6010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6011         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6012         CHECK(!val->result_ok);
6013         LDKDecodeError err_var = (*val->contents.err);
6014         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6015         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6016         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6017         return err_ref;
6018 }
6019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6020         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
6021 }
6022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6023         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6024         CHECK(val->result_ok);
6025         LDKErrorMessage res_var = (*val->contents.result);
6026         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6027         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6028         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6029         return res_ref;
6030 }
6031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6032         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6033         CHECK(!val->result_ok);
6034         LDKDecodeError err_var = (*val->contents.err);
6035         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6036         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6037         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6038         return err_ref;
6039 }
6040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6041         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6042 }
6043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6044         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6045         CHECK(val->result_ok);
6046         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6047         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6048         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6049         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6050         return res_ref;
6051 }
6052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6053         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6054         CHECK(!val->result_ok);
6055         LDKDecodeError err_var = (*val->contents.err);
6056         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6057         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6058         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6059         return err_ref;
6060 }
6061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6062         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
6063 }
6064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6065         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6066         CHECK(val->result_ok);
6067         LDKNodeAnnouncement res_var = (*val->contents.result);
6068         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6069         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6070         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6071         return res_ref;
6072 }
6073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6074         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6075         CHECK(!val->result_ok);
6076         LDKDecodeError err_var = (*val->contents.err);
6077         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6078         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6079         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6080         return err_ref;
6081 }
6082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6083         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
6084 }
6085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6086         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6087         CHECK(val->result_ok);
6088         LDKQueryShortChannelIds res_var = (*val->contents.result);
6089         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6090         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6091         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6092         return res_ref;
6093 }
6094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6095         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6096         CHECK(!val->result_ok);
6097         LDKDecodeError err_var = (*val->contents.err);
6098         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6099         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6100         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6101         return err_ref;
6102 }
6103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6104         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
6105 }
6106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6107         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6108         CHECK(val->result_ok);
6109         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6110         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6111         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6112         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6113         return res_ref;
6114 }
6115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6116         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6117         CHECK(!val->result_ok);
6118         LDKDecodeError err_var = (*val->contents.err);
6119         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6120         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6121         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6122         return err_ref;
6123 }
6124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6125         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
6126 }
6127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6128         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6129         CHECK(val->result_ok);
6130         LDKQueryChannelRange res_var = (*val->contents.result);
6131         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6132         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6133         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6134         return res_ref;
6135 }
6136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6137         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6138         CHECK(!val->result_ok);
6139         LDKDecodeError err_var = (*val->contents.err);
6140         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6141         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6142         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6143         return err_ref;
6144 }
6145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6146         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
6147 }
6148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6149         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6150         CHECK(val->result_ok);
6151         LDKReplyChannelRange res_var = (*val->contents.result);
6152         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6153         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6154         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6155         return res_ref;
6156 }
6157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6158         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6159         CHECK(!val->result_ok);
6160         LDKDecodeError err_var = (*val->contents.err);
6161         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6162         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6163         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6164         return err_ref;
6165 }
6166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6167         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6168 }
6169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6170         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6171         CHECK(val->result_ok);
6172         LDKGossipTimestampFilter res_var = (*val->contents.result);
6173         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6174         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6175         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6176         return res_ref;
6177 }
6178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6179         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6180         CHECK(!val->result_ok);
6181         LDKDecodeError err_var = (*val->contents.err);
6182         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6183         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6184         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6185         return err_ref;
6186 }
6187 static jclass LDKSignOrCreationError_SignError_class = NULL;
6188 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6189 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6190 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6192         LDKSignOrCreationError_SignError_class =
6193                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6194         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6195         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6196         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6197         LDKSignOrCreationError_CreationError_class =
6198                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6199         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6200         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6201         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6202 }
6203 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6204         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6205         switch(obj->tag) {
6206                 case LDKSignOrCreationError_SignError: {
6207                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6208                 }
6209                 case LDKSignOrCreationError_CreationError: {
6210                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6211                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6212                 }
6213                 default: abort();
6214         }
6215 }
6216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6217         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6218 }
6219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6220         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6221         CHECK(val->result_ok);
6222         LDKInvoice res_var = (*val->contents.result);
6223         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6224         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6225         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6226         return res_ref;
6227 }
6228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6229         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6230         CHECK(!val->result_ok);
6231         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6232         return err_ref;
6233 }
6234 typedef struct LDKMessageSendEventsProvider_JCalls {
6235         atomic_size_t refcnt;
6236         JavaVM *vm;
6237         jweak o;
6238         jmethodID get_and_clear_pending_msg_events_meth;
6239 } LDKMessageSendEventsProvider_JCalls;
6240 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6241         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6242         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6243                 JNIEnv *env;
6244                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6245                 if (get_jenv_res == JNI_EDETACHED) {
6246                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6247                 } else {
6248                         DO_ASSERT(get_jenv_res == JNI_OK);
6249                 }
6250                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6251                 if (get_jenv_res == JNI_EDETACHED) {
6252                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6253                 }
6254                 FREE(j_calls);
6255         }
6256 }
6257 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6258         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6259         JNIEnv *env;
6260         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6261         if (get_jenv_res == JNI_EDETACHED) {
6262                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6263         } else {
6264                 DO_ASSERT(get_jenv_res == JNI_OK);
6265         }
6266         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6267         CHECK(obj != NULL);
6268         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6269         if ((*env)->ExceptionCheck(env)) {
6270                 (*env)->ExceptionDescribe(env);
6271                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6272         }
6273         LDKCVec_MessageSendEventZ ret_constr;
6274         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6275         if (ret_constr.datalen > 0)
6276                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6277         else
6278                 ret_constr.data = NULL;
6279         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6280         for (size_t s = 0; s < ret_constr.datalen; s++) {
6281                 int64_t ret_conv_18 = ret_vals[s];
6282                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6283                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6284                 ret_constr.data[s] = ret_conv_18_conv;
6285         }
6286         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6287         if (get_jenv_res == JNI_EDETACHED) {
6288                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6289         }
6290         return ret_constr;
6291 }
6292 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6293         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6294         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6295 }
6296 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6297         jclass c = (*env)->GetObjectClass(env, o);
6298         CHECK(c != NULL);
6299         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6300         atomic_init(&calls->refcnt, 1);
6301         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6302         calls->o = (*env)->NewWeakGlobalRef(env, o);
6303         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6304         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6305
6306         LDKMessageSendEventsProvider ret = {
6307                 .this_arg = (void*) calls,
6308                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6309                 .free = LDKMessageSendEventsProvider_JCalls_free,
6310         };
6311         return ret;
6312 }
6313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6314         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6315         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6316         return (uint64_t)res_ptr;
6317 }
6318 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6319         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6320         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6321         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6322         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6323         for (size_t s = 0; s < ret_var.datalen; s++) {
6324                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6325                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6326                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6327                 ret_arr_ptr[s] = ret_conv_18_ref;
6328         }
6329         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6330         FREE(ret_var.data);
6331         return ret_arr;
6332 }
6333
6334 typedef struct LDKEventHandler_JCalls {
6335         atomic_size_t refcnt;
6336         JavaVM *vm;
6337         jweak o;
6338         jmethodID handle_event_meth;
6339 } LDKEventHandler_JCalls;
6340 static void LDKEventHandler_JCalls_free(void* this_arg) {
6341         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6342         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6343                 JNIEnv *env;
6344                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6345                 if (get_jenv_res == JNI_EDETACHED) {
6346                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6347                 } else {
6348                         DO_ASSERT(get_jenv_res == JNI_OK);
6349                 }
6350                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6351                 if (get_jenv_res == JNI_EDETACHED) {
6352                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6353                 }
6354                 FREE(j_calls);
6355         }
6356 }
6357 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6358         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6359         JNIEnv *env;
6360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6361         if (get_jenv_res == JNI_EDETACHED) {
6362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6363         } else {
6364                 DO_ASSERT(get_jenv_res == JNI_OK);
6365         }
6366         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6367         *event_copy = event;
6368         uint64_t event_ref = (uint64_t)event_copy;
6369         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6370         CHECK(obj != NULL);
6371         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6372         if ((*env)->ExceptionCheck(env)) {
6373                 (*env)->ExceptionDescribe(env);
6374                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6375         }
6376         if (get_jenv_res == JNI_EDETACHED) {
6377                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6378         }
6379 }
6380 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6381         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6382         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6383 }
6384 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6385         jclass c = (*env)->GetObjectClass(env, o);
6386         CHECK(c != NULL);
6387         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6388         atomic_init(&calls->refcnt, 1);
6389         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6390         calls->o = (*env)->NewWeakGlobalRef(env, o);
6391         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6392         CHECK(calls->handle_event_meth != NULL);
6393
6394         LDKEventHandler ret = {
6395                 .this_arg = (void*) calls,
6396                 .handle_event = handle_event_LDKEventHandler_jcall,
6397                 .free = LDKEventHandler_JCalls_free,
6398         };
6399         return ret;
6400 }
6401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6402         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6403         *res_ptr = LDKEventHandler_init(env, clz, o);
6404         return (uint64_t)res_ptr;
6405 }
6406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6407         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6408         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6409         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6410 }
6411
6412 typedef struct LDKEventsProvider_JCalls {
6413         atomic_size_t refcnt;
6414         JavaVM *vm;
6415         jweak o;
6416         jmethodID process_pending_events_meth;
6417 } LDKEventsProvider_JCalls;
6418 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6419         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6420         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6421                 JNIEnv *env;
6422                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6423                 if (get_jenv_res == JNI_EDETACHED) {
6424                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6425                 } else {
6426                         DO_ASSERT(get_jenv_res == JNI_OK);
6427                 }
6428                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6429                 if (get_jenv_res == JNI_EDETACHED) {
6430                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6431                 }
6432                 FREE(j_calls);
6433         }
6434 }
6435 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6436         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6437         JNIEnv *env;
6438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6439         if (get_jenv_res == JNI_EDETACHED) {
6440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6441         } else {
6442                 DO_ASSERT(get_jenv_res == JNI_OK);
6443         }
6444         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6445         *ret = handler;
6446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6447         CHECK(obj != NULL);
6448         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6449         if ((*env)->ExceptionCheck(env)) {
6450                 (*env)->ExceptionDescribe(env);
6451                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6452         }
6453         if (get_jenv_res == JNI_EDETACHED) {
6454                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6455         }
6456 }
6457 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6458         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6459         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6460 }
6461 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6462         jclass c = (*env)->GetObjectClass(env, o);
6463         CHECK(c != NULL);
6464         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6465         atomic_init(&calls->refcnt, 1);
6466         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6467         calls->o = (*env)->NewWeakGlobalRef(env, o);
6468         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6469         CHECK(calls->process_pending_events_meth != NULL);
6470
6471         LDKEventsProvider ret = {
6472                 .this_arg = (void*) calls,
6473                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6474                 .free = LDKEventsProvider_JCalls_free,
6475         };
6476         return ret;
6477 }
6478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6479         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6480         *res_ptr = LDKEventsProvider_init(env, clz, o);
6481         return (uint64_t)res_ptr;
6482 }
6483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6484         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6485         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6486         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6487                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6488                 LDKEventHandler_JCalls_cloned(&handler_conv);
6489         }
6490         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6491 }
6492
6493 typedef struct LDKAccess_JCalls {
6494         atomic_size_t refcnt;
6495         JavaVM *vm;
6496         jweak o;
6497         jmethodID get_utxo_meth;
6498 } LDKAccess_JCalls;
6499 static void LDKAccess_JCalls_free(void* this_arg) {
6500         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6501         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6502                 JNIEnv *env;
6503                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6504                 if (get_jenv_res == JNI_EDETACHED) {
6505                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6506                 } else {
6507                         DO_ASSERT(get_jenv_res == JNI_OK);
6508                 }
6509                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6510                 if (get_jenv_res == JNI_EDETACHED) {
6511                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6512                 }
6513                 FREE(j_calls);
6514         }
6515 }
6516 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6517         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6518         JNIEnv *env;
6519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6520         if (get_jenv_res == JNI_EDETACHED) {
6521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6522         } else {
6523                 DO_ASSERT(get_jenv_res == JNI_OK);
6524         }
6525         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6526         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6527         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6528         CHECK(obj != NULL);
6529         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6530         if ((*env)->ExceptionCheck(env)) {
6531                 (*env)->ExceptionDescribe(env);
6532                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6533         }
6534         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6535         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6536         if (get_jenv_res == JNI_EDETACHED) {
6537                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6538         }
6539         return ret_conv;
6540 }
6541 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6542         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6543         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6544 }
6545 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6546         jclass c = (*env)->GetObjectClass(env, o);
6547         CHECK(c != NULL);
6548         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6549         atomic_init(&calls->refcnt, 1);
6550         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6551         calls->o = (*env)->NewWeakGlobalRef(env, o);
6552         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6553         CHECK(calls->get_utxo_meth != NULL);
6554
6555         LDKAccess ret = {
6556                 .this_arg = (void*) calls,
6557                 .get_utxo = get_utxo_LDKAccess_jcall,
6558                 .free = LDKAccess_JCalls_free,
6559         };
6560         return ret;
6561 }
6562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6563         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6564         *res_ptr = LDKAccess_init(env, clz, o);
6565         return (uint64_t)res_ptr;
6566 }
6567 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) {
6568         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6569         unsigned char genesis_hash_arr[32];
6570         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6571         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6572         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6573         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6574         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6575         return (uint64_t)ret_conv;
6576 }
6577
6578 typedef struct LDKListen_JCalls {
6579         atomic_size_t refcnt;
6580         JavaVM *vm;
6581         jweak o;
6582         jmethodID block_connected_meth;
6583         jmethodID block_disconnected_meth;
6584 } LDKListen_JCalls;
6585 static void LDKListen_JCalls_free(void* this_arg) {
6586         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6587         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6588                 JNIEnv *env;
6589                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6590                 if (get_jenv_res == JNI_EDETACHED) {
6591                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6592                 } else {
6593                         DO_ASSERT(get_jenv_res == JNI_OK);
6594                 }
6595                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6596                 if (get_jenv_res == JNI_EDETACHED) {
6597                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6598                 }
6599                 FREE(j_calls);
6600         }
6601 }
6602 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6603         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6604         JNIEnv *env;
6605         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6606         if (get_jenv_res == JNI_EDETACHED) {
6607                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6608         } else {
6609                 DO_ASSERT(get_jenv_res == JNI_OK);
6610         }
6611         LDKu8slice block_var = block;
6612         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6613         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6614         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6615         CHECK(obj != NULL);
6616         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6617         if ((*env)->ExceptionCheck(env)) {
6618                 (*env)->ExceptionDescribe(env);
6619                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6620         }
6621         if (get_jenv_res == JNI_EDETACHED) {
6622                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6623         }
6624 }
6625 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6626         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6627         JNIEnv *env;
6628         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6629         if (get_jenv_res == JNI_EDETACHED) {
6630                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6631         } else {
6632                 DO_ASSERT(get_jenv_res == JNI_OK);
6633         }
6634         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6635         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6636         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6637         CHECK(obj != NULL);
6638         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6639         if ((*env)->ExceptionCheck(env)) {
6640                 (*env)->ExceptionDescribe(env);
6641                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6642         }
6643         if (get_jenv_res == JNI_EDETACHED) {
6644                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6645         }
6646 }
6647 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6648         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6649         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6650 }
6651 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6652         jclass c = (*env)->GetObjectClass(env, o);
6653         CHECK(c != NULL);
6654         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6655         atomic_init(&calls->refcnt, 1);
6656         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6657         calls->o = (*env)->NewWeakGlobalRef(env, o);
6658         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6659         CHECK(calls->block_connected_meth != NULL);
6660         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6661         CHECK(calls->block_disconnected_meth != NULL);
6662
6663         LDKListen ret = {
6664                 .this_arg = (void*) calls,
6665                 .block_connected = block_connected_LDKListen_jcall,
6666                 .block_disconnected = block_disconnected_LDKListen_jcall,
6667                 .free = LDKListen_JCalls_free,
6668         };
6669         return ret;
6670 }
6671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6672         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6673         *res_ptr = LDKListen_init(env, clz, o);
6674         return (uint64_t)res_ptr;
6675 }
6676 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) {
6677         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6678         LDKu8slice block_ref;
6679         block_ref.datalen = (*env)->GetArrayLength(env, block);
6680         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6681         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6682         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6683 }
6684
6685 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) {
6686         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6687         unsigned char header_arr[80];
6688         CHECK((*env)->GetArrayLength(env, header) == 80);
6689         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6690         unsigned char (*header_ref)[80] = &header_arr;
6691         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6692 }
6693
6694 typedef struct LDKConfirm_JCalls {
6695         atomic_size_t refcnt;
6696         JavaVM *vm;
6697         jweak o;
6698         jmethodID transactions_confirmed_meth;
6699         jmethodID transaction_unconfirmed_meth;
6700         jmethodID best_block_updated_meth;
6701         jmethodID get_relevant_txids_meth;
6702 } LDKConfirm_JCalls;
6703 static void LDKConfirm_JCalls_free(void* this_arg) {
6704         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6705         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6706                 JNIEnv *env;
6707                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6708                 if (get_jenv_res == JNI_EDETACHED) {
6709                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6710                 } else {
6711                         DO_ASSERT(get_jenv_res == JNI_OK);
6712                 }
6713                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6714                 if (get_jenv_res == JNI_EDETACHED) {
6715                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6716                 }
6717                 FREE(j_calls);
6718         }
6719 }
6720 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6721         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6722         JNIEnv *env;
6723         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6724         if (get_jenv_res == JNI_EDETACHED) {
6725                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6726         } else {
6727                 DO_ASSERT(get_jenv_res == JNI_OK);
6728         }
6729         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6730         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6731         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6732         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6733         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6734         for (size_t y = 0; y < txdata_var.datalen; y++) {
6735                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6736                 *txdata_conv_24_ref = txdata_var.data[y];
6737                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6738         }
6739         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6740         FREE(txdata_var.data);
6741         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6742         CHECK(obj != NULL);
6743         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6744         if ((*env)->ExceptionCheck(env)) {
6745                 (*env)->ExceptionDescribe(env);
6746                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6747         }
6748         if (get_jenv_res == JNI_EDETACHED) {
6749                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6750         }
6751 }
6752 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6753         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6754         JNIEnv *env;
6755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6756         if (get_jenv_res == JNI_EDETACHED) {
6757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6758         } else {
6759                 DO_ASSERT(get_jenv_res == JNI_OK);
6760         }
6761         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6762         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6763         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6764         CHECK(obj != NULL);
6765         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6766         if ((*env)->ExceptionCheck(env)) {
6767                 (*env)->ExceptionDescribe(env);
6768                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6769         }
6770         if (get_jenv_res == JNI_EDETACHED) {
6771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6772         }
6773 }
6774 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6775         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6776         JNIEnv *env;
6777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6778         if (get_jenv_res == JNI_EDETACHED) {
6779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6780         } else {
6781                 DO_ASSERT(get_jenv_res == JNI_OK);
6782         }
6783         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6784         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6786         CHECK(obj != NULL);
6787         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6788         if ((*env)->ExceptionCheck(env)) {
6789                 (*env)->ExceptionDescribe(env);
6790                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6791         }
6792         if (get_jenv_res == JNI_EDETACHED) {
6793                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6794         }
6795 }
6796 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6797         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6798         JNIEnv *env;
6799         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6800         if (get_jenv_res == JNI_EDETACHED) {
6801                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6802         } else {
6803                 DO_ASSERT(get_jenv_res == JNI_OK);
6804         }
6805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6806         CHECK(obj != NULL);
6807         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6808         if ((*env)->ExceptionCheck(env)) {
6809                 (*env)->ExceptionDescribe(env);
6810                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6811         }
6812         LDKCVec_TxidZ ret_constr;
6813         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6814         if (ret_constr.datalen > 0)
6815                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6816         else
6817                 ret_constr.data = NULL;
6818         for (size_t i = 0; i < ret_constr.datalen; i++) {
6819                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6820                 LDKThirtyTwoBytes ret_conv_8_ref;
6821                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6822                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6823                 ret_constr.data[i] = ret_conv_8_ref;
6824         }
6825         if (get_jenv_res == JNI_EDETACHED) {
6826                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6827         }
6828         return ret_constr;
6829 }
6830 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6831         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6832         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6833 }
6834 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6835         jclass c = (*env)->GetObjectClass(env, o);
6836         CHECK(c != NULL);
6837         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6838         atomic_init(&calls->refcnt, 1);
6839         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6840         calls->o = (*env)->NewWeakGlobalRef(env, o);
6841         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6842         CHECK(calls->transactions_confirmed_meth != NULL);
6843         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6844         CHECK(calls->transaction_unconfirmed_meth != NULL);
6845         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6846         CHECK(calls->best_block_updated_meth != NULL);
6847         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6848         CHECK(calls->get_relevant_txids_meth != NULL);
6849
6850         LDKConfirm ret = {
6851                 .this_arg = (void*) calls,
6852                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6853                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6854                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6855                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6856                 .free = LDKConfirm_JCalls_free,
6857         };
6858         return ret;
6859 }
6860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6861         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6862         *res_ptr = LDKConfirm_init(env, clz, o);
6863         return (uint64_t)res_ptr;
6864 }
6865 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) {
6866         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6867         unsigned char header_arr[80];
6868         CHECK((*env)->GetArrayLength(env, header) == 80);
6869         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6870         unsigned char (*header_ref)[80] = &header_arr;
6871         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6872         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6873         if (txdata_constr.datalen > 0)
6874                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6875         else
6876                 txdata_constr.data = NULL;
6877         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6878         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6879                 int64_t txdata_conv_24 = txdata_vals[y];
6880                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6881                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6882                 txdata_constr.data[y] = txdata_conv_24_conv;
6883         }
6884         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6885         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6886 }
6887
6888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6889         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6890         unsigned char txid_arr[32];
6891         CHECK((*env)->GetArrayLength(env, txid) == 32);
6892         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6893         unsigned char (*txid_ref)[32] = &txid_arr;
6894         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6895 }
6896
6897 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) {
6898         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6899         unsigned char header_arr[80];
6900         CHECK((*env)->GetArrayLength(env, header) == 80);
6901         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6902         unsigned char (*header_ref)[80] = &header_arr;
6903         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6904 }
6905
6906 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6907         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6908         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6909         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6910         ;
6911         for (size_t i = 0; i < ret_var.datalen; i++) {
6912                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6913                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6914                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6915         }
6916         FREE(ret_var.data);
6917         return ret_arr;
6918 }
6919
6920 typedef struct LDKFilter_JCalls {
6921         atomic_size_t refcnt;
6922         JavaVM *vm;
6923         jweak o;
6924         jmethodID register_tx_meth;
6925         jmethodID register_output_meth;
6926 } LDKFilter_JCalls;
6927 static void LDKFilter_JCalls_free(void* this_arg) {
6928         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6929         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6930                 JNIEnv *env;
6931                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6932                 if (get_jenv_res == JNI_EDETACHED) {
6933                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6934                 } else {
6935                         DO_ASSERT(get_jenv_res == JNI_OK);
6936                 }
6937                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6938                 if (get_jenv_res == JNI_EDETACHED) {
6939                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6940                 }
6941                 FREE(j_calls);
6942         }
6943 }
6944 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6945         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6946         JNIEnv *env;
6947         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6948         if (get_jenv_res == JNI_EDETACHED) {
6949                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6950         } else {
6951                 DO_ASSERT(get_jenv_res == JNI_OK);
6952         }
6953         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6954         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6955         LDKu8slice script_pubkey_var = script_pubkey;
6956         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6957         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6958         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6959         CHECK(obj != NULL);
6960         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6961         if ((*env)->ExceptionCheck(env)) {
6962                 (*env)->ExceptionDescribe(env);
6963                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6964         }
6965         if (get_jenv_res == JNI_EDETACHED) {
6966                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6967         }
6968 }
6969 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6970         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6971         JNIEnv *env;
6972         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6973         if (get_jenv_res == JNI_EDETACHED) {
6974                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6975         } else {
6976                 DO_ASSERT(get_jenv_res == JNI_OK);
6977         }
6978         LDKWatchedOutput output_var = output;
6979         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6980         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6981         uint64_t output_ref = (uint64_t)output_var.inner;
6982         if (output_var.is_owned) {
6983                 output_ref |= 1;
6984         }
6985         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6986         CHECK(obj != NULL);
6987         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6988         if ((*env)->ExceptionCheck(env)) {
6989                 (*env)->ExceptionDescribe(env);
6990                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
6991         }
6992         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6993         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6994         if (get_jenv_res == JNI_EDETACHED) {
6995                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6996         }
6997         return ret_conv;
6998 }
6999 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7000         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7001         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7002 }
7003 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7004         jclass c = (*env)->GetObjectClass(env, o);
7005         CHECK(c != NULL);
7006         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7007         atomic_init(&calls->refcnt, 1);
7008         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7009         calls->o = (*env)->NewWeakGlobalRef(env, o);
7010         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7011         CHECK(calls->register_tx_meth != NULL);
7012         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7013         CHECK(calls->register_output_meth != NULL);
7014
7015         LDKFilter ret = {
7016                 .this_arg = (void*) calls,
7017                 .register_tx = register_tx_LDKFilter_jcall,
7018                 .register_output = register_output_LDKFilter_jcall,
7019                 .free = LDKFilter_JCalls_free,
7020         };
7021         return ret;
7022 }
7023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7024         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7025         *res_ptr = LDKFilter_init(env, clz, o);
7026         return (uint64_t)res_ptr;
7027 }
7028 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) {
7029         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7030         unsigned char txid_arr[32];
7031         CHECK((*env)->GetArrayLength(env, txid) == 32);
7032         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7033         unsigned char (*txid_ref)[32] = &txid_arr;
7034         LDKu8slice script_pubkey_ref;
7035         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7036         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7037         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7038         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7039 }
7040
7041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7042         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
7043         LDKWatchedOutput output_conv;
7044         output_conv.inner = (void*)(output & (~1));
7045         output_conv.is_owned = (output & 1) || (output == 0);
7046         output_conv = WatchedOutput_clone(&output_conv);
7047         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7048         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7049         uint64_t ret_ref = (uint64_t)ret_copy;
7050         return ret_ref;
7051 }
7052
7053 typedef struct LDKPersist_JCalls {
7054         atomic_size_t refcnt;
7055         JavaVM *vm;
7056         jweak o;
7057         jmethodID persist_new_channel_meth;
7058         jmethodID update_persisted_channel_meth;
7059 } LDKPersist_JCalls;
7060 static void LDKPersist_JCalls_free(void* this_arg) {
7061         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7062         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7063                 JNIEnv *env;
7064                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7065                 if (get_jenv_res == JNI_EDETACHED) {
7066                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7067                 } else {
7068                         DO_ASSERT(get_jenv_res == JNI_OK);
7069                 }
7070                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7071                 if (get_jenv_res == JNI_EDETACHED) {
7072                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7073                 }
7074                 FREE(j_calls);
7075         }
7076 }
7077 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
7078         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7079         JNIEnv *env;
7080         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7081         if (get_jenv_res == JNI_EDETACHED) {
7082                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7083         } else {
7084                 DO_ASSERT(get_jenv_res == JNI_OK);
7085         }
7086         LDKOutPoint id_var = id;
7087         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7088         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7089         uint64_t id_ref = (uint64_t)id_var.inner;
7090         if (id_var.is_owned) {
7091                 id_ref |= 1;
7092         }
7093         LDKChannelMonitor data_var = *data;
7094         data_var = ChannelMonitor_clone(data);
7095         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7096         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7097         uint64_t data_ref = (uint64_t)data_var.inner;
7098         if (data_var.is_owned) {
7099                 data_ref |= 1;
7100         }
7101         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7102         CHECK(obj != NULL);
7103         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
7104         if ((*env)->ExceptionCheck(env)) {
7105                 (*env)->ExceptionDescribe(env);
7106                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7107         }
7108         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7109         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7110         if (get_jenv_res == JNI_EDETACHED) {
7111                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7112         }
7113         return ret_conv;
7114 }
7115 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
7116         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7117         JNIEnv *env;
7118         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7119         if (get_jenv_res == JNI_EDETACHED) {
7120                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7121         } else {
7122                 DO_ASSERT(get_jenv_res == JNI_OK);
7123         }
7124         LDKOutPoint id_var = id;
7125         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7126         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7127         uint64_t id_ref = (uint64_t)id_var.inner;
7128         if (id_var.is_owned) {
7129                 id_ref |= 1;
7130         }
7131         LDKChannelMonitorUpdate update_var = *update;
7132         update_var = ChannelMonitorUpdate_clone(update);
7133         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7134         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7135         uint64_t update_ref = (uint64_t)update_var.inner;
7136         if (update_var.is_owned) {
7137                 update_ref |= 1;
7138         }
7139         LDKChannelMonitor data_var = *data;
7140         data_var = ChannelMonitor_clone(data);
7141         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7142         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7143         uint64_t data_ref = (uint64_t)data_var.inner;
7144         if (data_var.is_owned) {
7145                 data_ref |= 1;
7146         }
7147         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7148         CHECK(obj != NULL);
7149         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7150         if ((*env)->ExceptionCheck(env)) {
7151                 (*env)->ExceptionDescribe(env);
7152                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7153         }
7154         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7155         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7156         if (get_jenv_res == JNI_EDETACHED) {
7157                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7158         }
7159         return ret_conv;
7160 }
7161 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7162         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7163         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7164 }
7165 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7166         jclass c = (*env)->GetObjectClass(env, o);
7167         CHECK(c != NULL);
7168         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7169         atomic_init(&calls->refcnt, 1);
7170         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7171         calls->o = (*env)->NewWeakGlobalRef(env, o);
7172         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7173         CHECK(calls->persist_new_channel_meth != NULL);
7174         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7175         CHECK(calls->update_persisted_channel_meth != NULL);
7176
7177         LDKPersist ret = {
7178                 .this_arg = (void*) calls,
7179                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7180                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7181                 .free = LDKPersist_JCalls_free,
7182         };
7183         return ret;
7184 }
7185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7186         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7187         *res_ptr = LDKPersist_init(env, clz, o);
7188         return (uint64_t)res_ptr;
7189 }
7190 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) {
7191         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7192         LDKOutPoint id_conv;
7193         id_conv.inner = (void*)(id & (~1));
7194         id_conv.is_owned = (id & 1) || (id == 0);
7195         id_conv = OutPoint_clone(&id_conv);
7196         LDKChannelMonitor data_conv;
7197         data_conv.inner = (void*)(data & (~1));
7198         data_conv.is_owned = false;
7199         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7200         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7201         return (uint64_t)ret_conv;
7202 }
7203
7204 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) {
7205         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7206         LDKOutPoint id_conv;
7207         id_conv.inner = (void*)(id & (~1));
7208         id_conv.is_owned = (id & 1) || (id == 0);
7209         id_conv = OutPoint_clone(&id_conv);
7210         LDKChannelMonitorUpdate update_conv;
7211         update_conv.inner = (void*)(update & (~1));
7212         update_conv.is_owned = false;
7213         LDKChannelMonitor data_conv;
7214         data_conv.inner = (void*)(data & (~1));
7215         data_conv.is_owned = false;
7216         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7217         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7218         return (uint64_t)ret_conv;
7219 }
7220
7221 typedef struct LDKChannelMessageHandler_JCalls {
7222         atomic_size_t refcnt;
7223         JavaVM *vm;
7224         jweak o;
7225         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7226         jmethodID handle_open_channel_meth;
7227         jmethodID handle_accept_channel_meth;
7228         jmethodID handle_funding_created_meth;
7229         jmethodID handle_funding_signed_meth;
7230         jmethodID handle_funding_locked_meth;
7231         jmethodID handle_shutdown_meth;
7232         jmethodID handle_closing_signed_meth;
7233         jmethodID handle_update_add_htlc_meth;
7234         jmethodID handle_update_fulfill_htlc_meth;
7235         jmethodID handle_update_fail_htlc_meth;
7236         jmethodID handle_update_fail_malformed_htlc_meth;
7237         jmethodID handle_commitment_signed_meth;
7238         jmethodID handle_revoke_and_ack_meth;
7239         jmethodID handle_update_fee_meth;
7240         jmethodID handle_announcement_signatures_meth;
7241         jmethodID peer_disconnected_meth;
7242         jmethodID peer_connected_meth;
7243         jmethodID handle_channel_reestablish_meth;
7244         jmethodID handle_channel_update_meth;
7245         jmethodID handle_error_meth;
7246 } LDKChannelMessageHandler_JCalls;
7247 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7248         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7249         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7250                 JNIEnv *env;
7251                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7252                 if (get_jenv_res == JNI_EDETACHED) {
7253                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7254                 } else {
7255                         DO_ASSERT(get_jenv_res == JNI_OK);
7256                 }
7257                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7258                 if (get_jenv_res == JNI_EDETACHED) {
7259                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7260                 }
7261                 FREE(j_calls);
7262         }
7263 }
7264 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7265         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7266         JNIEnv *env;
7267         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7268         if (get_jenv_res == JNI_EDETACHED) {
7269                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7270         } else {
7271                 DO_ASSERT(get_jenv_res == JNI_OK);
7272         }
7273         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7274         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7275         LDKInitFeatures their_features_var = their_features;
7276         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7277         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7278         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7279         if (their_features_var.is_owned) {
7280                 their_features_ref |= 1;
7281         }
7282         LDKOpenChannel msg_var = *msg;
7283         msg_var = OpenChannel_clone(msg);
7284         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7285         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7286         uint64_t msg_ref = (uint64_t)msg_var.inner;
7287         if (msg_var.is_owned) {
7288                 msg_ref |= 1;
7289         }
7290         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7291         CHECK(obj != NULL);
7292         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7293         if ((*env)->ExceptionCheck(env)) {
7294                 (*env)->ExceptionDescribe(env);
7295                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7296         }
7297         if (get_jenv_res == JNI_EDETACHED) {
7298                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7299         }
7300 }
7301 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7302         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7303         JNIEnv *env;
7304         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7305         if (get_jenv_res == JNI_EDETACHED) {
7306                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7307         } else {
7308                 DO_ASSERT(get_jenv_res == JNI_OK);
7309         }
7310         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7311         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7312         LDKInitFeatures their_features_var = their_features;
7313         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7314         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7315         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7316         if (their_features_var.is_owned) {
7317                 their_features_ref |= 1;
7318         }
7319         LDKAcceptChannel msg_var = *msg;
7320         msg_var = AcceptChannel_clone(msg);
7321         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7322         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7323         uint64_t msg_ref = (uint64_t)msg_var.inner;
7324         if (msg_var.is_owned) {
7325                 msg_ref |= 1;
7326         }
7327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7328         CHECK(obj != NULL);
7329         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7330         if ((*env)->ExceptionCheck(env)) {
7331                 (*env)->ExceptionDescribe(env);
7332                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7333         }
7334         if (get_jenv_res == JNI_EDETACHED) {
7335                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7336         }
7337 }
7338 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7339         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7340         JNIEnv *env;
7341         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7342         if (get_jenv_res == JNI_EDETACHED) {
7343                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7344         } else {
7345                 DO_ASSERT(get_jenv_res == JNI_OK);
7346         }
7347         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7348         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7349         LDKFundingCreated msg_var = *msg;
7350         msg_var = FundingCreated_clone(msg);
7351         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7352         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7353         uint64_t msg_ref = (uint64_t)msg_var.inner;
7354         if (msg_var.is_owned) {
7355                 msg_ref |= 1;
7356         }
7357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7358         CHECK(obj != NULL);
7359         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7360         if ((*env)->ExceptionCheck(env)) {
7361                 (*env)->ExceptionDescribe(env);
7362                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7363         }
7364         if (get_jenv_res == JNI_EDETACHED) {
7365                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7366         }
7367 }
7368 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7369         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7370         JNIEnv *env;
7371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7372         if (get_jenv_res == JNI_EDETACHED) {
7373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7374         } else {
7375                 DO_ASSERT(get_jenv_res == JNI_OK);
7376         }
7377         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7378         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7379         LDKFundingSigned msg_var = *msg;
7380         msg_var = FundingSigned_clone(msg);
7381         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7382         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7383         uint64_t msg_ref = (uint64_t)msg_var.inner;
7384         if (msg_var.is_owned) {
7385                 msg_ref |= 1;
7386         }
7387         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7388         CHECK(obj != NULL);
7389         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7390         if ((*env)->ExceptionCheck(env)) {
7391                 (*env)->ExceptionDescribe(env);
7392                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7393         }
7394         if (get_jenv_res == JNI_EDETACHED) {
7395                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7396         }
7397 }
7398 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7399         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7400         JNIEnv *env;
7401         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7402         if (get_jenv_res == JNI_EDETACHED) {
7403                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7404         } else {
7405                 DO_ASSERT(get_jenv_res == JNI_OK);
7406         }
7407         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7408         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7409         LDKFundingLocked msg_var = *msg;
7410         msg_var = FundingLocked_clone(msg);
7411         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7412         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7413         uint64_t msg_ref = (uint64_t)msg_var.inner;
7414         if (msg_var.is_owned) {
7415                 msg_ref |= 1;
7416         }
7417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7418         CHECK(obj != NULL);
7419         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7420         if ((*env)->ExceptionCheck(env)) {
7421                 (*env)->ExceptionDescribe(env);
7422                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7423         }
7424         if (get_jenv_res == JNI_EDETACHED) {
7425                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7426         }
7427 }
7428 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7429         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7430         JNIEnv *env;
7431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7432         if (get_jenv_res == JNI_EDETACHED) {
7433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7434         } else {
7435                 DO_ASSERT(get_jenv_res == JNI_OK);
7436         }
7437         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7438         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7439         LDKInitFeatures their_features_var = *their_features;
7440         their_features_var = InitFeatures_clone(their_features);
7441         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7442         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7443         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7444         if (their_features_var.is_owned) {
7445                 their_features_ref |= 1;
7446         }
7447         LDKShutdown msg_var = *msg;
7448         msg_var = Shutdown_clone(msg);
7449         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7450         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7451         uint64_t msg_ref = (uint64_t)msg_var.inner;
7452         if (msg_var.is_owned) {
7453                 msg_ref |= 1;
7454         }
7455         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7456         CHECK(obj != NULL);
7457         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7458         if ((*env)->ExceptionCheck(env)) {
7459                 (*env)->ExceptionDescribe(env);
7460                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7461         }
7462         if (get_jenv_res == JNI_EDETACHED) {
7463                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7464         }
7465 }
7466 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7467         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7468         JNIEnv *env;
7469         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7470         if (get_jenv_res == JNI_EDETACHED) {
7471                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7472         } else {
7473                 DO_ASSERT(get_jenv_res == JNI_OK);
7474         }
7475         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7476         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7477         LDKClosingSigned msg_var = *msg;
7478         msg_var = ClosingSigned_clone(msg);
7479         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7480         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7481         uint64_t msg_ref = (uint64_t)msg_var.inner;
7482         if (msg_var.is_owned) {
7483                 msg_ref |= 1;
7484         }
7485         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7486         CHECK(obj != NULL);
7487         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7488         if ((*env)->ExceptionCheck(env)) {
7489                 (*env)->ExceptionDescribe(env);
7490                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7491         }
7492         if (get_jenv_res == JNI_EDETACHED) {
7493                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7494         }
7495 }
7496 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7497         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7498         JNIEnv *env;
7499         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7500         if (get_jenv_res == JNI_EDETACHED) {
7501                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7502         } else {
7503                 DO_ASSERT(get_jenv_res == JNI_OK);
7504         }
7505         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7506         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7507         LDKUpdateAddHTLC msg_var = *msg;
7508         msg_var = UpdateAddHTLC_clone(msg);
7509         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7510         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7511         uint64_t msg_ref = (uint64_t)msg_var.inner;
7512         if (msg_var.is_owned) {
7513                 msg_ref |= 1;
7514         }
7515         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7516         CHECK(obj != NULL);
7517         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7518         if ((*env)->ExceptionCheck(env)) {
7519                 (*env)->ExceptionDescribe(env);
7520                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7521         }
7522         if (get_jenv_res == JNI_EDETACHED) {
7523                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7524         }
7525 }
7526 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7527         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7528         JNIEnv *env;
7529         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7530         if (get_jenv_res == JNI_EDETACHED) {
7531                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7532         } else {
7533                 DO_ASSERT(get_jenv_res == JNI_OK);
7534         }
7535         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7536         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7537         LDKUpdateFulfillHTLC msg_var = *msg;
7538         msg_var = UpdateFulfillHTLC_clone(msg);
7539         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7540         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7541         uint64_t msg_ref = (uint64_t)msg_var.inner;
7542         if (msg_var.is_owned) {
7543                 msg_ref |= 1;
7544         }
7545         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7546         CHECK(obj != NULL);
7547         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7548         if ((*env)->ExceptionCheck(env)) {
7549                 (*env)->ExceptionDescribe(env);
7550                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7551         }
7552         if (get_jenv_res == JNI_EDETACHED) {
7553                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7554         }
7555 }
7556 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7557         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7558         JNIEnv *env;
7559         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7560         if (get_jenv_res == JNI_EDETACHED) {
7561                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7562         } else {
7563                 DO_ASSERT(get_jenv_res == JNI_OK);
7564         }
7565         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7566         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7567         LDKUpdateFailHTLC msg_var = *msg;
7568         msg_var = UpdateFailHTLC_clone(msg);
7569         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7570         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7571         uint64_t msg_ref = (uint64_t)msg_var.inner;
7572         if (msg_var.is_owned) {
7573                 msg_ref |= 1;
7574         }
7575         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7576         CHECK(obj != NULL);
7577         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7578         if ((*env)->ExceptionCheck(env)) {
7579                 (*env)->ExceptionDescribe(env);
7580                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7581         }
7582         if (get_jenv_res == JNI_EDETACHED) {
7583                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7584         }
7585 }
7586 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7587         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7588         JNIEnv *env;
7589         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7590         if (get_jenv_res == JNI_EDETACHED) {
7591                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7592         } else {
7593                 DO_ASSERT(get_jenv_res == JNI_OK);
7594         }
7595         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7596         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7597         LDKUpdateFailMalformedHTLC msg_var = *msg;
7598         msg_var = UpdateFailMalformedHTLC_clone(msg);
7599         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7600         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7601         uint64_t msg_ref = (uint64_t)msg_var.inner;
7602         if (msg_var.is_owned) {
7603                 msg_ref |= 1;
7604         }
7605         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7606         CHECK(obj != NULL);
7607         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7608         if ((*env)->ExceptionCheck(env)) {
7609                 (*env)->ExceptionDescribe(env);
7610                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7611         }
7612         if (get_jenv_res == JNI_EDETACHED) {
7613                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7614         }
7615 }
7616 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7617         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7618         JNIEnv *env;
7619         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7620         if (get_jenv_res == JNI_EDETACHED) {
7621                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7622         } else {
7623                 DO_ASSERT(get_jenv_res == JNI_OK);
7624         }
7625         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7626         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7627         LDKCommitmentSigned msg_var = *msg;
7628         msg_var = CommitmentSigned_clone(msg);
7629         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7630         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7631         uint64_t msg_ref = (uint64_t)msg_var.inner;
7632         if (msg_var.is_owned) {
7633                 msg_ref |= 1;
7634         }
7635         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7636         CHECK(obj != NULL);
7637         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7638         if ((*env)->ExceptionCheck(env)) {
7639                 (*env)->ExceptionDescribe(env);
7640                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7641         }
7642         if (get_jenv_res == JNI_EDETACHED) {
7643                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7644         }
7645 }
7646 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7647         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7648         JNIEnv *env;
7649         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7650         if (get_jenv_res == JNI_EDETACHED) {
7651                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7652         } else {
7653                 DO_ASSERT(get_jenv_res == JNI_OK);
7654         }
7655         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7656         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7657         LDKRevokeAndACK msg_var = *msg;
7658         msg_var = RevokeAndACK_clone(msg);
7659         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7660         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7661         uint64_t msg_ref = (uint64_t)msg_var.inner;
7662         if (msg_var.is_owned) {
7663                 msg_ref |= 1;
7664         }
7665         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7666         CHECK(obj != NULL);
7667         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7668         if ((*env)->ExceptionCheck(env)) {
7669                 (*env)->ExceptionDescribe(env);
7670                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7671         }
7672         if (get_jenv_res == JNI_EDETACHED) {
7673                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7674         }
7675 }
7676 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7677         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7678         JNIEnv *env;
7679         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7680         if (get_jenv_res == JNI_EDETACHED) {
7681                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7682         } else {
7683                 DO_ASSERT(get_jenv_res == JNI_OK);
7684         }
7685         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7686         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7687         LDKUpdateFee msg_var = *msg;
7688         msg_var = UpdateFee_clone(msg);
7689         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7690         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7691         uint64_t msg_ref = (uint64_t)msg_var.inner;
7692         if (msg_var.is_owned) {
7693                 msg_ref |= 1;
7694         }
7695         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7696         CHECK(obj != NULL);
7697         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7698         if ((*env)->ExceptionCheck(env)) {
7699                 (*env)->ExceptionDescribe(env);
7700                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7701         }
7702         if (get_jenv_res == JNI_EDETACHED) {
7703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7704         }
7705 }
7706 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7707         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7708         JNIEnv *env;
7709         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7710         if (get_jenv_res == JNI_EDETACHED) {
7711                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7712         } else {
7713                 DO_ASSERT(get_jenv_res == JNI_OK);
7714         }
7715         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7716         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7717         LDKAnnouncementSignatures msg_var = *msg;
7718         msg_var = AnnouncementSignatures_clone(msg);
7719         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7720         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7721         uint64_t msg_ref = (uint64_t)msg_var.inner;
7722         if (msg_var.is_owned) {
7723                 msg_ref |= 1;
7724         }
7725         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7726         CHECK(obj != NULL);
7727         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7728         if ((*env)->ExceptionCheck(env)) {
7729                 (*env)->ExceptionDescribe(env);
7730                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7731         }
7732         if (get_jenv_res == JNI_EDETACHED) {
7733                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7734         }
7735 }
7736 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7737         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7738         JNIEnv *env;
7739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7740         if (get_jenv_res == JNI_EDETACHED) {
7741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7742         } else {
7743                 DO_ASSERT(get_jenv_res == JNI_OK);
7744         }
7745         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7746         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7747         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7748         CHECK(obj != NULL);
7749         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7750         if ((*env)->ExceptionCheck(env)) {
7751                 (*env)->ExceptionDescribe(env);
7752                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7753         }
7754         if (get_jenv_res == JNI_EDETACHED) {
7755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7756         }
7757 }
7758 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7759         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7760         JNIEnv *env;
7761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7762         if (get_jenv_res == JNI_EDETACHED) {
7763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7764         } else {
7765                 DO_ASSERT(get_jenv_res == JNI_OK);
7766         }
7767         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7768         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7769         LDKInit msg_var = *msg;
7770         msg_var = Init_clone(msg);
7771         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7772         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7773         uint64_t msg_ref = (uint64_t)msg_var.inner;
7774         if (msg_var.is_owned) {
7775                 msg_ref |= 1;
7776         }
7777         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7778         CHECK(obj != NULL);
7779         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7780         if ((*env)->ExceptionCheck(env)) {
7781                 (*env)->ExceptionDescribe(env);
7782                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7783         }
7784         if (get_jenv_res == JNI_EDETACHED) {
7785                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7786         }
7787 }
7788 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7789         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7790         JNIEnv *env;
7791         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7792         if (get_jenv_res == JNI_EDETACHED) {
7793                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7794         } else {
7795                 DO_ASSERT(get_jenv_res == JNI_OK);
7796         }
7797         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7798         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7799         LDKChannelReestablish msg_var = *msg;
7800         msg_var = ChannelReestablish_clone(msg);
7801         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7802         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7803         uint64_t msg_ref = (uint64_t)msg_var.inner;
7804         if (msg_var.is_owned) {
7805                 msg_ref |= 1;
7806         }
7807         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7808         CHECK(obj != NULL);
7809         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7810         if ((*env)->ExceptionCheck(env)) {
7811                 (*env)->ExceptionDescribe(env);
7812                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7813         }
7814         if (get_jenv_res == JNI_EDETACHED) {
7815                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7816         }
7817 }
7818 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7819         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7820         JNIEnv *env;
7821         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7822         if (get_jenv_res == JNI_EDETACHED) {
7823                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7824         } else {
7825                 DO_ASSERT(get_jenv_res == JNI_OK);
7826         }
7827         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7828         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7829         LDKChannelUpdate msg_var = *msg;
7830         msg_var = ChannelUpdate_clone(msg);
7831         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7832         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7833         uint64_t msg_ref = (uint64_t)msg_var.inner;
7834         if (msg_var.is_owned) {
7835                 msg_ref |= 1;
7836         }
7837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7838         CHECK(obj != NULL);
7839         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7840         if ((*env)->ExceptionCheck(env)) {
7841                 (*env)->ExceptionDescribe(env);
7842                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7843         }
7844         if (get_jenv_res == JNI_EDETACHED) {
7845                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7846         }
7847 }
7848 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7849         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7850         JNIEnv *env;
7851         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7852         if (get_jenv_res == JNI_EDETACHED) {
7853                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7854         } else {
7855                 DO_ASSERT(get_jenv_res == JNI_OK);
7856         }
7857         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7858         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7859         LDKErrorMessage msg_var = *msg;
7860         msg_var = ErrorMessage_clone(msg);
7861         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7862         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7863         uint64_t msg_ref = (uint64_t)msg_var.inner;
7864         if (msg_var.is_owned) {
7865                 msg_ref |= 1;
7866         }
7867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7868         CHECK(obj != NULL);
7869         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7870         if ((*env)->ExceptionCheck(env)) {
7871                 (*env)->ExceptionDescribe(env);
7872                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7873         }
7874         if (get_jenv_res == JNI_EDETACHED) {
7875                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7876         }
7877 }
7878 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7879         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7880         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7881         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7882 }
7883 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7884         jclass c = (*env)->GetObjectClass(env, o);
7885         CHECK(c != NULL);
7886         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7887         atomic_init(&calls->refcnt, 1);
7888         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7889         calls->o = (*env)->NewWeakGlobalRef(env, o);
7890         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7891         CHECK(calls->handle_open_channel_meth != NULL);
7892         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7893         CHECK(calls->handle_accept_channel_meth != NULL);
7894         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7895         CHECK(calls->handle_funding_created_meth != NULL);
7896         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7897         CHECK(calls->handle_funding_signed_meth != NULL);
7898         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7899         CHECK(calls->handle_funding_locked_meth != NULL);
7900         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7901         CHECK(calls->handle_shutdown_meth != NULL);
7902         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7903         CHECK(calls->handle_closing_signed_meth != NULL);
7904         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7905         CHECK(calls->handle_update_add_htlc_meth != NULL);
7906         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7907         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7908         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7909         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7910         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7911         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7912         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7913         CHECK(calls->handle_commitment_signed_meth != NULL);
7914         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7915         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7916         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7917         CHECK(calls->handle_update_fee_meth != NULL);
7918         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7919         CHECK(calls->handle_announcement_signatures_meth != NULL);
7920         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7921         CHECK(calls->peer_disconnected_meth != NULL);
7922         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7923         CHECK(calls->peer_connected_meth != NULL);
7924         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7925         CHECK(calls->handle_channel_reestablish_meth != NULL);
7926         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7927         CHECK(calls->handle_channel_update_meth != NULL);
7928         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7929         CHECK(calls->handle_error_meth != NULL);
7930
7931         LDKChannelMessageHandler ret = {
7932                 .this_arg = (void*) calls,
7933                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7934                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7935                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7936                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7937                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7938                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7939                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7940                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7941                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7942                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7943                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7944                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7945                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7946                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7947                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7948                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7949                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7950                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7951                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7952                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7953                 .free = LDKChannelMessageHandler_JCalls_free,
7954                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7955         };
7956         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7957         return ret;
7958 }
7959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7960         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7961         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7962         return (uint64_t)res_ptr;
7963 }
7964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
7965         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
7966         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
7967         DO_ASSERT((res_ptr & 1) == 0);
7968         return (int64_t)(res_ptr | 1);
7969 }
7970 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) {
7971         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7972         LDKPublicKey their_node_id_ref;
7973         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7974         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7975         LDKInitFeatures their_features_conv;
7976         their_features_conv.inner = (void*)(their_features & (~1));
7977         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7978         their_features_conv = InitFeatures_clone(&their_features_conv);
7979         LDKOpenChannel msg_conv;
7980         msg_conv.inner = (void*)(msg & (~1));
7981         msg_conv.is_owned = false;
7982         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7983 }
7984
7985 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) {
7986         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7987         LDKPublicKey their_node_id_ref;
7988         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7989         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7990         LDKInitFeatures their_features_conv;
7991         their_features_conv.inner = (void*)(their_features & (~1));
7992         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7993         their_features_conv = InitFeatures_clone(&their_features_conv);
7994         LDKAcceptChannel msg_conv;
7995         msg_conv.inner = (void*)(msg & (~1));
7996         msg_conv.is_owned = false;
7997         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7998 }
7999
8000 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) {
8001         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8002         LDKPublicKey their_node_id_ref;
8003         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8004         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8005         LDKFundingCreated msg_conv;
8006         msg_conv.inner = (void*)(msg & (~1));
8007         msg_conv.is_owned = false;
8008         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8009 }
8010
8011 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) {
8012         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8013         LDKPublicKey their_node_id_ref;
8014         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8015         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8016         LDKFundingSigned msg_conv;
8017         msg_conv.inner = (void*)(msg & (~1));
8018         msg_conv.is_owned = false;
8019         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8020 }
8021
8022 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) {
8023         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8024         LDKPublicKey their_node_id_ref;
8025         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8026         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8027         LDKFundingLocked msg_conv;
8028         msg_conv.inner = (void*)(msg & (~1));
8029         msg_conv.is_owned = false;
8030         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8031 }
8032
8033 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) {
8034         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8035         LDKPublicKey their_node_id_ref;
8036         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8037         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8038         LDKInitFeatures their_features_conv;
8039         their_features_conv.inner = (void*)(their_features & (~1));
8040         their_features_conv.is_owned = false;
8041         LDKShutdown msg_conv;
8042         msg_conv.inner = (void*)(msg & (~1));
8043         msg_conv.is_owned = false;
8044         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8045 }
8046
8047 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) {
8048         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8049         LDKPublicKey their_node_id_ref;
8050         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8051         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8052         LDKClosingSigned msg_conv;
8053         msg_conv.inner = (void*)(msg & (~1));
8054         msg_conv.is_owned = false;
8055         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8056 }
8057
8058 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) {
8059         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8060         LDKPublicKey their_node_id_ref;
8061         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8062         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8063         LDKUpdateAddHTLC msg_conv;
8064         msg_conv.inner = (void*)(msg & (~1));
8065         msg_conv.is_owned = false;
8066         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8067 }
8068
8069 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) {
8070         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8071         LDKPublicKey their_node_id_ref;
8072         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8073         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8074         LDKUpdateFulfillHTLC msg_conv;
8075         msg_conv.inner = (void*)(msg & (~1));
8076         msg_conv.is_owned = false;
8077         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8078 }
8079
8080 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) {
8081         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8082         LDKPublicKey their_node_id_ref;
8083         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8084         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8085         LDKUpdateFailHTLC msg_conv;
8086         msg_conv.inner = (void*)(msg & (~1));
8087         msg_conv.is_owned = false;
8088         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8089 }
8090
8091 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) {
8092         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8093         LDKPublicKey their_node_id_ref;
8094         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8095         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8096         LDKUpdateFailMalformedHTLC msg_conv;
8097         msg_conv.inner = (void*)(msg & (~1));
8098         msg_conv.is_owned = false;
8099         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8100 }
8101
8102 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) {
8103         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8104         LDKPublicKey their_node_id_ref;
8105         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8106         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8107         LDKCommitmentSigned msg_conv;
8108         msg_conv.inner = (void*)(msg & (~1));
8109         msg_conv.is_owned = false;
8110         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8111 }
8112
8113 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) {
8114         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8115         LDKPublicKey their_node_id_ref;
8116         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8117         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8118         LDKRevokeAndACK msg_conv;
8119         msg_conv.inner = (void*)(msg & (~1));
8120         msg_conv.is_owned = false;
8121         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8122 }
8123
8124 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) {
8125         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8126         LDKPublicKey their_node_id_ref;
8127         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8128         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8129         LDKUpdateFee msg_conv;
8130         msg_conv.inner = (void*)(msg & (~1));
8131         msg_conv.is_owned = false;
8132         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8133 }
8134
8135 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) {
8136         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8137         LDKPublicKey their_node_id_ref;
8138         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8139         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8140         LDKAnnouncementSignatures msg_conv;
8141         msg_conv.inner = (void*)(msg & (~1));
8142         msg_conv.is_owned = false;
8143         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8144 }
8145
8146 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) {
8147         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8148         LDKPublicKey their_node_id_ref;
8149         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8150         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8151         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8152 }
8153
8154 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) {
8155         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8156         LDKPublicKey their_node_id_ref;
8157         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8158         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8159         LDKInit msg_conv;
8160         msg_conv.inner = (void*)(msg & (~1));
8161         msg_conv.is_owned = false;
8162         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8163 }
8164
8165 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) {
8166         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8167         LDKPublicKey their_node_id_ref;
8168         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8169         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8170         LDKChannelReestablish msg_conv;
8171         msg_conv.inner = (void*)(msg & (~1));
8172         msg_conv.is_owned = false;
8173         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8174 }
8175
8176 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) {
8177         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8178         LDKPublicKey their_node_id_ref;
8179         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8180         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8181         LDKChannelUpdate msg_conv;
8182         msg_conv.inner = (void*)(msg & (~1));
8183         msg_conv.is_owned = false;
8184         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8185 }
8186
8187 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) {
8188         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8189         LDKPublicKey their_node_id_ref;
8190         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8191         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8192         LDKErrorMessage msg_conv;
8193         msg_conv.inner = (void*)(msg & (~1));
8194         msg_conv.is_owned = false;
8195         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8196 }
8197
8198 typedef struct LDKRoutingMessageHandler_JCalls {
8199         atomic_size_t refcnt;
8200         JavaVM *vm;
8201         jweak o;
8202         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8203         jmethodID handle_node_announcement_meth;
8204         jmethodID handle_channel_announcement_meth;
8205         jmethodID handle_channel_update_meth;
8206         jmethodID handle_htlc_fail_channel_update_meth;
8207         jmethodID get_next_channel_announcements_meth;
8208         jmethodID get_next_node_announcements_meth;
8209         jmethodID sync_routing_table_meth;
8210         jmethodID handle_reply_channel_range_meth;
8211         jmethodID handle_reply_short_channel_ids_end_meth;
8212         jmethodID handle_query_channel_range_meth;
8213         jmethodID handle_query_short_channel_ids_meth;
8214 } LDKRoutingMessageHandler_JCalls;
8215 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8216         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8217         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8218                 JNIEnv *env;
8219                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8220                 if (get_jenv_res == JNI_EDETACHED) {
8221                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8222                 } else {
8223                         DO_ASSERT(get_jenv_res == JNI_OK);
8224                 }
8225                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8226                 if (get_jenv_res == JNI_EDETACHED) {
8227                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8228                 }
8229                 FREE(j_calls);
8230         }
8231 }
8232 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8233         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8234         JNIEnv *env;
8235         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8236         if (get_jenv_res == JNI_EDETACHED) {
8237                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8238         } else {
8239                 DO_ASSERT(get_jenv_res == JNI_OK);
8240         }
8241         LDKNodeAnnouncement msg_var = *msg;
8242         msg_var = NodeAnnouncement_clone(msg);
8243         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8244         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8245         uint64_t msg_ref = (uint64_t)msg_var.inner;
8246         if (msg_var.is_owned) {
8247                 msg_ref |= 1;
8248         }
8249         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8250         CHECK(obj != NULL);
8251         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8252         if ((*env)->ExceptionCheck(env)) {
8253                 (*env)->ExceptionDescribe(env);
8254                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8255         }
8256         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8257         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8258         if (get_jenv_res == JNI_EDETACHED) {
8259                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8260         }
8261         return ret_conv;
8262 }
8263 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8264         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8265         JNIEnv *env;
8266         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8267         if (get_jenv_res == JNI_EDETACHED) {
8268                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8269         } else {
8270                 DO_ASSERT(get_jenv_res == JNI_OK);
8271         }
8272         LDKChannelAnnouncement msg_var = *msg;
8273         msg_var = ChannelAnnouncement_clone(msg);
8274         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8275         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8276         uint64_t msg_ref = (uint64_t)msg_var.inner;
8277         if (msg_var.is_owned) {
8278                 msg_ref |= 1;
8279         }
8280         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8281         CHECK(obj != NULL);
8282         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8283         if ((*env)->ExceptionCheck(env)) {
8284                 (*env)->ExceptionDescribe(env);
8285                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8286         }
8287         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8288         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8289         if (get_jenv_res == JNI_EDETACHED) {
8290                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8291         }
8292         return ret_conv;
8293 }
8294 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8295         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8296         JNIEnv *env;
8297         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8298         if (get_jenv_res == JNI_EDETACHED) {
8299                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8300         } else {
8301                 DO_ASSERT(get_jenv_res == JNI_OK);
8302         }
8303         LDKChannelUpdate msg_var = *msg;
8304         msg_var = ChannelUpdate_clone(msg);
8305         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8306         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8307         uint64_t msg_ref = (uint64_t)msg_var.inner;
8308         if (msg_var.is_owned) {
8309                 msg_ref |= 1;
8310         }
8311         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8312         CHECK(obj != NULL);
8313         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8314         if ((*env)->ExceptionCheck(env)) {
8315                 (*env)->ExceptionDescribe(env);
8316                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8317         }
8318         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8319         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8320         if (get_jenv_res == JNI_EDETACHED) {
8321                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8322         }
8323         return ret_conv;
8324 }
8325 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8326         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8327         JNIEnv *env;
8328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8329         if (get_jenv_res == JNI_EDETACHED) {
8330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8331         } else {
8332                 DO_ASSERT(get_jenv_res == JNI_OK);
8333         }
8334         uint64_t ret_update = (uint64_t)update;
8335         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8336         CHECK(obj != NULL);
8337         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8338         if ((*env)->ExceptionCheck(env)) {
8339                 (*env)->ExceptionDescribe(env);
8340                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8341         }
8342         if (get_jenv_res == JNI_EDETACHED) {
8343                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8344         }
8345 }
8346 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8347         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8348         JNIEnv *env;
8349         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8350         if (get_jenv_res == JNI_EDETACHED) {
8351                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8352         } else {
8353                 DO_ASSERT(get_jenv_res == JNI_OK);
8354         }
8355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8356         CHECK(obj != NULL);
8357         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8358         if ((*env)->ExceptionCheck(env)) {
8359                 (*env)->ExceptionDescribe(env);
8360                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8361         }
8362         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8363         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8364         if (ret_constr.datalen > 0)
8365                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8366         else
8367                 ret_constr.data = NULL;
8368         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8369         for (size_t l = 0; l < ret_constr.datalen; l++) {
8370                 int64_t ret_conv_63 = ret_vals[l];
8371                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8372                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8373                 ret_constr.data[l] = ret_conv_63_conv;
8374         }
8375         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8376         if (get_jenv_res == JNI_EDETACHED) {
8377                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8378         }
8379         return ret_constr;
8380 }
8381 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8382         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8383         JNIEnv *env;
8384         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8385         if (get_jenv_res == JNI_EDETACHED) {
8386                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8387         } else {
8388                 DO_ASSERT(get_jenv_res == JNI_OK);
8389         }
8390         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8391         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8392         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8393         CHECK(obj != NULL);
8394         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8395         if ((*env)->ExceptionCheck(env)) {
8396                 (*env)->ExceptionDescribe(env);
8397                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8398         }
8399         LDKCVec_NodeAnnouncementZ ret_constr;
8400         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8401         if (ret_constr.datalen > 0)
8402                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8403         else
8404                 ret_constr.data = NULL;
8405         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8406         for (size_t s = 0; s < ret_constr.datalen; s++) {
8407                 int64_t ret_conv_18 = ret_vals[s];
8408                 LDKNodeAnnouncement ret_conv_18_conv;
8409                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8410                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8411                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8412                 ret_constr.data[s] = ret_conv_18_conv;
8413         }
8414         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8415         if (get_jenv_res == JNI_EDETACHED) {
8416                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8417         }
8418         return ret_constr;
8419 }
8420 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8421         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8422         JNIEnv *env;
8423         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8424         if (get_jenv_res == JNI_EDETACHED) {
8425                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8426         } else {
8427                 DO_ASSERT(get_jenv_res == JNI_OK);
8428         }
8429         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8430         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8431         LDKInit init_var = *init;
8432         init_var = Init_clone(init);
8433         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8434         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8435         uint64_t init_ref = (uint64_t)init_var.inner;
8436         if (init_var.is_owned) {
8437                 init_ref |= 1;
8438         }
8439         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8440         CHECK(obj != NULL);
8441         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8442         if ((*env)->ExceptionCheck(env)) {
8443                 (*env)->ExceptionDescribe(env);
8444                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8445         }
8446         if (get_jenv_res == JNI_EDETACHED) {
8447                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8448         }
8449 }
8450 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8451         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8452         JNIEnv *env;
8453         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8454         if (get_jenv_res == JNI_EDETACHED) {
8455                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8456         } else {
8457                 DO_ASSERT(get_jenv_res == JNI_OK);
8458         }
8459         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8460         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8461         LDKReplyChannelRange msg_var = msg;
8462         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8463         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8464         uint64_t msg_ref = (uint64_t)msg_var.inner;
8465         if (msg_var.is_owned) {
8466                 msg_ref |= 1;
8467         }
8468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8469         CHECK(obj != NULL);
8470         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8471         if ((*env)->ExceptionCheck(env)) {
8472                 (*env)->ExceptionDescribe(env);
8473                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8474         }
8475         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8476         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8477         if (get_jenv_res == JNI_EDETACHED) {
8478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8479         }
8480         return ret_conv;
8481 }
8482 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8483         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8484         JNIEnv *env;
8485         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8486         if (get_jenv_res == JNI_EDETACHED) {
8487                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8488         } else {
8489                 DO_ASSERT(get_jenv_res == JNI_OK);
8490         }
8491         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8492         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8493         LDKReplyShortChannelIdsEnd msg_var = msg;
8494         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8495         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8496         uint64_t msg_ref = (uint64_t)msg_var.inner;
8497         if (msg_var.is_owned) {
8498                 msg_ref |= 1;
8499         }
8500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8501         CHECK(obj != NULL);
8502         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8503         if ((*env)->ExceptionCheck(env)) {
8504                 (*env)->ExceptionDescribe(env);
8505                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8506         }
8507         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8508         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8509         if (get_jenv_res == JNI_EDETACHED) {
8510                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8511         }
8512         return ret_conv;
8513 }
8514 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8515         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8516         JNIEnv *env;
8517         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8518         if (get_jenv_res == JNI_EDETACHED) {
8519                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8520         } else {
8521                 DO_ASSERT(get_jenv_res == JNI_OK);
8522         }
8523         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8524         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8525         LDKQueryChannelRange msg_var = msg;
8526         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8527         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8528         uint64_t msg_ref = (uint64_t)msg_var.inner;
8529         if (msg_var.is_owned) {
8530                 msg_ref |= 1;
8531         }
8532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8533         CHECK(obj != NULL);
8534         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8535         if ((*env)->ExceptionCheck(env)) {
8536                 (*env)->ExceptionDescribe(env);
8537                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8538         }
8539         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8540         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8541         if (get_jenv_res == JNI_EDETACHED) {
8542                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8543         }
8544         return ret_conv;
8545 }
8546 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8547         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8548         JNIEnv *env;
8549         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8550         if (get_jenv_res == JNI_EDETACHED) {
8551                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8552         } else {
8553                 DO_ASSERT(get_jenv_res == JNI_OK);
8554         }
8555         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8556         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8557         LDKQueryShortChannelIds msg_var = msg;
8558         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8559         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8560         uint64_t msg_ref = (uint64_t)msg_var.inner;
8561         if (msg_var.is_owned) {
8562                 msg_ref |= 1;
8563         }
8564         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8565         CHECK(obj != NULL);
8566         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8567         if ((*env)->ExceptionCheck(env)) {
8568                 (*env)->ExceptionDescribe(env);
8569                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8570         }
8571         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8572         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8573         if (get_jenv_res == JNI_EDETACHED) {
8574                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8575         }
8576         return ret_conv;
8577 }
8578 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8579         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8580         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8581         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8582 }
8583 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8584         jclass c = (*env)->GetObjectClass(env, o);
8585         CHECK(c != NULL);
8586         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8587         atomic_init(&calls->refcnt, 1);
8588         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8589         calls->o = (*env)->NewWeakGlobalRef(env, o);
8590         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8591         CHECK(calls->handle_node_announcement_meth != NULL);
8592         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8593         CHECK(calls->handle_channel_announcement_meth != NULL);
8594         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8595         CHECK(calls->handle_channel_update_meth != NULL);
8596         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8597         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8598         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8599         CHECK(calls->get_next_channel_announcements_meth != NULL);
8600         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8601         CHECK(calls->get_next_node_announcements_meth != NULL);
8602         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8603         CHECK(calls->sync_routing_table_meth != NULL);
8604         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8605         CHECK(calls->handle_reply_channel_range_meth != NULL);
8606         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8607         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8608         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8609         CHECK(calls->handle_query_channel_range_meth != NULL);
8610         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8611         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8612
8613         LDKRoutingMessageHandler ret = {
8614                 .this_arg = (void*) calls,
8615                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8616                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8617                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8618                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8619                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8620                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8621                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8622                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8623                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8624                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8625                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8626                 .free = LDKRoutingMessageHandler_JCalls_free,
8627                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8628         };
8629         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8630         return ret;
8631 }
8632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8633         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8634         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8635         return (uint64_t)res_ptr;
8636 }
8637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8638         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
8639         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8640         DO_ASSERT((res_ptr & 1) == 0);
8641         return (int64_t)(res_ptr | 1);
8642 }
8643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8644         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8645         LDKNodeAnnouncement msg_conv;
8646         msg_conv.inner = (void*)(msg & (~1));
8647         msg_conv.is_owned = false;
8648         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8649         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8650         return (uint64_t)ret_conv;
8651 }
8652
8653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8654         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8655         LDKChannelAnnouncement msg_conv;
8656         msg_conv.inner = (void*)(msg & (~1));
8657         msg_conv.is_owned = false;
8658         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8659         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8660         return (uint64_t)ret_conv;
8661 }
8662
8663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8664         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8665         LDKChannelUpdate msg_conv;
8666         msg_conv.inner = (void*)(msg & (~1));
8667         msg_conv.is_owned = false;
8668         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8669         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8670         return (uint64_t)ret_conv;
8671 }
8672
8673 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) {
8674         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8675         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8676         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8677 }
8678
8679 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) {
8680         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8681         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8682         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8683         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8684         for (size_t l = 0; l < ret_var.datalen; l++) {
8685                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8686                 *ret_conv_63_ref = ret_var.data[l];
8687                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8688         }
8689         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8690         FREE(ret_var.data);
8691         return ret_arr;
8692 }
8693
8694 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) {
8695         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8696         LDKPublicKey starting_point_ref;
8697         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8698         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8699         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8700         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8701         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8702         for (size_t s = 0; s < ret_var.datalen; s++) {
8703                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8704                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8705                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8706                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8707                 if (ret_conv_18_var.is_owned) {
8708                         ret_conv_18_ref |= 1;
8709                 }
8710                 ret_arr_ptr[s] = ret_conv_18_ref;
8711         }
8712         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8713         FREE(ret_var.data);
8714         return ret_arr;
8715 }
8716
8717 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) {
8718         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8719         LDKPublicKey their_node_id_ref;
8720         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8721         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8722         LDKInit init_conv;
8723         init_conv.inner = (void*)(init & (~1));
8724         init_conv.is_owned = false;
8725         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8726 }
8727
8728 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) {
8729         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8730         LDKPublicKey their_node_id_ref;
8731         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8732         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8733         LDKReplyChannelRange msg_conv;
8734         msg_conv.inner = (void*)(msg & (~1));
8735         msg_conv.is_owned = (msg & 1) || (msg == 0);
8736         msg_conv = ReplyChannelRange_clone(&msg_conv);
8737         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8738         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8739         return (uint64_t)ret_conv;
8740 }
8741
8742 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) {
8743         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8744         LDKPublicKey their_node_id_ref;
8745         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8746         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8747         LDKReplyShortChannelIdsEnd msg_conv;
8748         msg_conv.inner = (void*)(msg & (~1));
8749         msg_conv.is_owned = (msg & 1) || (msg == 0);
8750         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8751         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8752         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8753         return (uint64_t)ret_conv;
8754 }
8755
8756 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) {
8757         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8758         LDKPublicKey their_node_id_ref;
8759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8761         LDKQueryChannelRange msg_conv;
8762         msg_conv.inner = (void*)(msg & (~1));
8763         msg_conv.is_owned = (msg & 1) || (msg == 0);
8764         msg_conv = QueryChannelRange_clone(&msg_conv);
8765         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8766         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8767         return (uint64_t)ret_conv;
8768 }
8769
8770 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) {
8771         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8772         LDKPublicKey their_node_id_ref;
8773         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8774         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8775         LDKQueryShortChannelIds msg_conv;
8776         msg_conv.inner = (void*)(msg & (~1));
8777         msg_conv.is_owned = (msg & 1) || (msg == 0);
8778         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8779         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8780         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8781         return (uint64_t)ret_conv;
8782 }
8783
8784 typedef struct LDKSocketDescriptor_JCalls {
8785         atomic_size_t refcnt;
8786         JavaVM *vm;
8787         jweak o;
8788         jmethodID send_data_meth;
8789         jmethodID disconnect_socket_meth;
8790         jmethodID eq_meth;
8791         jmethodID hash_meth;
8792 } LDKSocketDescriptor_JCalls;
8793 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8794         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8796                 JNIEnv *env;
8797                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8798                 if (get_jenv_res == JNI_EDETACHED) {
8799                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8800                 } else {
8801                         DO_ASSERT(get_jenv_res == JNI_OK);
8802                 }
8803                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8804                 if (get_jenv_res == JNI_EDETACHED) {
8805                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8806                 }
8807                 FREE(j_calls);
8808         }
8809 }
8810 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8811         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8812         JNIEnv *env;
8813         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8814         if (get_jenv_res == JNI_EDETACHED) {
8815                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8816         } else {
8817                 DO_ASSERT(get_jenv_res == JNI_OK);
8818         }
8819         LDKu8slice data_var = data;
8820         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8821         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8822         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8823         CHECK(obj != NULL);
8824         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8825         if ((*env)->ExceptionCheck(env)) {
8826                 (*env)->ExceptionDescribe(env);
8827                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8828         }
8829         if (get_jenv_res == JNI_EDETACHED) {
8830                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8831         }
8832         return ret;
8833 }
8834 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8835         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8836         JNIEnv *env;
8837         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8838         if (get_jenv_res == JNI_EDETACHED) {
8839                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8840         } else {
8841                 DO_ASSERT(get_jenv_res == JNI_OK);
8842         }
8843         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8844         CHECK(obj != NULL);
8845         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8846         if ((*env)->ExceptionCheck(env)) {
8847                 (*env)->ExceptionDescribe(env);
8848                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8849         }
8850         if (get_jenv_res == JNI_EDETACHED) {
8851                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8852         }
8853 }
8854 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8855         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8856         JNIEnv *env;
8857         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8858         if (get_jenv_res == JNI_EDETACHED) {
8859                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8860         } else {
8861                 DO_ASSERT(get_jenv_res == JNI_OK);
8862         }
8863         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8864         *other_arg_clone = SocketDescriptor_clone(other_arg);
8865         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8866         CHECK(obj != NULL);
8867         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8868         if ((*env)->ExceptionCheck(env)) {
8869                 (*env)->ExceptionDescribe(env);
8870                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8871         }
8872         if (get_jenv_res == JNI_EDETACHED) {
8873                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8874         }
8875         return ret;
8876 }
8877 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8878         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8879         JNIEnv *env;
8880         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8881         if (get_jenv_res == JNI_EDETACHED) {
8882                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8883         } else {
8884                 DO_ASSERT(get_jenv_res == JNI_OK);
8885         }
8886         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8887         CHECK(obj != NULL);
8888         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8889         if ((*env)->ExceptionCheck(env)) {
8890                 (*env)->ExceptionDescribe(env);
8891                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8892         }
8893         if (get_jenv_res == JNI_EDETACHED) {
8894                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8895         }
8896         return ret;
8897 }
8898 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8899         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8900         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8901 }
8902 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8903         jclass c = (*env)->GetObjectClass(env, o);
8904         CHECK(c != NULL);
8905         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8906         atomic_init(&calls->refcnt, 1);
8907         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8908         calls->o = (*env)->NewWeakGlobalRef(env, o);
8909         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8910         CHECK(calls->send_data_meth != NULL);
8911         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8912         CHECK(calls->disconnect_socket_meth != NULL);
8913         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8914         CHECK(calls->eq_meth != NULL);
8915         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8916         CHECK(calls->hash_meth != NULL);
8917
8918         LDKSocketDescriptor ret = {
8919                 .this_arg = (void*) calls,
8920                 .send_data = send_data_LDKSocketDescriptor_jcall,
8921                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8922                 .eq = eq_LDKSocketDescriptor_jcall,
8923                 .hash = hash_LDKSocketDescriptor_jcall,
8924                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8925                 .free = LDKSocketDescriptor_JCalls_free,
8926         };
8927         return ret;
8928 }
8929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8930         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8931         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8932         return (uint64_t)res_ptr;
8933 }
8934 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) {
8935         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8936         LDKu8slice data_ref;
8937         data_ref.datalen = (*env)->GetArrayLength(env, data);
8938         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8939         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8940         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8941         return ret_val;
8942 }
8943
8944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8945         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8946         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8947 }
8948
8949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8950         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8951         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8952         return ret_val;
8953 }
8954
8955 typedef struct LDKChannelManagerPersister_JCalls {
8956         atomic_size_t refcnt;
8957         JavaVM *vm;
8958         jweak o;
8959         jmethodID persist_manager_meth;
8960 } LDKChannelManagerPersister_JCalls;
8961 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8962         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8963         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8964                 JNIEnv *env;
8965                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8966                 if (get_jenv_res == JNI_EDETACHED) {
8967                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8968                 } else {
8969                         DO_ASSERT(get_jenv_res == JNI_OK);
8970                 }
8971                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8972                 if (get_jenv_res == JNI_EDETACHED) {
8973                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8974                 }
8975                 FREE(j_calls);
8976         }
8977 }
8978 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8979         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8980         JNIEnv *env;
8981         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8982         if (get_jenv_res == JNI_EDETACHED) {
8983                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8984         } else {
8985                 DO_ASSERT(get_jenv_res == JNI_OK);
8986         }
8987         LDKChannelManager channel_manager_var = *channel_manager;
8988         // Warning: we may need a move here but no clone is available for LDKChannelManager
8989         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8990         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8991         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8992         if (channel_manager_var.is_owned) {
8993                 channel_manager_ref |= 1;
8994         }
8995         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8996         CHECK(obj != NULL);
8997         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8998         if ((*env)->ExceptionCheck(env)) {
8999                 (*env)->ExceptionDescribe(env);
9000                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
9001         }
9002         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
9003         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
9004         if (get_jenv_res == JNI_EDETACHED) {
9005                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9006         }
9007         return ret_conv;
9008 }
9009 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
9010         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
9011         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9012 }
9013 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
9014         jclass c = (*env)->GetObjectClass(env, o);
9015         CHECK(c != NULL);
9016         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
9017         atomic_init(&calls->refcnt, 1);
9018         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9019         calls->o = (*env)->NewWeakGlobalRef(env, o);
9020         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
9021         CHECK(calls->persist_manager_meth != NULL);
9022
9023         LDKChannelManagerPersister ret = {
9024                 .this_arg = (void*) calls,
9025                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
9026                 .free = LDKChannelManagerPersister_JCalls_free,
9027         };
9028         return ret;
9029 }
9030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
9031         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
9032         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
9033         return (uint64_t)res_ptr;
9034 }
9035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
9036         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
9037         LDKChannelManager channel_manager_conv;
9038         channel_manager_conv.inner = (void*)(channel_manager & (~1));
9039         channel_manager_conv.is_owned = false;
9040         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9041         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
9042         return (uint64_t)ret_conv;
9043 }
9044
9045 static jclass LDKFallback_SegWitProgram_class = NULL;
9046 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
9047 static jclass LDKFallback_PubKeyHash_class = NULL;
9048 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
9049 static jclass LDKFallback_ScriptHash_class = NULL;
9050 static jmethodID LDKFallback_ScriptHash_meth = NULL;
9051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
9052         LDKFallback_SegWitProgram_class =
9053                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
9054         CHECK(LDKFallback_SegWitProgram_class != NULL);
9055         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
9056         CHECK(LDKFallback_SegWitProgram_meth != NULL);
9057         LDKFallback_PubKeyHash_class =
9058                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
9059         CHECK(LDKFallback_PubKeyHash_class != NULL);
9060         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
9061         CHECK(LDKFallback_PubKeyHash_meth != NULL);
9062         LDKFallback_ScriptHash_class =
9063                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
9064         CHECK(LDKFallback_ScriptHash_class != NULL);
9065         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
9066         CHECK(LDKFallback_ScriptHash_meth != NULL);
9067 }
9068 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9069         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9070         switch(obj->tag) {
9071                 case LDKFallback_SegWitProgram: {
9072                         uint8_t version_val = obj->seg_wit_program.version._0;
9073                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
9074                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
9075                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
9076                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
9077                 }
9078                 case LDKFallback_PubKeyHash: {
9079                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
9080                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
9081                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
9082                 }
9083                 case LDKFallback_ScriptHash: {
9084                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
9085                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
9086                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
9087                 }
9088                 default: abort();
9089         }
9090 }
9091 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9092         LDKStr ret_str = _ldk_get_compiled_version();
9093         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9094         Str_free(ret_str);
9095         return ret_conv;
9096 }
9097
9098 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
9099         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
9100         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9101         Str_free(ret_str);
9102         return ret_conv;
9103 }
9104
9105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
9106         LDKTransaction _res_ref;
9107         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
9108         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
9109         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
9110         _res_ref.data_is_owned = true;
9111         Transaction_free(_res_ref);
9112 }
9113
9114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
9115         LDKCVec_u8Z script_pubkey_ref;
9116         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9117         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
9118         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
9119         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9120         *ret_ref = TxOut_new(script_pubkey_ref, value);
9121         return (uint64_t)ret_ref;
9122 }
9123
9124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
9125         if ((_res & 1) != 0) return;
9126         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
9127         FREE((void*)_res);
9128         TxOut_free(_res_conv);
9129 }
9130
9131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9132         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
9133         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9134         *ret_ref = TxOut_clone(orig_conv);
9135         return (uint64_t)ret_ref;
9136 }
9137
9138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
9139         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
9140         Str_free(dummy);
9141 }
9142
9143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9144         LDKSecretKey o_ref;
9145         CHECK((*env)->GetArrayLength(env, o) == 32);
9146         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
9147         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9148         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9149         return (uint64_t)ret_conv;
9150 }
9151
9152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9153         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9154         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9155         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9156         return (uint64_t)ret_conv;
9157 }
9158
9159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9160         if ((_res & 1) != 0) return;
9161         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9162         FREE((void*)_res);
9163         CResult_SecretKeyErrorZ_free(_res_conv);
9164 }
9165
9166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9167         LDKPublicKey o_ref;
9168         CHECK((*env)->GetArrayLength(env, o) == 33);
9169         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9170         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9171         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9172         return (uint64_t)ret_conv;
9173 }
9174
9175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9176         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9177         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9178         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9179         return (uint64_t)ret_conv;
9180 }
9181
9182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9183         if ((_res & 1) != 0) return;
9184         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9185         FREE((void*)_res);
9186         CResult_PublicKeyErrorZ_free(_res_conv);
9187 }
9188
9189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9190         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9191         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9192         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9193         return (uint64_t)ret_conv;
9194 }
9195
9196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9197         LDKTxCreationKeys o_conv;
9198         o_conv.inner = (void*)(o & (~1));
9199         o_conv.is_owned = (o & 1) || (o == 0);
9200         o_conv = TxCreationKeys_clone(&o_conv);
9201         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9202         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9203         return (uint64_t)ret_conv;
9204 }
9205
9206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9207         LDKDecodeError e_conv;
9208         e_conv.inner = (void*)(e & (~1));
9209         e_conv.is_owned = (e & 1) || (e == 0);
9210         e_conv = DecodeError_clone(&e_conv);
9211         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9212         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9213         return (uint64_t)ret_conv;
9214 }
9215
9216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9217         if ((_res & 1) != 0) return;
9218         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9219         FREE((void*)_res);
9220         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9221 }
9222
9223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9224         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9225         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9226         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9227         return (uint64_t)ret_conv;
9228 }
9229
9230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9231         LDKChannelPublicKeys o_conv;
9232         o_conv.inner = (void*)(o & (~1));
9233         o_conv.is_owned = (o & 1) || (o == 0);
9234         o_conv = ChannelPublicKeys_clone(&o_conv);
9235         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9236         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9237         return (uint64_t)ret_conv;
9238 }
9239
9240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9241         LDKDecodeError e_conv;
9242         e_conv.inner = (void*)(e & (~1));
9243         e_conv.is_owned = (e & 1) || (e == 0);
9244         e_conv = DecodeError_clone(&e_conv);
9245         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9246         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9247         return (uint64_t)ret_conv;
9248 }
9249
9250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9251         if ((_res & 1) != 0) return;
9252         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9253         FREE((void*)_res);
9254         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9255 }
9256
9257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9258         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9259         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9260         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9261         return (uint64_t)ret_conv;
9262 }
9263
9264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9265         LDKTxCreationKeys o_conv;
9266         o_conv.inner = (void*)(o & (~1));
9267         o_conv.is_owned = (o & 1) || (o == 0);
9268         o_conv = TxCreationKeys_clone(&o_conv);
9269         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9270         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9271         return (uint64_t)ret_conv;
9272 }
9273
9274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9275         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9276         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9277         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9278         return (uint64_t)ret_conv;
9279 }
9280
9281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9282         if ((_res & 1) != 0) return;
9283         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9284         FREE((void*)_res);
9285         CResult_TxCreationKeysErrorZ_free(_res_conv);
9286 }
9287
9288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9289         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9290         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9291         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9292         return (uint64_t)ret_conv;
9293 }
9294
9295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9296         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9297         *ret_copy = COption_u32Z_some(o);
9298         uint64_t ret_ref = (uint64_t)ret_copy;
9299         return ret_ref;
9300 }
9301
9302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9303         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9304         *ret_copy = COption_u32Z_none();
9305         uint64_t ret_ref = (uint64_t)ret_copy;
9306         return ret_ref;
9307 }
9308
9309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9310         if ((_res & 1) != 0) return;
9311         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9312         FREE((void*)_res);
9313         COption_u32Z_free(_res_conv);
9314 }
9315
9316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9317         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9318         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9319         *ret_copy = COption_u32Z_clone(orig_conv);
9320         uint64_t ret_ref = (uint64_t)ret_copy;
9321         return ret_ref;
9322 }
9323
9324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9325         LDKHTLCOutputInCommitment o_conv;
9326         o_conv.inner = (void*)(o & (~1));
9327         o_conv.is_owned = (o & 1) || (o == 0);
9328         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9329         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9330         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9331         return (uint64_t)ret_conv;
9332 }
9333
9334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9335         LDKDecodeError e_conv;
9336         e_conv.inner = (void*)(e & (~1));
9337         e_conv.is_owned = (e & 1) || (e == 0);
9338         e_conv = DecodeError_clone(&e_conv);
9339         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9340         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9341         return (uint64_t)ret_conv;
9342 }
9343
9344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9345         if ((_res & 1) != 0) return;
9346         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9347         FREE((void*)_res);
9348         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9349 }
9350
9351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9352         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9353         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9354         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9355         return (uint64_t)ret_conv;
9356 }
9357
9358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9359         LDKCounterpartyChannelTransactionParameters o_conv;
9360         o_conv.inner = (void*)(o & (~1));
9361         o_conv.is_owned = (o & 1) || (o == 0);
9362         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9363         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9364         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9365         return (uint64_t)ret_conv;
9366 }
9367
9368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9369         LDKDecodeError e_conv;
9370         e_conv.inner = (void*)(e & (~1));
9371         e_conv.is_owned = (e & 1) || (e == 0);
9372         e_conv = DecodeError_clone(&e_conv);
9373         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9374         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9375         return (uint64_t)ret_conv;
9376 }
9377
9378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9379         if ((_res & 1) != 0) return;
9380         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9381         FREE((void*)_res);
9382         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9383 }
9384
9385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9386         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9387         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9388         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9389         return (uint64_t)ret_conv;
9390 }
9391
9392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9393         LDKChannelTransactionParameters o_conv;
9394         o_conv.inner = (void*)(o & (~1));
9395         o_conv.is_owned = (o & 1) || (o == 0);
9396         o_conv = ChannelTransactionParameters_clone(&o_conv);
9397         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9398         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9399         return (uint64_t)ret_conv;
9400 }
9401
9402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9403         LDKDecodeError e_conv;
9404         e_conv.inner = (void*)(e & (~1));
9405         e_conv.is_owned = (e & 1) || (e == 0);
9406         e_conv = DecodeError_clone(&e_conv);
9407         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9408         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9409         return (uint64_t)ret_conv;
9410 }
9411
9412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9413         if ((_res & 1) != 0) return;
9414         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9415         FREE((void*)_res);
9416         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9417 }
9418
9419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9420         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9421         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9422         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9423         return (uint64_t)ret_conv;
9424 }
9425
9426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9427         LDKCVec_SignatureZ _res_constr;
9428         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9429         if (_res_constr.datalen > 0)
9430                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9431         else
9432                 _res_constr.data = NULL;
9433         for (size_t i = 0; i < _res_constr.datalen; i++) {
9434                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9435                 LDKSignature _res_conv_8_ref;
9436                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9437                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9438                 _res_constr.data[i] = _res_conv_8_ref;
9439         }
9440         CVec_SignatureZ_free(_res_constr);
9441 }
9442
9443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9444         LDKHolderCommitmentTransaction o_conv;
9445         o_conv.inner = (void*)(o & (~1));
9446         o_conv.is_owned = (o & 1) || (o == 0);
9447         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9448         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9449         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9450         return (uint64_t)ret_conv;
9451 }
9452
9453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9454         LDKDecodeError e_conv;
9455         e_conv.inner = (void*)(e & (~1));
9456         e_conv.is_owned = (e & 1) || (e == 0);
9457         e_conv = DecodeError_clone(&e_conv);
9458         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9459         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9460         return (uint64_t)ret_conv;
9461 }
9462
9463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9464         if ((_res & 1) != 0) return;
9465         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9466         FREE((void*)_res);
9467         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9468 }
9469
9470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9471         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9472         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9473         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9474         return (uint64_t)ret_conv;
9475 }
9476
9477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9478         LDKBuiltCommitmentTransaction o_conv;
9479         o_conv.inner = (void*)(o & (~1));
9480         o_conv.is_owned = (o & 1) || (o == 0);
9481         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9482         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9483         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9484         return (uint64_t)ret_conv;
9485 }
9486
9487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9488         LDKDecodeError e_conv;
9489         e_conv.inner = (void*)(e & (~1));
9490         e_conv.is_owned = (e & 1) || (e == 0);
9491         e_conv = DecodeError_clone(&e_conv);
9492         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9493         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9494         return (uint64_t)ret_conv;
9495 }
9496
9497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9498         if ((_res & 1) != 0) return;
9499         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9500         FREE((void*)_res);
9501         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9502 }
9503
9504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9505         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9506         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9507         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9508         return (uint64_t)ret_conv;
9509 }
9510
9511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9512         LDKCommitmentTransaction o_conv;
9513         o_conv.inner = (void*)(o & (~1));
9514         o_conv.is_owned = (o & 1) || (o == 0);
9515         o_conv = CommitmentTransaction_clone(&o_conv);
9516         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9517         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9518         return (uint64_t)ret_conv;
9519 }
9520
9521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9522         LDKDecodeError e_conv;
9523         e_conv.inner = (void*)(e & (~1));
9524         e_conv.is_owned = (e & 1) || (e == 0);
9525         e_conv = DecodeError_clone(&e_conv);
9526         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9527         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9528         return (uint64_t)ret_conv;
9529 }
9530
9531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9532         if ((_res & 1) != 0) return;
9533         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9534         FREE((void*)_res);
9535         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9536 }
9537
9538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9539         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9540         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9541         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9542         return (uint64_t)ret_conv;
9543 }
9544
9545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9546         LDKTrustedCommitmentTransaction o_conv;
9547         o_conv.inner = (void*)(o & (~1));
9548         o_conv.is_owned = (o & 1) || (o == 0);
9549         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9550         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9551         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9552         return (uint64_t)ret_conv;
9553 }
9554
9555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9556         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9557         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9558         return (uint64_t)ret_conv;
9559 }
9560
9561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9562         if ((_res & 1) != 0) return;
9563         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9564         FREE((void*)_res);
9565         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9566 }
9567
9568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9569         LDKCVec_SignatureZ o_constr;
9570         o_constr.datalen = (*env)->GetArrayLength(env, o);
9571         if (o_constr.datalen > 0)
9572                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9573         else
9574                 o_constr.data = NULL;
9575         for (size_t i = 0; i < o_constr.datalen; i++) {
9576                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9577                 LDKSignature o_conv_8_ref;
9578                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9579                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9580                 o_constr.data[i] = o_conv_8_ref;
9581         }
9582         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9583         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9584         return (uint64_t)ret_conv;
9585 }
9586
9587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9588         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9589         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9590         return (uint64_t)ret_conv;
9591 }
9592
9593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9594         if ((_res & 1) != 0) return;
9595         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9596         FREE((void*)_res);
9597         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9598 }
9599
9600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9601         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9602         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9603         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9604         return (uint64_t)ret_conv;
9605 }
9606
9607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9608         LDKShutdownScript o_conv;
9609         o_conv.inner = (void*)(o & (~1));
9610         o_conv.is_owned = (o & 1) || (o == 0);
9611         o_conv = ShutdownScript_clone(&o_conv);
9612         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9613         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
9614         return (uint64_t)ret_conv;
9615 }
9616
9617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9618         LDKDecodeError e_conv;
9619         e_conv.inner = (void*)(e & (~1));
9620         e_conv.is_owned = (e & 1) || (e == 0);
9621         e_conv = DecodeError_clone(&e_conv);
9622         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9623         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
9624         return (uint64_t)ret_conv;
9625 }
9626
9627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9628         if ((_res & 1) != 0) return;
9629         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
9630         FREE((void*)_res);
9631         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
9632 }
9633
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9635         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
9636         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9637         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
9638         return (uint64_t)ret_conv;
9639 }
9640
9641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9642         LDKShutdownScript o_conv;
9643         o_conv.inner = (void*)(o & (~1));
9644         o_conv.is_owned = (o & 1) || (o == 0);
9645         o_conv = ShutdownScript_clone(&o_conv);
9646         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9647         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
9648         return (uint64_t)ret_conv;
9649 }
9650
9651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9652         LDKInvalidShutdownScript e_conv;
9653         e_conv.inner = (void*)(e & (~1));
9654         e_conv.is_owned = (e & 1) || (e == 0);
9655         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
9656         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9657         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
9658         return (uint64_t)ret_conv;
9659 }
9660
9661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9662         if ((_res & 1) != 0) return;
9663         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
9664         FREE((void*)_res);
9665         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
9666 }
9667
9668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9669         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9670         *ret_conv = CResult_NoneErrorZ_ok();
9671         return (uint64_t)ret_conv;
9672 }
9673
9674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9675         LDKIOError e_conv = LDKIOError_from_java(env, e);
9676         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9677         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9678         return (uint64_t)ret_conv;
9679 }
9680
9681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9682         if ((_res & 1) != 0) return;
9683         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9684         FREE((void*)_res);
9685         CResult_NoneErrorZ_free(_res_conv);
9686 }
9687
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9689         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9690         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9691         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9692         return (uint64_t)ret_conv;
9693 }
9694
9695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9696         LDKRouteHop o_conv;
9697         o_conv.inner = (void*)(o & (~1));
9698         o_conv.is_owned = (o & 1) || (o == 0);
9699         o_conv = RouteHop_clone(&o_conv);
9700         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9701         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9702         return (uint64_t)ret_conv;
9703 }
9704
9705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9706         LDKDecodeError e_conv;
9707         e_conv.inner = (void*)(e & (~1));
9708         e_conv.is_owned = (e & 1) || (e == 0);
9709         e_conv = DecodeError_clone(&e_conv);
9710         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9711         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9712         return (uint64_t)ret_conv;
9713 }
9714
9715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9716         if ((_res & 1) != 0) return;
9717         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9718         FREE((void*)_res);
9719         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9720 }
9721
9722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9723         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9724         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9725         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9726         return (uint64_t)ret_conv;
9727 }
9728
9729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9730         LDKCVec_RouteHopZ _res_constr;
9731         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9732         if (_res_constr.datalen > 0)
9733                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9734         else
9735                 _res_constr.data = NULL;
9736         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9737         for (size_t k = 0; k < _res_constr.datalen; k++) {
9738                 int64_t _res_conv_10 = _res_vals[k];
9739                 LDKRouteHop _res_conv_10_conv;
9740                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9741                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9742                 _res_constr.data[k] = _res_conv_10_conv;
9743         }
9744         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9745         CVec_RouteHopZ_free(_res_constr);
9746 }
9747
9748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9749         LDKCVec_CVec_RouteHopZZ _res_constr;
9750         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9751         if (_res_constr.datalen > 0)
9752                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9753         else
9754                 _res_constr.data = NULL;
9755         for (size_t m = 0; m < _res_constr.datalen; m++) {
9756                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9757                 LDKCVec_RouteHopZ _res_conv_12_constr;
9758                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9759                 if (_res_conv_12_constr.datalen > 0)
9760                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9761                 else
9762                         _res_conv_12_constr.data = NULL;
9763                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9764                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9765                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9766                         LDKRouteHop _res_conv_12_conv_10_conv;
9767                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9768                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9769                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9770                 }
9771                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9772                 _res_constr.data[m] = _res_conv_12_constr;
9773         }
9774         CVec_CVec_RouteHopZZ_free(_res_constr);
9775 }
9776
9777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9778         LDKRoute o_conv;
9779         o_conv.inner = (void*)(o & (~1));
9780         o_conv.is_owned = (o & 1) || (o == 0);
9781         o_conv = Route_clone(&o_conv);
9782         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9783         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9784         return (uint64_t)ret_conv;
9785 }
9786
9787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9788         LDKDecodeError e_conv;
9789         e_conv.inner = (void*)(e & (~1));
9790         e_conv.is_owned = (e & 1) || (e == 0);
9791         e_conv = DecodeError_clone(&e_conv);
9792         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9793         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9794         return (uint64_t)ret_conv;
9795 }
9796
9797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9798         if ((_res & 1) != 0) return;
9799         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9800         FREE((void*)_res);
9801         CResult_RouteDecodeErrorZ_free(_res_conv);
9802 }
9803
9804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9805         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9806         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9807         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9808         return (uint64_t)ret_conv;
9809 }
9810
9811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9812         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9813         *ret_copy = COption_u64Z_some(o);
9814         uint64_t ret_ref = (uint64_t)ret_copy;
9815         return ret_ref;
9816 }
9817
9818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9819         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9820         *ret_copy = COption_u64Z_none();
9821         uint64_t ret_ref = (uint64_t)ret_copy;
9822         return ret_ref;
9823 }
9824
9825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9826         if ((_res & 1) != 0) return;
9827         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9828         FREE((void*)_res);
9829         COption_u64Z_free(_res_conv);
9830 }
9831
9832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9833         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9834         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9835         *ret_copy = COption_u64Z_clone(orig_conv);
9836         uint64_t ret_ref = (uint64_t)ret_copy;
9837         return ret_ref;
9838 }
9839
9840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9841         LDKCVec_ChannelDetailsZ _res_constr;
9842         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9843         if (_res_constr.datalen > 0)
9844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9845         else
9846                 _res_constr.data = NULL;
9847         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9848         for (size_t q = 0; q < _res_constr.datalen; q++) {
9849                 int64_t _res_conv_16 = _res_vals[q];
9850                 LDKChannelDetails _res_conv_16_conv;
9851                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9852                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9853                 _res_constr.data[q] = _res_conv_16_conv;
9854         }
9855         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9856         CVec_ChannelDetailsZ_free(_res_constr);
9857 }
9858
9859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9860         LDKCVec_RouteHintZ _res_constr;
9861         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9862         if (_res_constr.datalen > 0)
9863                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9864         else
9865                 _res_constr.data = NULL;
9866         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9867         for (size_t l = 0; l < _res_constr.datalen; l++) {
9868                 int64_t _res_conv_11 = _res_vals[l];
9869                 LDKRouteHint _res_conv_11_conv;
9870                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9871                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9872                 _res_constr.data[l] = _res_conv_11_conv;
9873         }
9874         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9875         CVec_RouteHintZ_free(_res_constr);
9876 }
9877
9878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9879         LDKRoute o_conv;
9880         o_conv.inner = (void*)(o & (~1));
9881         o_conv.is_owned = (o & 1) || (o == 0);
9882         o_conv = Route_clone(&o_conv);
9883         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9884         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9885         return (uint64_t)ret_conv;
9886 }
9887
9888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9889         LDKLightningError e_conv;
9890         e_conv.inner = (void*)(e & (~1));
9891         e_conv.is_owned = (e & 1) || (e == 0);
9892         e_conv = LightningError_clone(&e_conv);
9893         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9894         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9895         return (uint64_t)ret_conv;
9896 }
9897
9898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9899         if ((_res & 1) != 0) return;
9900         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9901         FREE((void*)_res);
9902         CResult_RouteLightningErrorZ_free(_res_conv);
9903 }
9904
9905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9906         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9907         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9908         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9909         return (uint64_t)ret_conv;
9910 }
9911
9912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9913         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9914         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9915         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9916         return (uint64_t)ret_conv;
9917 }
9918
9919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9920         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9921         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9922         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9923         return (uint64_t)ret_conv;
9924 }
9925
9926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9927         if ((_res & 1) != 0) return;
9928         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9929         FREE((void*)_res);
9930         CResult_TxOutAccessErrorZ_free(_res_conv);
9931 }
9932
9933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9934         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9935         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9936         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9937         return (uint64_t)ret_conv;
9938 }
9939
9940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9941         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9942         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9943         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9944         return (uint64_t)ret_ref;
9945 }
9946
9947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9948         LDKTransaction b_ref;
9949         b_ref.datalen = (*env)->GetArrayLength(env, b);
9950         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9951         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9952         b_ref.data_is_owned = true;
9953         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9954         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9955         return (uint64_t)ret_ref;
9956 }
9957
9958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9959         if ((_res & 1) != 0) return;
9960         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9961         FREE((void*)_res);
9962         C2Tuple_usizeTransactionZ_free(_res_conv);
9963 }
9964
9965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9966         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9967         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9968         if (_res_constr.datalen > 0)
9969                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9970         else
9971                 _res_constr.data = NULL;
9972         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9973         for (size_t y = 0; y < _res_constr.datalen; y++) {
9974                 int64_t _res_conv_24 = _res_vals[y];
9975                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9976                 FREE((void*)_res_conv_24);
9977                 _res_constr.data[y] = _res_conv_24_conv;
9978         }
9979         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9980         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9981 }
9982
9983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9984         LDKCVec_TxidZ _res_constr;
9985         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9986         if (_res_constr.datalen > 0)
9987                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9988         else
9989                 _res_constr.data = NULL;
9990         for (size_t i = 0; i < _res_constr.datalen; i++) {
9991                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9992                 LDKThirtyTwoBytes _res_conv_8_ref;
9993                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9994                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9995                 _res_constr.data[i] = _res_conv_8_ref;
9996         }
9997         CVec_TxidZ_free(_res_constr);
9998 }
9999
10000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
10001         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10002         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
10003         return (uint64_t)ret_conv;
10004 }
10005
10006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
10007         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
10008         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10009         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
10010         return (uint64_t)ret_conv;
10011 }
10012
10013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10014         if ((_res & 1) != 0) return;
10015         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
10016         FREE((void*)_res);
10017         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
10018 }
10019
10020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10021         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
10022         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10023         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
10024         return (uint64_t)ret_conv;
10025 }
10026
10027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10028         LDKCVec_MonitorEventZ _res_constr;
10029         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10030         if (_res_constr.datalen > 0)
10031                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
10032         else
10033                 _res_constr.data = NULL;
10034         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10035         for (size_t o = 0; o < _res_constr.datalen; o++) {
10036                 int64_t _res_conv_14 = _res_vals[o];
10037                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
10038                 FREE((void*)_res_conv_14);
10039                 _res_constr.data[o] = _res_conv_14_conv;
10040         }
10041         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10042         CVec_MonitorEventZ_free(_res_constr);
10043 }
10044
10045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
10046         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
10047         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10048         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
10049         uint64_t ret_ref = (uint64_t)ret_copy;
10050         return ret_ref;
10051 }
10052
10053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
10054         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10055         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
10056         uint64_t ret_ref = (uint64_t)ret_copy;
10057         return ret_ref;
10058 }
10059
10060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10061         if ((_res & 1) != 0) return;
10062         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
10063         FREE((void*)_res);
10064         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
10065 }
10066
10067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10068         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
10069         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10070         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
10071         uint64_t ret_ref = (uint64_t)ret_copy;
10072         return ret_ref;
10073 }
10074
10075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10076         LDKCVec_SpendableOutputDescriptorZ _res_constr;
10077         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10078         if (_res_constr.datalen > 0)
10079                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10080         else
10081                 _res_constr.data = NULL;
10082         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10083         for (size_t b = 0; b < _res_constr.datalen; b++) {
10084                 int64_t _res_conv_27 = _res_vals[b];
10085                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
10086                 FREE((void*)_res_conv_27);
10087                 _res_constr.data[b] = _res_conv_27_conv;
10088         }
10089         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10090         CVec_SpendableOutputDescriptorZ_free(_res_constr);
10091 }
10092
10093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10094         LDKCVec_MessageSendEventZ _res_constr;
10095         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10096         if (_res_constr.datalen > 0)
10097                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10098         else
10099                 _res_constr.data = NULL;
10100         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10101         for (size_t s = 0; s < _res_constr.datalen; s++) {
10102                 int64_t _res_conv_18 = _res_vals[s];
10103                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
10104                 FREE((void*)_res_conv_18);
10105                 _res_constr.data[s] = _res_conv_18_conv;
10106         }
10107         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10108         CVec_MessageSendEventZ_free(_res_constr);
10109 }
10110
10111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10112         LDKInitFeatures o_conv;
10113         o_conv.inner = (void*)(o & (~1));
10114         o_conv.is_owned = (o & 1) || (o == 0);
10115         o_conv = InitFeatures_clone(&o_conv);
10116         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10117         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
10118         return (uint64_t)ret_conv;
10119 }
10120
10121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10122         LDKDecodeError e_conv;
10123         e_conv.inner = (void*)(e & (~1));
10124         e_conv.is_owned = (e & 1) || (e == 0);
10125         e_conv = DecodeError_clone(&e_conv);
10126         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10127         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
10128         return (uint64_t)ret_conv;
10129 }
10130
10131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10132         if ((_res & 1) != 0) return;
10133         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10134         FREE((void*)_res);
10135         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
10136 }
10137
10138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10139         LDKNodeFeatures o_conv;
10140         o_conv.inner = (void*)(o & (~1));
10141         o_conv.is_owned = (o & 1) || (o == 0);
10142         o_conv = NodeFeatures_clone(&o_conv);
10143         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10144         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
10145         return (uint64_t)ret_conv;
10146 }
10147
10148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10149         LDKDecodeError e_conv;
10150         e_conv.inner = (void*)(e & (~1));
10151         e_conv.is_owned = (e & 1) || (e == 0);
10152         e_conv = DecodeError_clone(&e_conv);
10153         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10154         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
10155         return (uint64_t)ret_conv;
10156 }
10157
10158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10159         if ((_res & 1) != 0) return;
10160         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10161         FREE((void*)_res);
10162         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
10163 }
10164
10165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10166         LDKChannelFeatures o_conv;
10167         o_conv.inner = (void*)(o & (~1));
10168         o_conv.is_owned = (o & 1) || (o == 0);
10169         o_conv = ChannelFeatures_clone(&o_conv);
10170         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10171         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
10172         return (uint64_t)ret_conv;
10173 }
10174
10175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10176         LDKDecodeError e_conv;
10177         e_conv.inner = (void*)(e & (~1));
10178         e_conv.is_owned = (e & 1) || (e == 0);
10179         e_conv = DecodeError_clone(&e_conv);
10180         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10181         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
10182         return (uint64_t)ret_conv;
10183 }
10184
10185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10186         if ((_res & 1) != 0) return;
10187         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10188         FREE((void*)_res);
10189         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
10190 }
10191
10192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10193         LDKInvoiceFeatures o_conv;
10194         o_conv.inner = (void*)(o & (~1));
10195         o_conv.is_owned = (o & 1) || (o == 0);
10196         o_conv = InvoiceFeatures_clone(&o_conv);
10197         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10198         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
10199         return (uint64_t)ret_conv;
10200 }
10201
10202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10203         LDKDecodeError e_conv;
10204         e_conv.inner = (void*)(e & (~1));
10205         e_conv.is_owned = (e & 1) || (e == 0);
10206         e_conv = DecodeError_clone(&e_conv);
10207         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10208         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10209         return (uint64_t)ret_conv;
10210 }
10211
10212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10213         if ((_res & 1) != 0) return;
10214         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10215         FREE((void*)_res);
10216         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10217 }
10218
10219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10220         LDKDelayedPaymentOutputDescriptor o_conv;
10221         o_conv.inner = (void*)(o & (~1));
10222         o_conv.is_owned = (o & 1) || (o == 0);
10223         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10224         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10225         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10226         return (uint64_t)ret_conv;
10227 }
10228
10229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10230         LDKDecodeError e_conv;
10231         e_conv.inner = (void*)(e & (~1));
10232         e_conv.is_owned = (e & 1) || (e == 0);
10233         e_conv = DecodeError_clone(&e_conv);
10234         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10235         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10236         return (uint64_t)ret_conv;
10237 }
10238
10239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10240         if ((_res & 1) != 0) return;
10241         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10242         FREE((void*)_res);
10243         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10244 }
10245
10246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10247         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10248         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10249         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10250         return (uint64_t)ret_conv;
10251 }
10252
10253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10254         LDKStaticPaymentOutputDescriptor o_conv;
10255         o_conv.inner = (void*)(o & (~1));
10256         o_conv.is_owned = (o & 1) || (o == 0);
10257         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10258         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10259         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10260         return (uint64_t)ret_conv;
10261 }
10262
10263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10264         LDKDecodeError e_conv;
10265         e_conv.inner = (void*)(e & (~1));
10266         e_conv.is_owned = (e & 1) || (e == 0);
10267         e_conv = DecodeError_clone(&e_conv);
10268         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10269         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10270         return (uint64_t)ret_conv;
10271 }
10272
10273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10274         if ((_res & 1) != 0) return;
10275         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10276         FREE((void*)_res);
10277         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10278 }
10279
10280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10281         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10282         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10283         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10284         return (uint64_t)ret_conv;
10285 }
10286
10287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10288         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10289         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10290         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10291         return (uint64_t)ret_conv;
10292 }
10293
10294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10295         LDKDecodeError e_conv;
10296         e_conv.inner = (void*)(e & (~1));
10297         e_conv.is_owned = (e & 1) || (e == 0);
10298         e_conv = DecodeError_clone(&e_conv);
10299         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10300         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10301         return (uint64_t)ret_conv;
10302 }
10303
10304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10305         if ((_res & 1) != 0) return;
10306         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10307         FREE((void*)_res);
10308         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10309 }
10310
10311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10312         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10313         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10314         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10315         return (uint64_t)ret_conv;
10316 }
10317
10318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10319         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10320         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10321         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10322         return (uint64_t)ret_ref;
10323 }
10324
10325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10326         LDKSignature a_ref;
10327         CHECK((*env)->GetArrayLength(env, a) == 64);
10328         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10329         LDKCVec_SignatureZ b_constr;
10330         b_constr.datalen = (*env)->GetArrayLength(env, b);
10331         if (b_constr.datalen > 0)
10332                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10333         else
10334                 b_constr.data = NULL;
10335         for (size_t i = 0; i < b_constr.datalen; i++) {
10336                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10337                 LDKSignature b_conv_8_ref;
10338                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10339                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10340                 b_constr.data[i] = b_conv_8_ref;
10341         }
10342         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10343         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10344         return (uint64_t)ret_ref;
10345 }
10346
10347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10348         if ((_res & 1) != 0) return;
10349         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10350         FREE((void*)_res);
10351         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10352 }
10353
10354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10355         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10356         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10357         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10358         return (uint64_t)ret_conv;
10359 }
10360
10361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10362         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10363         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10364         return (uint64_t)ret_conv;
10365 }
10366
10367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10368         if ((_res & 1) != 0) return;
10369         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10370         FREE((void*)_res);
10371         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10372 }
10373
10374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10375         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10376         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10377         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10378         return (uint64_t)ret_conv;
10379 }
10380
10381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10382         LDKSignature o_ref;
10383         CHECK((*env)->GetArrayLength(env, o) == 64);
10384         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10385         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10386         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10387         return (uint64_t)ret_conv;
10388 }
10389
10390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10391         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10392         *ret_conv = CResult_SignatureNoneZ_err();
10393         return (uint64_t)ret_conv;
10394 }
10395
10396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10397         if ((_res & 1) != 0) return;
10398         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10399         FREE((void*)_res);
10400         CResult_SignatureNoneZ_free(_res_conv);
10401 }
10402
10403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10404         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10405         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10406         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10407         return (uint64_t)ret_conv;
10408 }
10409
10410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10411         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10412         if (o_conv.free == LDKSign_JCalls_free) {
10413                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10414                 LDKSign_JCalls_cloned(&o_conv);
10415         }
10416         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10417         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10418         return (uint64_t)ret_conv;
10419 }
10420
10421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10422         LDKDecodeError e_conv;
10423         e_conv.inner = (void*)(e & (~1));
10424         e_conv.is_owned = (e & 1) || (e == 0);
10425         e_conv = DecodeError_clone(&e_conv);
10426         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10427         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10428         return (uint64_t)ret_conv;
10429 }
10430
10431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10432         if ((_res & 1) != 0) return;
10433         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10434         FREE((void*)_res);
10435         CResult_SignDecodeErrorZ_free(_res_conv);
10436 }
10437
10438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10439         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10440         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10441         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10442         return (uint64_t)ret_conv;
10443 }
10444
10445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10446         LDKCVec_u8Z _res_ref;
10447         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10448         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10449         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10450         CVec_u8Z_free(_res_ref);
10451 }
10452
10453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10454         LDKRecoverableSignature arg_ref;
10455         CHECK((*env)->GetArrayLength(env, arg) == 68);
10456         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10457         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10458         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10459         return (uint64_t)ret_conv;
10460 }
10461
10462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10463         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10464         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10465         return (uint64_t)ret_conv;
10466 }
10467
10468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10469         if ((_res & 1) != 0) return;
10470         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10471         FREE((void*)_res);
10472         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10473 }
10474
10475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10476         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10477         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10478         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10479         return (uint64_t)ret_conv;
10480 }
10481
10482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10483         LDKCVec_CVec_u8ZZ _res_constr;
10484         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10485         if (_res_constr.datalen > 0)
10486                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10487         else
10488                 _res_constr.data = NULL;
10489         for (size_t i = 0; i < _res_constr.datalen; i++) {
10490                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10491                 LDKCVec_u8Z _res_conv_8_ref;
10492                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10493                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10494                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10495                 _res_constr.data[i] = _res_conv_8_ref;
10496         }
10497         CVec_CVec_u8ZZ_free(_res_constr);
10498 }
10499
10500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10501         LDKCVec_CVec_u8ZZ o_constr;
10502         o_constr.datalen = (*env)->GetArrayLength(env, o);
10503         if (o_constr.datalen > 0)
10504                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10505         else
10506                 o_constr.data = NULL;
10507         for (size_t i = 0; i < o_constr.datalen; i++) {
10508                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10509                 LDKCVec_u8Z o_conv_8_ref;
10510                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10511                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10512                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10513                 o_constr.data[i] = o_conv_8_ref;
10514         }
10515         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10516         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10517         return (uint64_t)ret_conv;
10518 }
10519
10520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10521         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10522         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10523         return (uint64_t)ret_conv;
10524 }
10525
10526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10527         if ((_res & 1) != 0) return;
10528         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10529         FREE((void*)_res);
10530         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10531 }
10532
10533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10534         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10535         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10536         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10537         return (uint64_t)ret_conv;
10538 }
10539
10540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10541         LDKInMemorySigner o_conv;
10542         o_conv.inner = (void*)(o & (~1));
10543         o_conv.is_owned = (o & 1) || (o == 0);
10544         o_conv = InMemorySigner_clone(&o_conv);
10545         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10546         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10547         return (uint64_t)ret_conv;
10548 }
10549
10550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10551         LDKDecodeError e_conv;
10552         e_conv.inner = (void*)(e & (~1));
10553         e_conv.is_owned = (e & 1) || (e == 0);
10554         e_conv = DecodeError_clone(&e_conv);
10555         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10556         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10557         return (uint64_t)ret_conv;
10558 }
10559
10560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10561         if ((_res & 1) != 0) return;
10562         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10563         FREE((void*)_res);
10564         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10565 }
10566
10567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10568         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10569         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10570         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10571         return (uint64_t)ret_conv;
10572 }
10573
10574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10575         LDKCVec_TxOutZ _res_constr;
10576         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10577         if (_res_constr.datalen > 0)
10578                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10579         else
10580                 _res_constr.data = NULL;
10581         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10582         for (size_t h = 0; h < _res_constr.datalen; h++) {
10583                 int64_t _res_conv_7 = _res_vals[h];
10584                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10585                 FREE((void*)_res_conv_7);
10586                 _res_constr.data[h] = _res_conv_7_conv;
10587         }
10588         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10589         CVec_TxOutZ_free(_res_constr);
10590 }
10591
10592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10593         LDKTransaction o_ref;
10594         o_ref.datalen = (*env)->GetArrayLength(env, o);
10595         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10596         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10597         o_ref.data_is_owned = true;
10598         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10599         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10600         return (uint64_t)ret_conv;
10601 }
10602
10603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10604         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10605         *ret_conv = CResult_TransactionNoneZ_err();
10606         return (uint64_t)ret_conv;
10607 }
10608
10609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10610         if ((_res & 1) != 0) return;
10611         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10612         FREE((void*)_res);
10613         CResult_TransactionNoneZ_free(_res_conv);
10614 }
10615
10616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10617         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10618         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10619         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10620         return (uint64_t)ret_conv;
10621 }
10622
10623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10624         LDKThirtyTwoBytes a_ref;
10625         CHECK((*env)->GetArrayLength(env, a) == 32);
10626         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10627         LDKChannelMonitor b_conv;
10628         b_conv.inner = (void*)(b & (~1));
10629         b_conv.is_owned = (b & 1) || (b == 0);
10630         b_conv = ChannelMonitor_clone(&b_conv);
10631         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10632         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10633         return (uint64_t)ret_ref;
10634 }
10635
10636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10637         if ((_res & 1) != 0) return;
10638         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10639         FREE((void*)_res);
10640         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10641 }
10642
10643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10644         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10645         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10646         if (_res_constr.datalen > 0)
10647                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10648         else
10649                 _res_constr.data = NULL;
10650         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10651         for (size_t i = 0; i < _res_constr.datalen; i++) {
10652                 int64_t _res_conv_34 = _res_vals[i];
10653                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10654                 FREE((void*)_res_conv_34);
10655                 _res_constr.data[i] = _res_conv_34_conv;
10656         }
10657         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10658         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10659 }
10660
10661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10662         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10663         o_constr.datalen = (*env)->GetArrayLength(env, o);
10664         if (o_constr.datalen > 0)
10665                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10666         else
10667                 o_constr.data = NULL;
10668         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10669         for (size_t i = 0; i < o_constr.datalen; i++) {
10670                 int64_t o_conv_34 = o_vals[i];
10671                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10672                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10673                 o_constr.data[i] = o_conv_34_conv;
10674         }
10675         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10676         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10677         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10678         return (uint64_t)ret_conv;
10679 }
10680
10681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10682         LDKIOError e_conv = LDKIOError_from_java(env, e);
10683         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10684         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10685         return (uint64_t)ret_conv;
10686 }
10687
10688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10689         if ((_res & 1) != 0) return;
10690         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10691         FREE((void*)_res);
10692         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10693 }
10694
10695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10696         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10697         *ret_copy = COption_u16Z_some(o);
10698         uint64_t ret_ref = (uint64_t)ret_copy;
10699         return ret_ref;
10700 }
10701
10702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10703         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10704         *ret_copy = COption_u16Z_none();
10705         uint64_t ret_ref = (uint64_t)ret_copy;
10706         return ret_ref;
10707 }
10708
10709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10710         if ((_res & 1) != 0) return;
10711         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10712         FREE((void*)_res);
10713         COption_u16Z_free(_res_conv);
10714 }
10715
10716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10717         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10718         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10719         *ret_copy = COption_u16Z_clone(orig_conv);
10720         uint64_t ret_ref = (uint64_t)ret_copy;
10721         return ret_ref;
10722 }
10723
10724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10725         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10726         *ret_conv = CResult_NoneAPIErrorZ_ok();
10727         return (uint64_t)ret_conv;
10728 }
10729
10730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10731         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10732         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10733         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10734         return (uint64_t)ret_conv;
10735 }
10736
10737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10738         if ((_res & 1) != 0) return;
10739         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10740         FREE((void*)_res);
10741         CResult_NoneAPIErrorZ_free(_res_conv);
10742 }
10743
10744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10745         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10746         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10747         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10748         return (uint64_t)ret_conv;
10749 }
10750
10751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10752         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10753         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10754         if (_res_constr.datalen > 0)
10755                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10756         else
10757                 _res_constr.data = NULL;
10758         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10759         for (size_t w = 0; w < _res_constr.datalen; w++) {
10760                 int64_t _res_conv_22 = _res_vals[w];
10761                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10762                 FREE((void*)_res_conv_22);
10763                 _res_constr.data[w] = _res_conv_22_conv;
10764         }
10765         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10766         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10767 }
10768
10769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10770         LDKCVec_APIErrorZ _res_constr;
10771         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10772         if (_res_constr.datalen > 0)
10773                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10774         else
10775                 _res_constr.data = NULL;
10776         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10777         for (size_t k = 0; k < _res_constr.datalen; k++) {
10778                 int64_t _res_conv_10 = _res_vals[k];
10779                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10780                 FREE((void*)_res_conv_10);
10781                 _res_constr.data[k] = _res_conv_10_conv;
10782         }
10783         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10784         CVec_APIErrorZ_free(_res_constr);
10785 }
10786
10787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10788         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10789         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10790         return (uint64_t)ret_conv;
10791 }
10792
10793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10794         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10795         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10796         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10797         return (uint64_t)ret_conv;
10798 }
10799
10800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10801         if ((_res & 1) != 0) return;
10802         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10803         FREE((void*)_res);
10804         CResult_NonePaymentSendFailureZ_free(_res_conv);
10805 }
10806
10807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10808         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10809         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10810         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10811         return (uint64_t)ret_conv;
10812 }
10813
10814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10815         LDKThirtyTwoBytes o_ref;
10816         CHECK((*env)->GetArrayLength(env, o) == 32);
10817         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10818         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10819         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
10820         return (uint64_t)ret_conv;
10821 }
10822
10823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10824         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10825         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10826         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
10827         return (uint64_t)ret_conv;
10828 }
10829
10830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10831         if ((_res & 1) != 0) return;
10832         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10833         FREE((void*)_res);
10834         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
10835 }
10836
10837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10838         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
10839         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
10840         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
10841         return (uint64_t)ret_conv;
10842 }
10843
10844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10845         LDKCVec_NetAddressZ _res_constr;
10846         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10847         if (_res_constr.datalen > 0)
10848                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10849         else
10850                 _res_constr.data = NULL;
10851         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10852         for (size_t m = 0; m < _res_constr.datalen; m++) {
10853                 int64_t _res_conv_12 = _res_vals[m];
10854                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10855                 FREE((void*)_res_conv_12);
10856                 _res_constr.data[m] = _res_conv_12_conv;
10857         }
10858         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10859         CVec_NetAddressZ_free(_res_constr);
10860 }
10861
10862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10863         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10864         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10865         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10866         return (uint64_t)ret_ref;
10867 }
10868
10869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10870         LDKThirtyTwoBytes a_ref;
10871         CHECK((*env)->GetArrayLength(env, a) == 32);
10872         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10873         LDKThirtyTwoBytes b_ref;
10874         CHECK((*env)->GetArrayLength(env, b) == 32);
10875         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10876         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10877         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10878         return (uint64_t)ret_ref;
10879 }
10880
10881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10882         if ((_res & 1) != 0) return;
10883         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10884         FREE((void*)_res);
10885         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10886 }
10887
10888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10889         LDKThirtyTwoBytes o_ref;
10890         CHECK((*env)->GetArrayLength(env, o) == 32);
10891         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10892         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10893         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10894         return (uint64_t)ret_conv;
10895 }
10896
10897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10898         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10899         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10900         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10901         return (uint64_t)ret_conv;
10902 }
10903
10904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10905         if ((_res & 1) != 0) return;
10906         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10907         FREE((void*)_res);
10908         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10909 }
10910
10911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10912         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10913         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10914         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10915         return (uint64_t)ret_conv;
10916 }
10917
10918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10919         LDKCVec_ChannelMonitorZ _res_constr;
10920         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10921         if (_res_constr.datalen > 0)
10922                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10923         else
10924                 _res_constr.data = NULL;
10925         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10926         for (size_t q = 0; q < _res_constr.datalen; q++) {
10927                 int64_t _res_conv_16 = _res_vals[q];
10928                 LDKChannelMonitor _res_conv_16_conv;
10929                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10930                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10931                 _res_constr.data[q] = _res_conv_16_conv;
10932         }
10933         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10934         CVec_ChannelMonitorZ_free(_res_constr);
10935 }
10936
10937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10938         LDKThirtyTwoBytes a_ref;
10939         CHECK((*env)->GetArrayLength(env, a) == 32);
10940         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10941         LDKChannelManager b_conv;
10942         b_conv.inner = (void*)(b & (~1));
10943         b_conv.is_owned = (b & 1) || (b == 0);
10944         // Warning: we need a move here but no clone is available for LDKChannelManager
10945         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10946         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10947         return (uint64_t)ret_ref;
10948 }
10949
10950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10951         if ((_res & 1) != 0) return;
10952         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10953         FREE((void*)_res);
10954         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10955 }
10956
10957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10958         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10959         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10960         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10961         return (uint64_t)ret_conv;
10962 }
10963
10964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10965         LDKDecodeError e_conv;
10966         e_conv.inner = (void*)(e & (~1));
10967         e_conv.is_owned = (e & 1) || (e == 0);
10968         e_conv = DecodeError_clone(&e_conv);
10969         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10970         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10971         return (uint64_t)ret_conv;
10972 }
10973
10974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10975         if ((_res & 1) != 0) return;
10976         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10977         FREE((void*)_res);
10978         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10979 }
10980
10981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10982         LDKChannelConfig o_conv;
10983         o_conv.inner = (void*)(o & (~1));
10984         o_conv.is_owned = (o & 1) || (o == 0);
10985         o_conv = ChannelConfig_clone(&o_conv);
10986         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10987         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10988         return (uint64_t)ret_conv;
10989 }
10990
10991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10992         LDKDecodeError e_conv;
10993         e_conv.inner = (void*)(e & (~1));
10994         e_conv.is_owned = (e & 1) || (e == 0);
10995         e_conv = DecodeError_clone(&e_conv);
10996         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10997         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10998         return (uint64_t)ret_conv;
10999 }
11000
11001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11002         if ((_res & 1) != 0) return;
11003         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
11004         FREE((void*)_res);
11005         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
11006 }
11007
11008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11009         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
11010         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11011         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
11012         return (uint64_t)ret_conv;
11013 }
11014
11015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11016         LDKOutPoint o_conv;
11017         o_conv.inner = (void*)(o & (~1));
11018         o_conv.is_owned = (o & 1) || (o == 0);
11019         o_conv = OutPoint_clone(&o_conv);
11020         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11021         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
11022         return (uint64_t)ret_conv;
11023 }
11024
11025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11026         LDKDecodeError e_conv;
11027         e_conv.inner = (void*)(e & (~1));
11028         e_conv.is_owned = (e & 1) || (e == 0);
11029         e_conv = DecodeError_clone(&e_conv);
11030         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11031         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
11032         return (uint64_t)ret_conv;
11033 }
11034
11035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11036         if ((_res & 1) != 0) return;
11037         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
11038         FREE((void*)_res);
11039         CResult_OutPointDecodeErrorZ_free(_res_conv);
11040 }
11041
11042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11043         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
11044         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11045         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
11046         return (uint64_t)ret_conv;
11047 }
11048
11049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
11050         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
11051         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11052         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
11053         return (uint64_t)ret_conv;
11054 }
11055
11056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
11057         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11058         *ret_conv = CResult_SiPrefixNoneZ_err();
11059         return (uint64_t)ret_conv;
11060 }
11061
11062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11063         if ((_res & 1) != 0) return;
11064         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
11065         FREE((void*)_res);
11066         CResult_SiPrefixNoneZ_free(_res_conv);
11067 }
11068
11069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11070         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
11071         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11072         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
11073         return (uint64_t)ret_conv;
11074 }
11075
11076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11077         LDKInvoice o_conv;
11078         o_conv.inner = (void*)(o & (~1));
11079         o_conv.is_owned = (o & 1) || (o == 0);
11080         o_conv = Invoice_clone(&o_conv);
11081         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11082         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
11083         return (uint64_t)ret_conv;
11084 }
11085
11086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11087         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11088         *ret_conv = CResult_InvoiceNoneZ_err();
11089         return (uint64_t)ret_conv;
11090 }
11091
11092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11093         if ((_res & 1) != 0) return;
11094         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
11095         FREE((void*)_res);
11096         CResult_InvoiceNoneZ_free(_res_conv);
11097 }
11098
11099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11100         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
11101         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11102         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
11103         return (uint64_t)ret_conv;
11104 }
11105
11106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11107         LDKSignedRawInvoice o_conv;
11108         o_conv.inner = (void*)(o & (~1));
11109         o_conv.is_owned = (o & 1) || (o == 0);
11110         o_conv = SignedRawInvoice_clone(&o_conv);
11111         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11112         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
11113         return (uint64_t)ret_conv;
11114 }
11115
11116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
11117         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11118         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
11119         return (uint64_t)ret_conv;
11120 }
11121
11122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11123         if ((_res & 1) != 0) return;
11124         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
11125         FREE((void*)_res);
11126         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
11127 }
11128
11129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11130         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
11131         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11132         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
11133         return (uint64_t)ret_conv;
11134 }
11135
11136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11137         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
11138         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11139         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
11140         return (uint64_t)ret_ref;
11141 }
11142
11143 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) {
11144         LDKRawInvoice a_conv;
11145         a_conv.inner = (void*)(a & (~1));
11146         a_conv.is_owned = (a & 1) || (a == 0);
11147         a_conv = RawInvoice_clone(&a_conv);
11148         LDKThirtyTwoBytes b_ref;
11149         CHECK((*env)->GetArrayLength(env, b) == 32);
11150         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
11151         LDKInvoiceSignature c_conv;
11152         c_conv.inner = (void*)(c & (~1));
11153         c_conv.is_owned = (c & 1) || (c == 0);
11154         c_conv = InvoiceSignature_clone(&c_conv);
11155         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11156         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
11157         return (uint64_t)ret_ref;
11158 }
11159
11160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11161         if ((_res & 1) != 0) return;
11162         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
11163         FREE((void*)_res);
11164         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
11165 }
11166
11167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11168         LDKPayeePubKey o_conv;
11169         o_conv.inner = (void*)(o & (~1));
11170         o_conv.is_owned = (o & 1) || (o == 0);
11171         o_conv = PayeePubKey_clone(&o_conv);
11172         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11173         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
11174         return (uint64_t)ret_conv;
11175 }
11176
11177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11178         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11179         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11180         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
11181         return (uint64_t)ret_conv;
11182 }
11183
11184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11185         if ((_res & 1) != 0) return;
11186         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
11187         FREE((void*)_res);
11188         CResult_PayeePubKeyErrorZ_free(_res_conv);
11189 }
11190
11191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11192         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
11193         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11194         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
11195         return (uint64_t)ret_conv;
11196 }
11197
11198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11199         LDKCVec_PrivateRouteZ _res_constr;
11200         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11201         if (_res_constr.datalen > 0)
11202                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
11203         else
11204                 _res_constr.data = NULL;
11205         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11206         for (size_t o = 0; o < _res_constr.datalen; o++) {
11207                 int64_t _res_conv_14 = _res_vals[o];
11208                 LDKPrivateRoute _res_conv_14_conv;
11209                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11210                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11211                 _res_constr.data[o] = _res_conv_14_conv;
11212         }
11213         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11214         CVec_PrivateRouteZ_free(_res_constr);
11215 }
11216
11217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11218         LDKPositiveTimestamp o_conv;
11219         o_conv.inner = (void*)(o & (~1));
11220         o_conv.is_owned = (o & 1) || (o == 0);
11221         o_conv = PositiveTimestamp_clone(&o_conv);
11222         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11223         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
11224         return (uint64_t)ret_conv;
11225 }
11226
11227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11228         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11229         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11230         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
11231         return (uint64_t)ret_conv;
11232 }
11233
11234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11235         if ((_res & 1) != 0) return;
11236         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
11237         FREE((void*)_res);
11238         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11239 }
11240
11241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11242         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11243         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11244         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11245         return (uint64_t)ret_conv;
11246 }
11247
11248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
11249         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11250         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11251         return (uint64_t)ret_conv;
11252 }
11253
11254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11255         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11256         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11257         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11258         return (uint64_t)ret_conv;
11259 }
11260
11261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11262         if ((_res & 1) != 0) return;
11263         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11264         FREE((void*)_res);
11265         CResult_NoneSemanticErrorZ_free(_res_conv);
11266 }
11267
11268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11269         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11270         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11271         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11272         return (uint64_t)ret_conv;
11273 }
11274
11275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11276         LDKInvoice o_conv;
11277         o_conv.inner = (void*)(o & (~1));
11278         o_conv.is_owned = (o & 1) || (o == 0);
11279         o_conv = Invoice_clone(&o_conv);
11280         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11281         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11282         return (uint64_t)ret_conv;
11283 }
11284
11285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11286         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11287         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11288         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11289         return (uint64_t)ret_conv;
11290 }
11291
11292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11293         if ((_res & 1) != 0) return;
11294         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11295         FREE((void*)_res);
11296         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11297 }
11298
11299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11300         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11301         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11302         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11303         return (uint64_t)ret_conv;
11304 }
11305
11306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11307         LDKDescription o_conv;
11308         o_conv.inner = (void*)(o & (~1));
11309         o_conv.is_owned = (o & 1) || (o == 0);
11310         o_conv = Description_clone(&o_conv);
11311         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11312         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11313         return (uint64_t)ret_conv;
11314 }
11315
11316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11317         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11318         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11319         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11320         return (uint64_t)ret_conv;
11321 }
11322
11323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11324         if ((_res & 1) != 0) return;
11325         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11326         FREE((void*)_res);
11327         CResult_DescriptionCreationErrorZ_free(_res_conv);
11328 }
11329
11330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11331         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11332         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11333         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11334         return (uint64_t)ret_conv;
11335 }
11336
11337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11338         LDKExpiryTime o_conv;
11339         o_conv.inner = (void*)(o & (~1));
11340         o_conv.is_owned = (o & 1) || (o == 0);
11341         o_conv = ExpiryTime_clone(&o_conv);
11342         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11343         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11344         return (uint64_t)ret_conv;
11345 }
11346
11347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11348         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11349         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11350         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11351         return (uint64_t)ret_conv;
11352 }
11353
11354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11355         if ((_res & 1) != 0) return;
11356         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11357         FREE((void*)_res);
11358         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11359 }
11360
11361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11362         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11363         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11364         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11365         return (uint64_t)ret_conv;
11366 }
11367
11368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11369         LDKPrivateRoute o_conv;
11370         o_conv.inner = (void*)(o & (~1));
11371         o_conv.is_owned = (o & 1) || (o == 0);
11372         o_conv = PrivateRoute_clone(&o_conv);
11373         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11374         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11375         return (uint64_t)ret_conv;
11376 }
11377
11378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11379         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11380         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11381         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11382         return (uint64_t)ret_conv;
11383 }
11384
11385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11386         if ((_res & 1) != 0) return;
11387         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11388         FREE((void*)_res);
11389         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11390 }
11391
11392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11393         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11394         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11395         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11396         return (uint64_t)ret_conv;
11397 }
11398
11399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11400         LDKStr o_conv = java_to_owned_str(env, o);
11401         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11402         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11403         return (uint64_t)ret_conv;
11404 }
11405
11406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11407         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11408         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11409         *ret_conv = CResult_StringErrorZ_err(e_conv);
11410         return (uint64_t)ret_conv;
11411 }
11412
11413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11414         if ((_res & 1) != 0) return;
11415         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11416         FREE((void*)_res);
11417         CResult_StringErrorZ_free(_res_conv);
11418 }
11419
11420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11421         LDKChannelMonitorUpdate o_conv;
11422         o_conv.inner = (void*)(o & (~1));
11423         o_conv.is_owned = (o & 1) || (o == 0);
11424         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11425         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11426         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11427         return (uint64_t)ret_conv;
11428 }
11429
11430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11431         LDKDecodeError e_conv;
11432         e_conv.inner = (void*)(e & (~1));
11433         e_conv.is_owned = (e & 1) || (e == 0);
11434         e_conv = DecodeError_clone(&e_conv);
11435         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11436         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11437         return (uint64_t)ret_conv;
11438 }
11439
11440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11441         if ((_res & 1) != 0) return;
11442         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11443         FREE((void*)_res);
11444         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11445 }
11446
11447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11448         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11449         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11450         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11451         return (uint64_t)ret_conv;
11452 }
11453
11454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11455         LDKHTLCUpdate o_conv;
11456         o_conv.inner = (void*)(o & (~1));
11457         o_conv.is_owned = (o & 1) || (o == 0);
11458         o_conv = HTLCUpdate_clone(&o_conv);
11459         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11460         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11461         return (uint64_t)ret_conv;
11462 }
11463
11464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11465         LDKDecodeError e_conv;
11466         e_conv.inner = (void*)(e & (~1));
11467         e_conv.is_owned = (e & 1) || (e == 0);
11468         e_conv = DecodeError_clone(&e_conv);
11469         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11470         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11471         return (uint64_t)ret_conv;
11472 }
11473
11474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11475         if ((_res & 1) != 0) return;
11476         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11477         FREE((void*)_res);
11478         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11479 }
11480
11481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11482         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11483         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11484         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11485         return (uint64_t)ret_conv;
11486 }
11487
11488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11489         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11490         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11491         return (uint64_t)ret_conv;
11492 }
11493
11494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11495         LDKMonitorUpdateError e_conv;
11496         e_conv.inner = (void*)(e & (~1));
11497         e_conv.is_owned = (e & 1) || (e == 0);
11498         e_conv = MonitorUpdateError_clone(&e_conv);
11499         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11500         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11501         return (uint64_t)ret_conv;
11502 }
11503
11504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11505         if ((_res & 1) != 0) return;
11506         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11507         FREE((void*)_res);
11508         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11509 }
11510
11511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11512         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11513         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11514         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11515         return (uint64_t)ret_conv;
11516 }
11517
11518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11519         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11520         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11521         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11522         return (uint64_t)ret_ref;
11523 }
11524
11525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11526         LDKOutPoint a_conv;
11527         a_conv.inner = (void*)(a & (~1));
11528         a_conv.is_owned = (a & 1) || (a == 0);
11529         a_conv = OutPoint_clone(&a_conv);
11530         LDKCVec_u8Z b_ref;
11531         b_ref.datalen = (*env)->GetArrayLength(env, b);
11532         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11533         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11534         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11535         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11536         return (uint64_t)ret_ref;
11537 }
11538
11539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11540         if ((_res & 1) != 0) return;
11541         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11542         FREE((void*)_res);
11543         C2Tuple_OutPointScriptZ_free(_res_conv);
11544 }
11545
11546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11547         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11548         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11549         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11550         return (uint64_t)ret_ref;
11551 }
11552
11553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11554         LDKCVec_u8Z b_ref;
11555         b_ref.datalen = (*env)->GetArrayLength(env, b);
11556         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11557         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11558         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11559         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11560         return (uint64_t)ret_ref;
11561 }
11562
11563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11564         if ((_res & 1) != 0) return;
11565         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11566         FREE((void*)_res);
11567         C2Tuple_u32ScriptZ_free(_res_conv);
11568 }
11569
11570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11571         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11572         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11573         if (_res_constr.datalen > 0)
11574                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11575         else
11576                 _res_constr.data = NULL;
11577         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11578         for (size_t b = 0; b < _res_constr.datalen; b++) {
11579                 int64_t _res_conv_27 = _res_vals[b];
11580                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11581                 FREE((void*)_res_conv_27);
11582                 _res_constr.data[b] = _res_conv_27_conv;
11583         }
11584         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11585         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11586 }
11587
11588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11589         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11590         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11591         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11592         return (uint64_t)ret_ref;
11593 }
11594
11595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11596         LDKThirtyTwoBytes a_ref;
11597         CHECK((*env)->GetArrayLength(env, a) == 32);
11598         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11599         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11600         b_constr.datalen = (*env)->GetArrayLength(env, b);
11601         if (b_constr.datalen > 0)
11602                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11603         else
11604                 b_constr.data = NULL;
11605         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11606         for (size_t b = 0; b < b_constr.datalen; b++) {
11607                 int64_t b_conv_27 = b_vals[b];
11608                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11609                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11610                 b_constr.data[b] = b_conv_27_conv;
11611         }
11612         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11613         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11614         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11615         return (uint64_t)ret_ref;
11616 }
11617
11618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11619         if ((_res & 1) != 0) return;
11620         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11621         FREE((void*)_res);
11622         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11623 }
11624
11625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11626         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11627         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11628         if (_res_constr.datalen > 0)
11629                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11630         else
11631                 _res_constr.data = NULL;
11632         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11633         for (size_t v = 0; v < _res_constr.datalen; v++) {
11634                 int64_t _res_conv_47 = _res_vals[v];
11635                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11636                 FREE((void*)_res_conv_47);
11637                 _res_constr.data[v] = _res_conv_47_conv;
11638         }
11639         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11640         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11641 }
11642
11643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11644         LDKCVec_EventZ _res_constr;
11645         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11646         if (_res_constr.datalen > 0)
11647                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11648         else
11649                 _res_constr.data = NULL;
11650         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11651         for (size_t h = 0; h < _res_constr.datalen; h++) {
11652                 int64_t _res_conv_7 = _res_vals[h];
11653                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11654                 FREE((void*)_res_conv_7);
11655                 _res_constr.data[h] = _res_conv_7_conv;
11656         }
11657         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11658         CVec_EventZ_free(_res_constr);
11659 }
11660
11661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11662         LDKCVec_TransactionZ _res_constr;
11663         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11664         if (_res_constr.datalen > 0)
11665                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11666         else
11667                 _res_constr.data = NULL;
11668         for (size_t i = 0; i < _res_constr.datalen; i++) {
11669                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11670                 LDKTransaction _res_conv_8_ref;
11671                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11672                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11673                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11674                 _res_conv_8_ref.data_is_owned = true;
11675                 _res_constr.data[i] = _res_conv_8_ref;
11676         }
11677         CVec_TransactionZ_free(_res_constr);
11678 }
11679
11680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11681         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11682         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11683         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11684         return (uint64_t)ret_ref;
11685 }
11686
11687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11688         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11689         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11690         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11691         return (uint64_t)ret_ref;
11692 }
11693
11694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11695         if ((_res & 1) != 0) return;
11696         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11697         FREE((void*)_res);
11698         C2Tuple_u32TxOutZ_free(_res_conv);
11699 }
11700
11701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11702         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11703         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11704         if (_res_constr.datalen > 0)
11705                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11706         else
11707                 _res_constr.data = NULL;
11708         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11709         for (size_t a = 0; a < _res_constr.datalen; a++) {
11710                 int64_t _res_conv_26 = _res_vals[a];
11711                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11712                 FREE((void*)_res_conv_26);
11713                 _res_constr.data[a] = _res_conv_26_conv;
11714         }
11715         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11716         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11717 }
11718
11719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11720         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11721         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11722         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11723         return (uint64_t)ret_ref;
11724 }
11725
11726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11727         LDKThirtyTwoBytes a_ref;
11728         CHECK((*env)->GetArrayLength(env, a) == 32);
11729         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11730         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11731         b_constr.datalen = (*env)->GetArrayLength(env, b);
11732         if (b_constr.datalen > 0)
11733                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11734         else
11735                 b_constr.data = NULL;
11736         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11737         for (size_t a = 0; a < b_constr.datalen; a++) {
11738                 int64_t b_conv_26 = b_vals[a];
11739                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11740                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11741                 b_constr.data[a] = b_conv_26_conv;
11742         }
11743         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11744         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11745         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11746         return (uint64_t)ret_ref;
11747 }
11748
11749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11750         if ((_res & 1) != 0) return;
11751         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11752         FREE((void*)_res);
11753         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11754 }
11755
11756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11757         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11758         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11759         if (_res_constr.datalen > 0)
11760                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11761         else
11762                 _res_constr.data = NULL;
11763         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11764         for (size_t u = 0; u < _res_constr.datalen; u++) {
11765                 int64_t _res_conv_46 = _res_vals[u];
11766                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11767                 FREE((void*)_res_conv_46);
11768                 _res_constr.data[u] = _res_conv_46_conv;
11769         }
11770         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11771         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11772 }
11773
11774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11775         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11776         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11777         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11778         return (uint64_t)ret_conv;
11779 }
11780
11781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11782         LDKDecodeError e_conv;
11783         e_conv.inner = (void*)(e & (~1));
11784         e_conv.is_owned = (e & 1) || (e == 0);
11785         e_conv = DecodeError_clone(&e_conv);
11786         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11787         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11788         return (uint64_t)ret_conv;
11789 }
11790
11791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11792         if ((_res & 1) != 0) return;
11793         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11794         FREE((void*)_res);
11795         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11796 }
11797
11798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11799         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11800         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11801         return (uint64_t)ret_conv;
11802 }
11803
11804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11805         LDKLightningError e_conv;
11806         e_conv.inner = (void*)(e & (~1));
11807         e_conv.is_owned = (e & 1) || (e == 0);
11808         e_conv = LightningError_clone(&e_conv);
11809         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11810         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11811         return (uint64_t)ret_conv;
11812 }
11813
11814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11815         if ((_res & 1) != 0) return;
11816         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11817         FREE((void*)_res);
11818         CResult_boolLightningErrorZ_free(_res_conv);
11819 }
11820
11821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11822         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11823         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11824         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11825         return (uint64_t)ret_conv;
11826 }
11827
11828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11829         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11830         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11831         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11832         return (uint64_t)ret_ref;
11833 }
11834
11835 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) {
11836         LDKChannelAnnouncement a_conv;
11837         a_conv.inner = (void*)(a & (~1));
11838         a_conv.is_owned = (a & 1) || (a == 0);
11839         a_conv = ChannelAnnouncement_clone(&a_conv);
11840         LDKChannelUpdate b_conv;
11841         b_conv.inner = (void*)(b & (~1));
11842         b_conv.is_owned = (b & 1) || (b == 0);
11843         b_conv = ChannelUpdate_clone(&b_conv);
11844         LDKChannelUpdate c_conv;
11845         c_conv.inner = (void*)(c & (~1));
11846         c_conv.is_owned = (c & 1) || (c == 0);
11847         c_conv = ChannelUpdate_clone(&c_conv);
11848         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11849         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11850         return (uint64_t)ret_ref;
11851 }
11852
11853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11854         if ((_res & 1) != 0) return;
11855         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11856         FREE((void*)_res);
11857         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11858 }
11859
11860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11861         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11862         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11863         if (_res_constr.datalen > 0)
11864                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11865         else
11866                 _res_constr.data = NULL;
11867         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11868         for (size_t l = 0; l < _res_constr.datalen; l++) {
11869                 int64_t _res_conv_63 = _res_vals[l];
11870                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11871                 FREE((void*)_res_conv_63);
11872                 _res_constr.data[l] = _res_conv_63_conv;
11873         }
11874         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11875         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11876 }
11877
11878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11879         LDKCVec_NodeAnnouncementZ _res_constr;
11880         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11881         if (_res_constr.datalen > 0)
11882                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11883         else
11884                 _res_constr.data = NULL;
11885         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11886         for (size_t s = 0; s < _res_constr.datalen; s++) {
11887                 int64_t _res_conv_18 = _res_vals[s];
11888                 LDKNodeAnnouncement _res_conv_18_conv;
11889                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11890                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11891                 _res_constr.data[s] = _res_conv_18_conv;
11892         }
11893         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11894         CVec_NodeAnnouncementZ_free(_res_constr);
11895 }
11896
11897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11898         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11899         *ret_conv = CResult_NoneLightningErrorZ_ok();
11900         return (uint64_t)ret_conv;
11901 }
11902
11903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11904         LDKLightningError e_conv;
11905         e_conv.inner = (void*)(e & (~1));
11906         e_conv.is_owned = (e & 1) || (e == 0);
11907         e_conv = LightningError_clone(&e_conv);
11908         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11909         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11910         return (uint64_t)ret_conv;
11911 }
11912
11913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11914         if ((_res & 1) != 0) return;
11915         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11916         FREE((void*)_res);
11917         CResult_NoneLightningErrorZ_free(_res_conv);
11918 }
11919
11920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11921         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11922         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11923         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11924         return (uint64_t)ret_conv;
11925 }
11926
11927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11928         LDKCVec_PublicKeyZ _res_constr;
11929         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11930         if (_res_constr.datalen > 0)
11931                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11932         else
11933                 _res_constr.data = NULL;
11934         for (size_t i = 0; i < _res_constr.datalen; i++) {
11935                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11936                 LDKPublicKey _res_conv_8_ref;
11937                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11938                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11939                 _res_constr.data[i] = _res_conv_8_ref;
11940         }
11941         CVec_PublicKeyZ_free(_res_constr);
11942 }
11943
11944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11945         LDKCVec_u8Z o_ref;
11946         o_ref.datalen = (*env)->GetArrayLength(env, o);
11947         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11948         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11949         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11950         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11951         return (uint64_t)ret_conv;
11952 }
11953
11954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11955         LDKPeerHandleError e_conv;
11956         e_conv.inner = (void*)(e & (~1));
11957         e_conv.is_owned = (e & 1) || (e == 0);
11958         e_conv = PeerHandleError_clone(&e_conv);
11959         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11960         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11961         return (uint64_t)ret_conv;
11962 }
11963
11964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11965         if ((_res & 1) != 0) return;
11966         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11967         FREE((void*)_res);
11968         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11969 }
11970
11971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11972         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11973         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11974         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11975         return (uint64_t)ret_conv;
11976 }
11977
11978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11979         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11980         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11981         return (uint64_t)ret_conv;
11982 }
11983
11984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11985         LDKPeerHandleError e_conv;
11986         e_conv.inner = (void*)(e & (~1));
11987         e_conv.is_owned = (e & 1) || (e == 0);
11988         e_conv = PeerHandleError_clone(&e_conv);
11989         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11990         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11991         return (uint64_t)ret_conv;
11992 }
11993
11994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11995         if ((_res & 1) != 0) return;
11996         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11997         FREE((void*)_res);
11998         CResult_NonePeerHandleErrorZ_free(_res_conv);
11999 }
12000
12001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12002         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
12003         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12004         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
12005         return (uint64_t)ret_conv;
12006 }
12007
12008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
12009         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12010         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
12011         return (uint64_t)ret_conv;
12012 }
12013
12014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12015         LDKPeerHandleError e_conv;
12016         e_conv.inner = (void*)(e & (~1));
12017         e_conv.is_owned = (e & 1) || (e == 0);
12018         e_conv = PeerHandleError_clone(&e_conv);
12019         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12020         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
12021         return (uint64_t)ret_conv;
12022 }
12023
12024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12025         if ((_res & 1) != 0) return;
12026         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
12027         FREE((void*)_res);
12028         CResult_boolPeerHandleErrorZ_free(_res_conv);
12029 }
12030
12031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12032         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
12033         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12034         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
12035         return (uint64_t)ret_conv;
12036 }
12037
12038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12039         LDKDirectionalChannelInfo o_conv;
12040         o_conv.inner = (void*)(o & (~1));
12041         o_conv.is_owned = (o & 1) || (o == 0);
12042         o_conv = DirectionalChannelInfo_clone(&o_conv);
12043         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12044         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
12045         return (uint64_t)ret_conv;
12046 }
12047
12048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12049         LDKDecodeError e_conv;
12050         e_conv.inner = (void*)(e & (~1));
12051         e_conv.is_owned = (e & 1) || (e == 0);
12052         e_conv = DecodeError_clone(&e_conv);
12053         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12054         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12055         return (uint64_t)ret_conv;
12056 }
12057
12058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12059         if ((_res & 1) != 0) return;
12060         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12061         FREE((void*)_res);
12062         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12063 }
12064
12065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12066         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12067         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12068         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12069         return (uint64_t)ret_conv;
12070 }
12071
12072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12073         LDKChannelInfo o_conv;
12074         o_conv.inner = (void*)(o & (~1));
12075         o_conv.is_owned = (o & 1) || (o == 0);
12076         o_conv = ChannelInfo_clone(&o_conv);
12077         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12078         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12079         return (uint64_t)ret_conv;
12080 }
12081
12082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12083         LDKDecodeError e_conv;
12084         e_conv.inner = (void*)(e & (~1));
12085         e_conv.is_owned = (e & 1) || (e == 0);
12086         e_conv = DecodeError_clone(&e_conv);
12087         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12088         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12089         return (uint64_t)ret_conv;
12090 }
12091
12092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12093         if ((_res & 1) != 0) return;
12094         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12095         FREE((void*)_res);
12096         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12097 }
12098
12099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12100         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12101         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12102         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12103         return (uint64_t)ret_conv;
12104 }
12105
12106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12107         LDKRoutingFees o_conv;
12108         o_conv.inner = (void*)(o & (~1));
12109         o_conv.is_owned = (o & 1) || (o == 0);
12110         o_conv = RoutingFees_clone(&o_conv);
12111         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12112         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12113         return (uint64_t)ret_conv;
12114 }
12115
12116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12117         LDKDecodeError e_conv;
12118         e_conv.inner = (void*)(e & (~1));
12119         e_conv.is_owned = (e & 1) || (e == 0);
12120         e_conv = DecodeError_clone(&e_conv);
12121         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12122         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12123         return (uint64_t)ret_conv;
12124 }
12125
12126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12127         if ((_res & 1) != 0) return;
12128         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12129         FREE((void*)_res);
12130         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12131 }
12132
12133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12134         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12135         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12136         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12137         return (uint64_t)ret_conv;
12138 }
12139
12140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12141         LDKNodeAnnouncementInfo o_conv;
12142         o_conv.inner = (void*)(o & (~1));
12143         o_conv.is_owned = (o & 1) || (o == 0);
12144         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12145         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12146         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12147         return (uint64_t)ret_conv;
12148 }
12149
12150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12151         LDKDecodeError e_conv;
12152         e_conv.inner = (void*)(e & (~1));
12153         e_conv.is_owned = (e & 1) || (e == 0);
12154         e_conv = DecodeError_clone(&e_conv);
12155         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12156         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12157         return (uint64_t)ret_conv;
12158 }
12159
12160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12161         if ((_res & 1) != 0) return;
12162         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12163         FREE((void*)_res);
12164         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12165 }
12166
12167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12168         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12169         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12170         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12171         return (uint64_t)ret_conv;
12172 }
12173
12174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12175         LDKCVec_u64Z _res_constr;
12176         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12177         if (_res_constr.datalen > 0)
12178                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12179         else
12180                 _res_constr.data = NULL;
12181         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12182         for (size_t g = 0; g < _res_constr.datalen; g++) {
12183                 int64_t _res_conv_6 = _res_vals[g];
12184                 _res_constr.data[g] = _res_conv_6;
12185         }
12186         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12187         CVec_u64Z_free(_res_constr);
12188 }
12189
12190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12191         LDKNodeInfo o_conv;
12192         o_conv.inner = (void*)(o & (~1));
12193         o_conv.is_owned = (o & 1) || (o == 0);
12194         o_conv = NodeInfo_clone(&o_conv);
12195         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12196         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12197         return (uint64_t)ret_conv;
12198 }
12199
12200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12201         LDKDecodeError e_conv;
12202         e_conv.inner = (void*)(e & (~1));
12203         e_conv.is_owned = (e & 1) || (e == 0);
12204         e_conv = DecodeError_clone(&e_conv);
12205         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12206         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12207         return (uint64_t)ret_conv;
12208 }
12209
12210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12211         if ((_res & 1) != 0) return;
12212         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
12213         FREE((void*)_res);
12214         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12215 }
12216
12217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12218         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12219         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12220         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12221         return (uint64_t)ret_conv;
12222 }
12223
12224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12225         LDKNetworkGraph o_conv;
12226         o_conv.inner = (void*)(o & (~1));
12227         o_conv.is_owned = (o & 1) || (o == 0);
12228         o_conv = NetworkGraph_clone(&o_conv);
12229         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12230         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12231         return (uint64_t)ret_conv;
12232 }
12233
12234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12235         LDKDecodeError e_conv;
12236         e_conv.inner = (void*)(e & (~1));
12237         e_conv.is_owned = (e & 1) || (e == 0);
12238         e_conv = DecodeError_clone(&e_conv);
12239         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12240         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12241         return (uint64_t)ret_conv;
12242 }
12243
12244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12245         if ((_res & 1) != 0) return;
12246         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
12247         FREE((void*)_res);
12248         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12249 }
12250
12251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12252         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12253         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12254         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12255         return (uint64_t)ret_conv;
12256 }
12257
12258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12259         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12260         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12261         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12262         return (uint64_t)ret_conv;
12263 }
12264
12265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12266         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12267         *ret_conv = CResult_NetAddressu8Z_err(e);
12268         return (uint64_t)ret_conv;
12269 }
12270
12271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12272         if ((_res & 1) != 0) return;
12273         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12274         FREE((void*)_res);
12275         CResult_NetAddressu8Z_free(_res_conv);
12276 }
12277
12278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12279         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12280         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12281         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12282         return (uint64_t)ret_conv;
12283 }
12284
12285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12286         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12287         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12288         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12289         return (uint64_t)ret_conv;
12290 }
12291
12292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12293         LDKDecodeError e_conv;
12294         e_conv.inner = (void*)(e & (~1));
12295         e_conv.is_owned = (e & 1) || (e == 0);
12296         e_conv = DecodeError_clone(&e_conv);
12297         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12298         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12299         return (uint64_t)ret_conv;
12300 }
12301
12302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12303         if ((_res & 1) != 0) return;
12304         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12305         FREE((void*)_res);
12306         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12307 }
12308
12309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12310         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12311         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12312         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12313         return (uint64_t)ret_conv;
12314 }
12315
12316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12317         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12318         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12319         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12320         return (uint64_t)ret_conv;
12321 }
12322
12323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12324         LDKDecodeError e_conv;
12325         e_conv.inner = (void*)(e & (~1));
12326         e_conv.is_owned = (e & 1) || (e == 0);
12327         e_conv = DecodeError_clone(&e_conv);
12328         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12329         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12330         return (uint64_t)ret_conv;
12331 }
12332
12333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12334         if ((_res & 1) != 0) return;
12335         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12336         FREE((void*)_res);
12337         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12338 }
12339
12340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12341         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12342         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12343         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12344         return (uint64_t)ret_conv;
12345 }
12346
12347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12348         LDKCVec_UpdateAddHTLCZ _res_constr;
12349         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12350         if (_res_constr.datalen > 0)
12351                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12352         else
12353                 _res_constr.data = NULL;
12354         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12355         for (size_t p = 0; p < _res_constr.datalen; p++) {
12356                 int64_t _res_conv_15 = _res_vals[p];
12357                 LDKUpdateAddHTLC _res_conv_15_conv;
12358                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12359                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12360                 _res_constr.data[p] = _res_conv_15_conv;
12361         }
12362         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12363         CVec_UpdateAddHTLCZ_free(_res_constr);
12364 }
12365
12366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12367         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12368         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12369         if (_res_constr.datalen > 0)
12370                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12371         else
12372                 _res_constr.data = NULL;
12373         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12374         for (size_t t = 0; t < _res_constr.datalen; t++) {
12375                 int64_t _res_conv_19 = _res_vals[t];
12376                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12377                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12378                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12379                 _res_constr.data[t] = _res_conv_19_conv;
12380         }
12381         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12382         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12383 }
12384
12385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12386         LDKCVec_UpdateFailHTLCZ _res_constr;
12387         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12388         if (_res_constr.datalen > 0)
12389                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12390         else
12391                 _res_constr.data = NULL;
12392         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12393         for (size_t q = 0; q < _res_constr.datalen; q++) {
12394                 int64_t _res_conv_16 = _res_vals[q];
12395                 LDKUpdateFailHTLC _res_conv_16_conv;
12396                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12397                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12398                 _res_constr.data[q] = _res_conv_16_conv;
12399         }
12400         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12401         CVec_UpdateFailHTLCZ_free(_res_constr);
12402 }
12403
12404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12405         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12406         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12407         if (_res_constr.datalen > 0)
12408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12409         else
12410                 _res_constr.data = NULL;
12411         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12412         for (size_t z = 0; z < _res_constr.datalen; z++) {
12413                 int64_t _res_conv_25 = _res_vals[z];
12414                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12415                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12416                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12417                 _res_constr.data[z] = _res_conv_25_conv;
12418         }
12419         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12420         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12421 }
12422
12423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12424         LDKAcceptChannel o_conv;
12425         o_conv.inner = (void*)(o & (~1));
12426         o_conv.is_owned = (o & 1) || (o == 0);
12427         o_conv = AcceptChannel_clone(&o_conv);
12428         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12429         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12430         return (uint64_t)ret_conv;
12431 }
12432
12433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12434         LDKDecodeError e_conv;
12435         e_conv.inner = (void*)(e & (~1));
12436         e_conv.is_owned = (e & 1) || (e == 0);
12437         e_conv = DecodeError_clone(&e_conv);
12438         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12439         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12440         return (uint64_t)ret_conv;
12441 }
12442
12443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12444         if ((_res & 1) != 0) return;
12445         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12446         FREE((void*)_res);
12447         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12448 }
12449
12450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12451         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12452         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12453         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12454         return (uint64_t)ret_conv;
12455 }
12456
12457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12458         LDKAnnouncementSignatures o_conv;
12459         o_conv.inner = (void*)(o & (~1));
12460         o_conv.is_owned = (o & 1) || (o == 0);
12461         o_conv = AnnouncementSignatures_clone(&o_conv);
12462         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12463         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12464         return (uint64_t)ret_conv;
12465 }
12466
12467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12468         LDKDecodeError e_conv;
12469         e_conv.inner = (void*)(e & (~1));
12470         e_conv.is_owned = (e & 1) || (e == 0);
12471         e_conv = DecodeError_clone(&e_conv);
12472         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12473         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12474         return (uint64_t)ret_conv;
12475 }
12476
12477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12478         if ((_res & 1) != 0) return;
12479         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12480         FREE((void*)_res);
12481         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12482 }
12483
12484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12485         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12486         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12487         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12488         return (uint64_t)ret_conv;
12489 }
12490
12491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12492         LDKChannelReestablish o_conv;
12493         o_conv.inner = (void*)(o & (~1));
12494         o_conv.is_owned = (o & 1) || (o == 0);
12495         o_conv = ChannelReestablish_clone(&o_conv);
12496         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12497         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12498         return (uint64_t)ret_conv;
12499 }
12500
12501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12502         LDKDecodeError e_conv;
12503         e_conv.inner = (void*)(e & (~1));
12504         e_conv.is_owned = (e & 1) || (e == 0);
12505         e_conv = DecodeError_clone(&e_conv);
12506         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12507         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12508         return (uint64_t)ret_conv;
12509 }
12510
12511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12512         if ((_res & 1) != 0) return;
12513         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12514         FREE((void*)_res);
12515         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12516 }
12517
12518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12519         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12520         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12521         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12522         return (uint64_t)ret_conv;
12523 }
12524
12525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12526         LDKClosingSigned o_conv;
12527         o_conv.inner = (void*)(o & (~1));
12528         o_conv.is_owned = (o & 1) || (o == 0);
12529         o_conv = ClosingSigned_clone(&o_conv);
12530         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12531         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12532         return (uint64_t)ret_conv;
12533 }
12534
12535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12536         LDKDecodeError e_conv;
12537         e_conv.inner = (void*)(e & (~1));
12538         e_conv.is_owned = (e & 1) || (e == 0);
12539         e_conv = DecodeError_clone(&e_conv);
12540         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12541         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12542         return (uint64_t)ret_conv;
12543 }
12544
12545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12546         if ((_res & 1) != 0) return;
12547         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12548         FREE((void*)_res);
12549         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12550 }
12551
12552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12553         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12554         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12555         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12556         return (uint64_t)ret_conv;
12557 }
12558
12559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12560         LDKClosingSignedFeeRange o_conv;
12561         o_conv.inner = (void*)(o & (~1));
12562         o_conv.is_owned = (o & 1) || (o == 0);
12563         o_conv = ClosingSignedFeeRange_clone(&o_conv);
12564         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12565         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
12566         return (uint64_t)ret_conv;
12567 }
12568
12569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12570         LDKDecodeError e_conv;
12571         e_conv.inner = (void*)(e & (~1));
12572         e_conv.is_owned = (e & 1) || (e == 0);
12573         e_conv = DecodeError_clone(&e_conv);
12574         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12575         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
12576         return (uint64_t)ret_conv;
12577 }
12578
12579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12580         if ((_res & 1) != 0) return;
12581         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12582         FREE((void*)_res);
12583         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
12584 }
12585
12586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12587         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
12588         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12589         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
12590         return (uint64_t)ret_conv;
12591 }
12592
12593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12594         LDKCommitmentSigned o_conv;
12595         o_conv.inner = (void*)(o & (~1));
12596         o_conv.is_owned = (o & 1) || (o == 0);
12597         o_conv = CommitmentSigned_clone(&o_conv);
12598         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12599         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12600         return (uint64_t)ret_conv;
12601 }
12602
12603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12604         LDKDecodeError e_conv;
12605         e_conv.inner = (void*)(e & (~1));
12606         e_conv.is_owned = (e & 1) || (e == 0);
12607         e_conv = DecodeError_clone(&e_conv);
12608         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12609         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12610         return (uint64_t)ret_conv;
12611 }
12612
12613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12614         if ((_res & 1) != 0) return;
12615         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12616         FREE((void*)_res);
12617         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12618 }
12619
12620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12621         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12622         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12623         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12624         return (uint64_t)ret_conv;
12625 }
12626
12627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12628         LDKFundingCreated o_conv;
12629         o_conv.inner = (void*)(o & (~1));
12630         o_conv.is_owned = (o & 1) || (o == 0);
12631         o_conv = FundingCreated_clone(&o_conv);
12632         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12633         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12634         return (uint64_t)ret_conv;
12635 }
12636
12637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12638         LDKDecodeError e_conv;
12639         e_conv.inner = (void*)(e & (~1));
12640         e_conv.is_owned = (e & 1) || (e == 0);
12641         e_conv = DecodeError_clone(&e_conv);
12642         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12643         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12644         return (uint64_t)ret_conv;
12645 }
12646
12647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12648         if ((_res & 1) != 0) return;
12649         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12650         FREE((void*)_res);
12651         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12652 }
12653
12654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12655         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12656         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12657         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12658         return (uint64_t)ret_conv;
12659 }
12660
12661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12662         LDKFundingSigned o_conv;
12663         o_conv.inner = (void*)(o & (~1));
12664         o_conv.is_owned = (o & 1) || (o == 0);
12665         o_conv = FundingSigned_clone(&o_conv);
12666         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12667         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12668         return (uint64_t)ret_conv;
12669 }
12670
12671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12672         LDKDecodeError e_conv;
12673         e_conv.inner = (void*)(e & (~1));
12674         e_conv.is_owned = (e & 1) || (e == 0);
12675         e_conv = DecodeError_clone(&e_conv);
12676         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12677         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12678         return (uint64_t)ret_conv;
12679 }
12680
12681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12682         if ((_res & 1) != 0) return;
12683         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12684         FREE((void*)_res);
12685         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12686 }
12687
12688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12689         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12690         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12691         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12692         return (uint64_t)ret_conv;
12693 }
12694
12695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12696         LDKFundingLocked o_conv;
12697         o_conv.inner = (void*)(o & (~1));
12698         o_conv.is_owned = (o & 1) || (o == 0);
12699         o_conv = FundingLocked_clone(&o_conv);
12700         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12701         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12702         return (uint64_t)ret_conv;
12703 }
12704
12705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12706         LDKDecodeError e_conv;
12707         e_conv.inner = (void*)(e & (~1));
12708         e_conv.is_owned = (e & 1) || (e == 0);
12709         e_conv = DecodeError_clone(&e_conv);
12710         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12711         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12712         return (uint64_t)ret_conv;
12713 }
12714
12715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12716         if ((_res & 1) != 0) return;
12717         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12718         FREE((void*)_res);
12719         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12720 }
12721
12722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12723         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12724         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12725         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12726         return (uint64_t)ret_conv;
12727 }
12728
12729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12730         LDKInit o_conv;
12731         o_conv.inner = (void*)(o & (~1));
12732         o_conv.is_owned = (o & 1) || (o == 0);
12733         o_conv = Init_clone(&o_conv);
12734         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12735         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12736         return (uint64_t)ret_conv;
12737 }
12738
12739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12740         LDKDecodeError e_conv;
12741         e_conv.inner = (void*)(e & (~1));
12742         e_conv.is_owned = (e & 1) || (e == 0);
12743         e_conv = DecodeError_clone(&e_conv);
12744         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12745         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12746         return (uint64_t)ret_conv;
12747 }
12748
12749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12750         if ((_res & 1) != 0) return;
12751         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12752         FREE((void*)_res);
12753         CResult_InitDecodeErrorZ_free(_res_conv);
12754 }
12755
12756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12757         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12758         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12759         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12760         return (uint64_t)ret_conv;
12761 }
12762
12763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12764         LDKOpenChannel o_conv;
12765         o_conv.inner = (void*)(o & (~1));
12766         o_conv.is_owned = (o & 1) || (o == 0);
12767         o_conv = OpenChannel_clone(&o_conv);
12768         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12769         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12770         return (uint64_t)ret_conv;
12771 }
12772
12773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12774         LDKDecodeError e_conv;
12775         e_conv.inner = (void*)(e & (~1));
12776         e_conv.is_owned = (e & 1) || (e == 0);
12777         e_conv = DecodeError_clone(&e_conv);
12778         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12779         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12780         return (uint64_t)ret_conv;
12781 }
12782
12783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12784         if ((_res & 1) != 0) return;
12785         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12786         FREE((void*)_res);
12787         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12788 }
12789
12790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12791         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12792         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12793         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12794         return (uint64_t)ret_conv;
12795 }
12796
12797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12798         LDKRevokeAndACK o_conv;
12799         o_conv.inner = (void*)(o & (~1));
12800         o_conv.is_owned = (o & 1) || (o == 0);
12801         o_conv = RevokeAndACK_clone(&o_conv);
12802         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12803         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12804         return (uint64_t)ret_conv;
12805 }
12806
12807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12808         LDKDecodeError e_conv;
12809         e_conv.inner = (void*)(e & (~1));
12810         e_conv.is_owned = (e & 1) || (e == 0);
12811         e_conv = DecodeError_clone(&e_conv);
12812         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12813         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12814         return (uint64_t)ret_conv;
12815 }
12816
12817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12818         if ((_res & 1) != 0) return;
12819         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12820         FREE((void*)_res);
12821         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12822 }
12823
12824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12825         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12826         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12827         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12828         return (uint64_t)ret_conv;
12829 }
12830
12831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12832         LDKShutdown o_conv;
12833         o_conv.inner = (void*)(o & (~1));
12834         o_conv.is_owned = (o & 1) || (o == 0);
12835         o_conv = Shutdown_clone(&o_conv);
12836         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12837         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12838         return (uint64_t)ret_conv;
12839 }
12840
12841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12842         LDKDecodeError e_conv;
12843         e_conv.inner = (void*)(e & (~1));
12844         e_conv.is_owned = (e & 1) || (e == 0);
12845         e_conv = DecodeError_clone(&e_conv);
12846         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12847         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12848         return (uint64_t)ret_conv;
12849 }
12850
12851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12852         if ((_res & 1) != 0) return;
12853         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12854         FREE((void*)_res);
12855         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12856 }
12857
12858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12859         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12860         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12861         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12862         return (uint64_t)ret_conv;
12863 }
12864
12865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12866         LDKUpdateFailHTLC o_conv;
12867         o_conv.inner = (void*)(o & (~1));
12868         o_conv.is_owned = (o & 1) || (o == 0);
12869         o_conv = UpdateFailHTLC_clone(&o_conv);
12870         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12871         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12872         return (uint64_t)ret_conv;
12873 }
12874
12875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12876         LDKDecodeError e_conv;
12877         e_conv.inner = (void*)(e & (~1));
12878         e_conv.is_owned = (e & 1) || (e == 0);
12879         e_conv = DecodeError_clone(&e_conv);
12880         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12881         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12882         return (uint64_t)ret_conv;
12883 }
12884
12885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12886         if ((_res & 1) != 0) return;
12887         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12888         FREE((void*)_res);
12889         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12890 }
12891
12892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12893         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12894         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12895         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12896         return (uint64_t)ret_conv;
12897 }
12898
12899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12900         LDKUpdateFailMalformedHTLC o_conv;
12901         o_conv.inner = (void*)(o & (~1));
12902         o_conv.is_owned = (o & 1) || (o == 0);
12903         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12904         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12905         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12906         return (uint64_t)ret_conv;
12907 }
12908
12909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12910         LDKDecodeError e_conv;
12911         e_conv.inner = (void*)(e & (~1));
12912         e_conv.is_owned = (e & 1) || (e == 0);
12913         e_conv = DecodeError_clone(&e_conv);
12914         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12915         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12916         return (uint64_t)ret_conv;
12917 }
12918
12919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12920         if ((_res & 1) != 0) return;
12921         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12922         FREE((void*)_res);
12923         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12924 }
12925
12926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12927         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12928         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12929         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12930         return (uint64_t)ret_conv;
12931 }
12932
12933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12934         LDKUpdateFee o_conv;
12935         o_conv.inner = (void*)(o & (~1));
12936         o_conv.is_owned = (o & 1) || (o == 0);
12937         o_conv = UpdateFee_clone(&o_conv);
12938         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12939         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12940         return (uint64_t)ret_conv;
12941 }
12942
12943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12944         LDKDecodeError e_conv;
12945         e_conv.inner = (void*)(e & (~1));
12946         e_conv.is_owned = (e & 1) || (e == 0);
12947         e_conv = DecodeError_clone(&e_conv);
12948         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12949         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12950         return (uint64_t)ret_conv;
12951 }
12952
12953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12954         if ((_res & 1) != 0) return;
12955         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12956         FREE((void*)_res);
12957         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12958 }
12959
12960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12961         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12962         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12963         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12964         return (uint64_t)ret_conv;
12965 }
12966
12967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12968         LDKUpdateFulfillHTLC o_conv;
12969         o_conv.inner = (void*)(o & (~1));
12970         o_conv.is_owned = (o & 1) || (o == 0);
12971         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12972         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12973         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12974         return (uint64_t)ret_conv;
12975 }
12976
12977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12978         LDKDecodeError e_conv;
12979         e_conv.inner = (void*)(e & (~1));
12980         e_conv.is_owned = (e & 1) || (e == 0);
12981         e_conv = DecodeError_clone(&e_conv);
12982         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12983         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12984         return (uint64_t)ret_conv;
12985 }
12986
12987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12988         if ((_res & 1) != 0) return;
12989         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12990         FREE((void*)_res);
12991         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12992 }
12993
12994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12995         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12996         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12997         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12998         return (uint64_t)ret_conv;
12999 }
13000
13001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13002         LDKUpdateAddHTLC o_conv;
13003         o_conv.inner = (void*)(o & (~1));
13004         o_conv.is_owned = (o & 1) || (o == 0);
13005         o_conv = UpdateAddHTLC_clone(&o_conv);
13006         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13007         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
13008         return (uint64_t)ret_conv;
13009 }
13010
13011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13012         LDKDecodeError e_conv;
13013         e_conv.inner = (void*)(e & (~1));
13014         e_conv.is_owned = (e & 1) || (e == 0);
13015         e_conv = DecodeError_clone(&e_conv);
13016         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13017         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
13018         return (uint64_t)ret_conv;
13019 }
13020
13021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13022         if ((_res & 1) != 0) return;
13023         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
13024         FREE((void*)_res);
13025         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
13026 }
13027
13028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13029         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
13030         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13031         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
13032         return (uint64_t)ret_conv;
13033 }
13034
13035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13036         LDKPing o_conv;
13037         o_conv.inner = (void*)(o & (~1));
13038         o_conv.is_owned = (o & 1) || (o == 0);
13039         o_conv = Ping_clone(&o_conv);
13040         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13041         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
13042         return (uint64_t)ret_conv;
13043 }
13044
13045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13046         LDKDecodeError e_conv;
13047         e_conv.inner = (void*)(e & (~1));
13048         e_conv.is_owned = (e & 1) || (e == 0);
13049         e_conv = DecodeError_clone(&e_conv);
13050         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13051         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
13052         return (uint64_t)ret_conv;
13053 }
13054
13055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13056         if ((_res & 1) != 0) return;
13057         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
13058         FREE((void*)_res);
13059         CResult_PingDecodeErrorZ_free(_res_conv);
13060 }
13061
13062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13063         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
13064         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13065         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
13066         return (uint64_t)ret_conv;
13067 }
13068
13069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13070         LDKPong o_conv;
13071         o_conv.inner = (void*)(o & (~1));
13072         o_conv.is_owned = (o & 1) || (o == 0);
13073         o_conv = Pong_clone(&o_conv);
13074         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13075         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
13076         return (uint64_t)ret_conv;
13077 }
13078
13079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13080         LDKDecodeError e_conv;
13081         e_conv.inner = (void*)(e & (~1));
13082         e_conv.is_owned = (e & 1) || (e == 0);
13083         e_conv = DecodeError_clone(&e_conv);
13084         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13085         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
13086         return (uint64_t)ret_conv;
13087 }
13088
13089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13090         if ((_res & 1) != 0) return;
13091         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
13092         FREE((void*)_res);
13093         CResult_PongDecodeErrorZ_free(_res_conv);
13094 }
13095
13096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13097         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
13098         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13099         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
13100         return (uint64_t)ret_conv;
13101 }
13102
13103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13104         LDKUnsignedChannelAnnouncement o_conv;
13105         o_conv.inner = (void*)(o & (~1));
13106         o_conv.is_owned = (o & 1) || (o == 0);
13107         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
13108         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13109         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
13110         return (uint64_t)ret_conv;
13111 }
13112
13113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13114         LDKDecodeError e_conv;
13115         e_conv.inner = (void*)(e & (~1));
13116         e_conv.is_owned = (e & 1) || (e == 0);
13117         e_conv = DecodeError_clone(&e_conv);
13118         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13119         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
13120         return (uint64_t)ret_conv;
13121 }
13122
13123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13124         if ((_res & 1) != 0) return;
13125         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13126         FREE((void*)_res);
13127         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
13128 }
13129
13130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13131         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13132         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13133         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13134         return (uint64_t)ret_conv;
13135 }
13136
13137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13138         LDKChannelAnnouncement o_conv;
13139         o_conv.inner = (void*)(o & (~1));
13140         o_conv.is_owned = (o & 1) || (o == 0);
13141         o_conv = ChannelAnnouncement_clone(&o_conv);
13142         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13143         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
13144         return (uint64_t)ret_conv;
13145 }
13146
13147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13148         LDKDecodeError e_conv;
13149         e_conv.inner = (void*)(e & (~1));
13150         e_conv.is_owned = (e & 1) || (e == 0);
13151         e_conv = DecodeError_clone(&e_conv);
13152         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13153         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
13154         return (uint64_t)ret_conv;
13155 }
13156
13157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13158         if ((_res & 1) != 0) return;
13159         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13160         FREE((void*)_res);
13161         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
13162 }
13163
13164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13165         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13166         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13167         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13168         return (uint64_t)ret_conv;
13169 }
13170
13171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13172         LDKUnsignedChannelUpdate o_conv;
13173         o_conv.inner = (void*)(o & (~1));
13174         o_conv.is_owned = (o & 1) || (o == 0);
13175         o_conv = UnsignedChannelUpdate_clone(&o_conv);
13176         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13177         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
13178         return (uint64_t)ret_conv;
13179 }
13180
13181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13182         LDKDecodeError e_conv;
13183         e_conv.inner = (void*)(e & (~1));
13184         e_conv.is_owned = (e & 1) || (e == 0);
13185         e_conv = DecodeError_clone(&e_conv);
13186         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13187         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
13188         return (uint64_t)ret_conv;
13189 }
13190
13191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13192         if ((_res & 1) != 0) return;
13193         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13194         FREE((void*)_res);
13195         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
13196 }
13197
13198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13199         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
13200         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13201         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
13202         return (uint64_t)ret_conv;
13203 }
13204
13205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13206         LDKChannelUpdate o_conv;
13207         o_conv.inner = (void*)(o & (~1));
13208         o_conv.is_owned = (o & 1) || (o == 0);
13209         o_conv = ChannelUpdate_clone(&o_conv);
13210         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13211         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
13212         return (uint64_t)ret_conv;
13213 }
13214
13215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13216         LDKDecodeError e_conv;
13217         e_conv.inner = (void*)(e & (~1));
13218         e_conv.is_owned = (e & 1) || (e == 0);
13219         e_conv = DecodeError_clone(&e_conv);
13220         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13221         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
13222         return (uint64_t)ret_conv;
13223 }
13224
13225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13226         if ((_res & 1) != 0) return;
13227         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
13228         FREE((void*)_res);
13229         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
13230 }
13231
13232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13233         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
13234         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13235         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
13236         return (uint64_t)ret_conv;
13237 }
13238
13239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13240         LDKErrorMessage o_conv;
13241         o_conv.inner = (void*)(o & (~1));
13242         o_conv.is_owned = (o & 1) || (o == 0);
13243         o_conv = ErrorMessage_clone(&o_conv);
13244         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13245         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
13246         return (uint64_t)ret_conv;
13247 }
13248
13249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13250         LDKDecodeError e_conv;
13251         e_conv.inner = (void*)(e & (~1));
13252         e_conv.is_owned = (e & 1) || (e == 0);
13253         e_conv = DecodeError_clone(&e_conv);
13254         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13255         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
13256         return (uint64_t)ret_conv;
13257 }
13258
13259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13260         if ((_res & 1) != 0) return;
13261         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
13262         FREE((void*)_res);
13263         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
13264 }
13265
13266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13267         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13268         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13269         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13270         return (uint64_t)ret_conv;
13271 }
13272
13273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13274         LDKUnsignedNodeAnnouncement o_conv;
13275         o_conv.inner = (void*)(o & (~1));
13276         o_conv.is_owned = (o & 1) || (o == 0);
13277         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13278         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13279         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13280         return (uint64_t)ret_conv;
13281 }
13282
13283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13284         LDKDecodeError e_conv;
13285         e_conv.inner = (void*)(e & (~1));
13286         e_conv.is_owned = (e & 1) || (e == 0);
13287         e_conv = DecodeError_clone(&e_conv);
13288         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13289         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13290         return (uint64_t)ret_conv;
13291 }
13292
13293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13294         if ((_res & 1) != 0) return;
13295         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13296         FREE((void*)_res);
13297         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13298 }
13299
13300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13301         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13302         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13303         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13304         return (uint64_t)ret_conv;
13305 }
13306
13307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13308         LDKNodeAnnouncement o_conv;
13309         o_conv.inner = (void*)(o & (~1));
13310         o_conv.is_owned = (o & 1) || (o == 0);
13311         o_conv = NodeAnnouncement_clone(&o_conv);
13312         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13313         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13314         return (uint64_t)ret_conv;
13315 }
13316
13317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13318         LDKDecodeError e_conv;
13319         e_conv.inner = (void*)(e & (~1));
13320         e_conv.is_owned = (e & 1) || (e == 0);
13321         e_conv = DecodeError_clone(&e_conv);
13322         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13323         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13324         return (uint64_t)ret_conv;
13325 }
13326
13327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13328         if ((_res & 1) != 0) return;
13329         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13330         FREE((void*)_res);
13331         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13332 }
13333
13334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13335         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13336         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13337         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13338         return (uint64_t)ret_conv;
13339 }
13340
13341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13342         LDKQueryShortChannelIds o_conv;
13343         o_conv.inner = (void*)(o & (~1));
13344         o_conv.is_owned = (o & 1) || (o == 0);
13345         o_conv = QueryShortChannelIds_clone(&o_conv);
13346         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13347         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13348         return (uint64_t)ret_conv;
13349 }
13350
13351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13352         LDKDecodeError e_conv;
13353         e_conv.inner = (void*)(e & (~1));
13354         e_conv.is_owned = (e & 1) || (e == 0);
13355         e_conv = DecodeError_clone(&e_conv);
13356         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13357         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13358         return (uint64_t)ret_conv;
13359 }
13360
13361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13362         if ((_res & 1) != 0) return;
13363         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13364         FREE((void*)_res);
13365         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13366 }
13367
13368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13369         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13370         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13371         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13372         return (uint64_t)ret_conv;
13373 }
13374
13375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13376         LDKReplyShortChannelIdsEnd o_conv;
13377         o_conv.inner = (void*)(o & (~1));
13378         o_conv.is_owned = (o & 1) || (o == 0);
13379         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13380         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13381         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13382         return (uint64_t)ret_conv;
13383 }
13384
13385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13386         LDKDecodeError e_conv;
13387         e_conv.inner = (void*)(e & (~1));
13388         e_conv.is_owned = (e & 1) || (e == 0);
13389         e_conv = DecodeError_clone(&e_conv);
13390         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13391         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13392         return (uint64_t)ret_conv;
13393 }
13394
13395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13396         if ((_res & 1) != 0) return;
13397         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13398         FREE((void*)_res);
13399         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13400 }
13401
13402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13403         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13404         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13405         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13406         return (uint64_t)ret_conv;
13407 }
13408
13409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13410         LDKQueryChannelRange o_conv;
13411         o_conv.inner = (void*)(o & (~1));
13412         o_conv.is_owned = (o & 1) || (o == 0);
13413         o_conv = QueryChannelRange_clone(&o_conv);
13414         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13415         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13416         return (uint64_t)ret_conv;
13417 }
13418
13419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13420         LDKDecodeError e_conv;
13421         e_conv.inner = (void*)(e & (~1));
13422         e_conv.is_owned = (e & 1) || (e == 0);
13423         e_conv = DecodeError_clone(&e_conv);
13424         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13425         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13426         return (uint64_t)ret_conv;
13427 }
13428
13429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13430         if ((_res & 1) != 0) return;
13431         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13432         FREE((void*)_res);
13433         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13434 }
13435
13436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13437         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13438         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13439         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13440         return (uint64_t)ret_conv;
13441 }
13442
13443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13444         LDKReplyChannelRange o_conv;
13445         o_conv.inner = (void*)(o & (~1));
13446         o_conv.is_owned = (o & 1) || (o == 0);
13447         o_conv = ReplyChannelRange_clone(&o_conv);
13448         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13449         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13450         return (uint64_t)ret_conv;
13451 }
13452
13453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13454         LDKDecodeError e_conv;
13455         e_conv.inner = (void*)(e & (~1));
13456         e_conv.is_owned = (e & 1) || (e == 0);
13457         e_conv = DecodeError_clone(&e_conv);
13458         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13459         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13460         return (uint64_t)ret_conv;
13461 }
13462
13463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13464         if ((_res & 1) != 0) return;
13465         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13466         FREE((void*)_res);
13467         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13468 }
13469
13470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13471         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13472         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13473         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13474         return (uint64_t)ret_conv;
13475 }
13476
13477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13478         LDKGossipTimestampFilter o_conv;
13479         o_conv.inner = (void*)(o & (~1));
13480         o_conv.is_owned = (o & 1) || (o == 0);
13481         o_conv = GossipTimestampFilter_clone(&o_conv);
13482         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13483         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13484         return (uint64_t)ret_conv;
13485 }
13486
13487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13488         LDKDecodeError e_conv;
13489         e_conv.inner = (void*)(e & (~1));
13490         e_conv.is_owned = (e & 1) || (e == 0);
13491         e_conv = DecodeError_clone(&e_conv);
13492         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13493         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13494         return (uint64_t)ret_conv;
13495 }
13496
13497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13498         if ((_res & 1) != 0) return;
13499         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13500         FREE((void*)_res);
13501         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13502 }
13503
13504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13505         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13506         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13507         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13508         return (uint64_t)ret_conv;
13509 }
13510
13511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13512         LDKInvoice o_conv;
13513         o_conv.inner = (void*)(o & (~1));
13514         o_conv.is_owned = (o & 1) || (o == 0);
13515         o_conv = Invoice_clone(&o_conv);
13516         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13517         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13518         return (uint64_t)ret_conv;
13519 }
13520
13521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13522         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13523         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13524         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13525         return (uint64_t)ret_conv;
13526 }
13527
13528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13529         if ((_res & 1) != 0) return;
13530         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13531         FREE((void*)_res);
13532         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13533 }
13534
13535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13536         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13537         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13538         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13539         return (uint64_t)ret_conv;
13540 }
13541
13542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13543         if ((this_ptr & 1) != 0) return;
13544         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
13545         FREE((void*)this_ptr);
13546         PaymentPurpose_free(this_ptr_conv);
13547 }
13548
13549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13550         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
13551         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13552         *ret_copy = PaymentPurpose_clone(orig_conv);
13553         uint64_t ret_ref = (uint64_t)ret_copy;
13554         return ret_ref;
13555 }
13556
13557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
13558         LDKThirtyTwoBytes payment_preimage_ref;
13559         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13560         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13561         LDKThirtyTwoBytes payment_secret_ref;
13562         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13563         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13564         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13565         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
13566         uint64_t ret_ref = (uint64_t)ret_copy;
13567         return ret_ref;
13568 }
13569
13570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
13571         LDKThirtyTwoBytes a_ref;
13572         CHECK((*env)->GetArrayLength(env, a) == 32);
13573         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13574         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13575         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
13576         uint64_t ret_ref = (uint64_t)ret_copy;
13577         return ret_ref;
13578 }
13579
13580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13581         if ((this_ptr & 1) != 0) return;
13582         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13583         FREE((void*)this_ptr);
13584         Event_free(this_ptr_conv);
13585 }
13586
13587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13588         LDKEvent* orig_conv = (LDKEvent*)orig;
13589         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13590         *ret_copy = Event_clone(orig_conv);
13591         uint64_t ret_ref = (uint64_t)ret_copy;
13592         return ret_ref;
13593 }
13594
13595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
13596         LDKThirtyTwoBytes temporary_channel_id_ref;
13597         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
13598         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
13599         LDKCVec_u8Z output_script_ref;
13600         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
13601         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
13602         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
13603         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13604         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
13605         uint64_t ret_ref = (uint64_t)ret_copy;
13606         return ret_ref;
13607 }
13608
13609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
13610         LDKThirtyTwoBytes payment_hash_ref;
13611         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13612         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13613         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
13614         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13615         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
13616         uint64_t ret_ref = (uint64_t)ret_copy;
13617         return ret_ref;
13618 }
13619
13620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage) {
13621         LDKThirtyTwoBytes payment_preimage_ref;
13622         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13623         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13624         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13625         *ret_copy = Event_payment_sent(payment_preimage_ref);
13626         uint64_t ret_ref = (uint64_t)ret_copy;
13627         return ret_ref;
13628 }
13629
13630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest) {
13631         LDKThirtyTwoBytes payment_hash_ref;
13632         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13633         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13634         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13635         *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest);
13636         uint64_t ret_ref = (uint64_t)ret_copy;
13637         return ret_ref;
13638 }
13639
13640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
13641         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13642         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
13643         uint64_t ret_ref = (uint64_t)ret_copy;
13644         return ret_ref;
13645 }
13646
13647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
13648         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
13649         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
13650         if (outputs_constr.datalen > 0)
13651                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13652         else
13653                 outputs_constr.data = NULL;
13654         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
13655         for (size_t b = 0; b < outputs_constr.datalen; b++) {
13656                 int64_t outputs_conv_27 = outputs_vals[b];
13657                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
13658                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
13659                 outputs_constr.data[b] = outputs_conv_27_conv;
13660         }
13661         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
13662         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13663         *ret_copy = Event_spendable_outputs(outputs_constr);
13664         uint64_t ret_ref = (uint64_t)ret_copy;
13665         return ret_ref;
13666 }
13667
13668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
13669         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
13670         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13671         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
13672         uint64_t ret_ref = (uint64_t)ret_copy;
13673         return ret_ref;
13674 }
13675
13676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13677         LDKEvent* obj_conv = (LDKEvent*)obj;
13678         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13679         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13680         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13681         CVec_u8Z_free(ret_var);
13682         return ret_arr;
13683 }
13684
13685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13686         if ((this_ptr & 1) != 0) return;
13687         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13688         FREE((void*)this_ptr);
13689         MessageSendEvent_free(this_ptr_conv);
13690 }
13691
13692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13693         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13694         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13695         *ret_copy = MessageSendEvent_clone(orig_conv);
13696         uint64_t ret_ref = (uint64_t)ret_copy;
13697         return ret_ref;
13698 }
13699
13700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13701         LDKPublicKey node_id_ref;
13702         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13703         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13704         LDKAcceptChannel msg_conv;
13705         msg_conv.inner = (void*)(msg & (~1));
13706         msg_conv.is_owned = (msg & 1) || (msg == 0);
13707         msg_conv = AcceptChannel_clone(&msg_conv);
13708         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13709         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
13710         uint64_t ret_ref = (uint64_t)ret_copy;
13711         return ret_ref;
13712 }
13713
13714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13715         LDKPublicKey node_id_ref;
13716         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13717         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13718         LDKOpenChannel msg_conv;
13719         msg_conv.inner = (void*)(msg & (~1));
13720         msg_conv.is_owned = (msg & 1) || (msg == 0);
13721         msg_conv = OpenChannel_clone(&msg_conv);
13722         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13723         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
13724         uint64_t ret_ref = (uint64_t)ret_copy;
13725         return ret_ref;
13726 }
13727
13728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13729         LDKPublicKey node_id_ref;
13730         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13731         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13732         LDKFundingCreated msg_conv;
13733         msg_conv.inner = (void*)(msg & (~1));
13734         msg_conv.is_owned = (msg & 1) || (msg == 0);
13735         msg_conv = FundingCreated_clone(&msg_conv);
13736         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13737         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
13738         uint64_t ret_ref = (uint64_t)ret_copy;
13739         return ret_ref;
13740 }
13741
13742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13743         LDKPublicKey node_id_ref;
13744         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13745         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13746         LDKFundingSigned msg_conv;
13747         msg_conv.inner = (void*)(msg & (~1));
13748         msg_conv.is_owned = (msg & 1) || (msg == 0);
13749         msg_conv = FundingSigned_clone(&msg_conv);
13750         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13751         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
13752         uint64_t ret_ref = (uint64_t)ret_copy;
13753         return ret_ref;
13754 }
13755
13756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13757         LDKPublicKey node_id_ref;
13758         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13759         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13760         LDKFundingLocked msg_conv;
13761         msg_conv.inner = (void*)(msg & (~1));
13762         msg_conv.is_owned = (msg & 1) || (msg == 0);
13763         msg_conv = FundingLocked_clone(&msg_conv);
13764         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13765         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
13766         uint64_t ret_ref = (uint64_t)ret_copy;
13767         return ret_ref;
13768 }
13769
13770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13771         LDKPublicKey node_id_ref;
13772         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13773         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13774         LDKAnnouncementSignatures msg_conv;
13775         msg_conv.inner = (void*)(msg & (~1));
13776         msg_conv.is_owned = (msg & 1) || (msg == 0);
13777         msg_conv = AnnouncementSignatures_clone(&msg_conv);
13778         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13779         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
13780         uint64_t ret_ref = (uint64_t)ret_copy;
13781         return ret_ref;
13782 }
13783
13784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
13785         LDKPublicKey node_id_ref;
13786         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13787         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13788         LDKCommitmentUpdate updates_conv;
13789         updates_conv.inner = (void*)(updates & (~1));
13790         updates_conv.is_owned = (updates & 1) || (updates == 0);
13791         updates_conv = CommitmentUpdate_clone(&updates_conv);
13792         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13793         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
13794         uint64_t ret_ref = (uint64_t)ret_copy;
13795         return ret_ref;
13796 }
13797
13798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1revoke_1and_1ack(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13799         LDKPublicKey node_id_ref;
13800         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13801         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13802         LDKRevokeAndACK msg_conv;
13803         msg_conv.inner = (void*)(msg & (~1));
13804         msg_conv.is_owned = (msg & 1) || (msg == 0);
13805         msg_conv = RevokeAndACK_clone(&msg_conv);
13806         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13807         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
13808         uint64_t ret_ref = (uint64_t)ret_copy;
13809         return ret_ref;
13810 }
13811
13812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13813         LDKPublicKey node_id_ref;
13814         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13815         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13816         LDKClosingSigned msg_conv;
13817         msg_conv.inner = (void*)(msg & (~1));
13818         msg_conv.is_owned = (msg & 1) || (msg == 0);
13819         msg_conv = ClosingSigned_clone(&msg_conv);
13820         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13821         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
13822         uint64_t ret_ref = (uint64_t)ret_copy;
13823         return ret_ref;
13824 }
13825
13826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13827         LDKPublicKey node_id_ref;
13828         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13829         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13830         LDKShutdown msg_conv;
13831         msg_conv.inner = (void*)(msg & (~1));
13832         msg_conv.is_owned = (msg & 1) || (msg == 0);
13833         msg_conv = Shutdown_clone(&msg_conv);
13834         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13835         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
13836         uint64_t ret_ref = (uint64_t)ret_copy;
13837         return ret_ref;
13838 }
13839
13840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13841         LDKPublicKey node_id_ref;
13842         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13843         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13844         LDKChannelReestablish msg_conv;
13845         msg_conv.inner = (void*)(msg & (~1));
13846         msg_conv.is_owned = (msg & 1) || (msg == 0);
13847         msg_conv = ChannelReestablish_clone(&msg_conv);
13848         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13849         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
13850         uint64_t ret_ref = (uint64_t)ret_copy;
13851         return ret_ref;
13852 }
13853
13854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
13855         LDKChannelAnnouncement msg_conv;
13856         msg_conv.inner = (void*)(msg & (~1));
13857         msg_conv.is_owned = (msg & 1) || (msg == 0);
13858         msg_conv = ChannelAnnouncement_clone(&msg_conv);
13859         LDKChannelUpdate update_msg_conv;
13860         update_msg_conv.inner = (void*)(update_msg & (~1));
13861         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
13862         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
13863         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13864         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
13865         uint64_t ret_ref = (uint64_t)ret_copy;
13866         return ret_ref;
13867 }
13868
13869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
13870         LDKNodeAnnouncement msg_conv;
13871         msg_conv.inner = (void*)(msg & (~1));
13872         msg_conv.is_owned = (msg & 1) || (msg == 0);
13873         msg_conv = NodeAnnouncement_clone(&msg_conv);
13874         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13875         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
13876         uint64_t ret_ref = (uint64_t)ret_copy;
13877         return ret_ref;
13878 }
13879
13880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
13881         LDKChannelUpdate msg_conv;
13882         msg_conv.inner = (void*)(msg & (~1));
13883         msg_conv.is_owned = (msg & 1) || (msg == 0);
13884         msg_conv = ChannelUpdate_clone(&msg_conv);
13885         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13886         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
13887         uint64_t ret_ref = (uint64_t)ret_copy;
13888         return ret_ref;
13889 }
13890
13891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13892         LDKPublicKey node_id_ref;
13893         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13894         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13895         LDKChannelUpdate msg_conv;
13896         msg_conv.inner = (void*)(msg & (~1));
13897         msg_conv.is_owned = (msg & 1) || (msg == 0);
13898         msg_conv = ChannelUpdate_clone(&msg_conv);
13899         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13900         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
13901         uint64_t ret_ref = (uint64_t)ret_copy;
13902         return ret_ref;
13903 }
13904
13905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
13906         LDKPublicKey node_id_ref;
13907         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13908         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13909         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
13910         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13911         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
13912         uint64_t ret_ref = (uint64_t)ret_copy;
13913         return ret_ref;
13914 }
13915
13916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1payment_1failure_1network_1update(JNIEnv *env, jclass clz, int64_t update) {
13917         LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1);
13918         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13919         *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv);
13920         uint64_t ret_ref = (uint64_t)ret_copy;
13921         return ret_ref;
13922 }
13923
13924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13925         LDKPublicKey node_id_ref;
13926         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13927         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13928         LDKQueryChannelRange msg_conv;
13929         msg_conv.inner = (void*)(msg & (~1));
13930         msg_conv.is_owned = (msg & 1) || (msg == 0);
13931         msg_conv = QueryChannelRange_clone(&msg_conv);
13932         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13933         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
13934         uint64_t ret_ref = (uint64_t)ret_copy;
13935         return ret_ref;
13936 }
13937
13938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1short_1ids_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13939         LDKPublicKey node_id_ref;
13940         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13941         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13942         LDKQueryShortChannelIds msg_conv;
13943         msg_conv.inner = (void*)(msg & (~1));
13944         msg_conv.is_owned = (msg & 1) || (msg == 0);
13945         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13946         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13947         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
13948         uint64_t ret_ref = (uint64_t)ret_copy;
13949         return ret_ref;
13950 }
13951
13952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1reply_1channel_1range(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13953         LDKPublicKey node_id_ref;
13954         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13955         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13956         LDKReplyChannelRange msg_conv;
13957         msg_conv.inner = (void*)(msg & (~1));
13958         msg_conv.is_owned = (msg & 1) || (msg == 0);
13959         msg_conv = ReplyChannelRange_clone(&msg_conv);
13960         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13961         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
13962         uint64_t ret_ref = (uint64_t)ret_copy;
13963         return ret_ref;
13964 }
13965
13966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13967         if ((this_ptr & 1) != 0) return;
13968         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13969         FREE((void*)this_ptr);
13970         MessageSendEventsProvider_free(this_ptr_conv);
13971 }
13972
13973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13974         if ((this_ptr & 1) != 0) return;
13975         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13976         FREE((void*)this_ptr);
13977         EventsProvider_free(this_ptr_conv);
13978 }
13979
13980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13981         if ((this_ptr & 1) != 0) return;
13982         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13983         FREE((void*)this_ptr);
13984         EventHandler_free(this_ptr_conv);
13985 }
13986
13987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13988         if ((this_ptr & 1) != 0) return;
13989         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13990         FREE((void*)this_ptr);
13991         APIError_free(this_ptr_conv);
13992 }
13993
13994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13995         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13996         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13997         *ret_copy = APIError_clone(orig_conv);
13998         uint64_t ret_ref = (uint64_t)ret_copy;
13999         return ret_ref;
14000 }
14001
14002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
14003         LDKStr err_conv = java_to_owned_str(env, err);
14004         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14005         *ret_copy = APIError_apimisuse_error(err_conv);
14006         uint64_t ret_ref = (uint64_t)ret_copy;
14007         return ret_ref;
14008 }
14009
14010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
14011         LDKStr err_conv = java_to_owned_str(env, err);
14012         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14013         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
14014         uint64_t ret_ref = (uint64_t)ret_copy;
14015         return ret_ref;
14016 }
14017
14018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
14019         LDKStr err_conv = java_to_owned_str(env, err);
14020         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14021         *ret_copy = APIError_route_error(err_conv);
14022         uint64_t ret_ref = (uint64_t)ret_copy;
14023         return ret_ref;
14024 }
14025
14026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
14027         LDKStr err_conv = java_to_owned_str(env, err);
14028         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14029         *ret_copy = APIError_channel_unavailable(err_conv);
14030         uint64_t ret_ref = (uint64_t)ret_copy;
14031         return ret_ref;
14032 }
14033
14034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
14035         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14036         *ret_copy = APIError_monitor_update_failed();
14037         uint64_t ret_ref = (uint64_t)ret_copy;
14038         return ret_ref;
14039 }
14040
14041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
14042         LDKShutdownScript script_conv;
14043         script_conv.inner = (void*)(script & (~1));
14044         script_conv.is_owned = (script & 1) || (script == 0);
14045         script_conv = ShutdownScript_clone(&script_conv);
14046         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14047         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
14048         uint64_t ret_ref = (uint64_t)ret_copy;
14049         return ret_ref;
14050 }
14051
14052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
14053         LDKu8slice msg_ref;
14054         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
14055         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
14056         unsigned char sk_arr[32];
14057         CHECK((*env)->GetArrayLength(env, sk) == 32);
14058         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
14059         unsigned char (*sk_ref)[32] = &sk_arr;
14060         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
14061         *ret_conv = sign(msg_ref, sk_ref);
14062         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
14063         return (uint64_t)ret_conv;
14064 }
14065
14066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
14067         LDKu8slice msg_ref;
14068         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
14069         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
14070         LDKStr sig_conv = java_to_owned_str(env, sig);
14071         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14072         *ret_conv = recover_pk(msg_ref, sig_conv);
14073         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
14074         return (uint64_t)ret_conv;
14075 }
14076
14077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
14078         LDKu8slice msg_ref;
14079         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
14080         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
14081         LDKStr sig_conv = java_to_owned_str(env, sig);
14082         LDKPublicKey pk_ref;
14083         CHECK((*env)->GetArrayLength(env, pk) == 33);
14084         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
14085         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
14086         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
14087         return ret_val;
14088 }
14089
14090 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14091         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
14092         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
14093         return ret_conv;
14094 }
14095
14096 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
14097         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
14098         return ret_conv;
14099 }
14100
14101 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
14102         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
14103         return ret_conv;
14104 }
14105
14106 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
14107         jclass ret_conv = LDKLevel_to_java(env, Level_info());
14108         return ret_conv;
14109 }
14110
14111 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
14112         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
14113         return ret_conv;
14114 }
14115
14116 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
14117         jclass ret_conv = LDKLevel_to_java(env, Level_error());
14118         return ret_conv;
14119 }
14120
14121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14122         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
14123         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
14124         jboolean ret_val = Level_eq(a_conv, b_conv);
14125         return ret_val;
14126 }
14127
14128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
14129         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
14130         int64_t ret_val = Level_hash(o_conv);
14131         return ret_val;
14132 }
14133
14134 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
14135         jclass ret_conv = LDKLevel_to_java(env, Level_max());
14136         return ret_conv;
14137 }
14138
14139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14140         if ((this_ptr & 1) != 0) return;
14141         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
14142         FREE((void*)this_ptr);
14143         Logger_free(this_ptr_conv);
14144 }
14145
14146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14147         LDKChannelHandshakeConfig this_obj_conv;
14148         this_obj_conv.inner = (void*)(this_obj & (~1));
14149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14150         ChannelHandshakeConfig_free(this_obj_conv);
14151 }
14152
14153 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14154         LDKChannelHandshakeConfig this_ptr_conv;
14155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14156         this_ptr_conv.is_owned = false;
14157         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
14158         return ret_val;
14159 }
14160
14161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14162         LDKChannelHandshakeConfig this_ptr_conv;
14163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14164         this_ptr_conv.is_owned = false;
14165         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
14166 }
14167
14168 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14169         LDKChannelHandshakeConfig this_ptr_conv;
14170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14171         this_ptr_conv.is_owned = false;
14172         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
14173         return ret_val;
14174 }
14175
14176 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) {
14177         LDKChannelHandshakeConfig this_ptr_conv;
14178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14179         this_ptr_conv.is_owned = false;
14180         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
14181 }
14182
14183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14184         LDKChannelHandshakeConfig this_ptr_conv;
14185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14186         this_ptr_conv.is_owned = false;
14187         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
14188         return ret_val;
14189 }
14190
14191 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) {
14192         LDKChannelHandshakeConfig this_ptr_conv;
14193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14194         this_ptr_conv.is_owned = false;
14195         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
14196 }
14197
14198 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) {
14199         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
14200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14202         uint64_t ret_ref = (uint64_t)ret_var.inner;
14203         if (ret_var.is_owned) {
14204                 ret_ref |= 1;
14205         }
14206         return ret_ref;
14207 }
14208
14209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14210         LDKChannelHandshakeConfig orig_conv;
14211         orig_conv.inner = (void*)(orig & (~1));
14212         orig_conv.is_owned = false;
14213         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
14214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14216         uint64_t ret_ref = (uint64_t)ret_var.inner;
14217         if (ret_var.is_owned) {
14218                 ret_ref |= 1;
14219         }
14220         return ret_ref;
14221 }
14222
14223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
14224         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
14225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14227         uint64_t ret_ref = (uint64_t)ret_var.inner;
14228         if (ret_var.is_owned) {
14229                 ret_ref |= 1;
14230         }
14231         return ret_ref;
14232 }
14233
14234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14235         LDKChannelHandshakeLimits this_obj_conv;
14236         this_obj_conv.inner = (void*)(this_obj & (~1));
14237         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14238         ChannelHandshakeLimits_free(this_obj_conv);
14239 }
14240
14241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14242         LDKChannelHandshakeLimits this_ptr_conv;
14243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14244         this_ptr_conv.is_owned = false;
14245         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
14246         return ret_val;
14247 }
14248
14249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14250         LDKChannelHandshakeLimits this_ptr_conv;
14251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14252         this_ptr_conv.is_owned = false;
14253         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
14254 }
14255
14256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14257         LDKChannelHandshakeLimits this_ptr_conv;
14258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14259         this_ptr_conv.is_owned = false;
14260         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
14261         return ret_val;
14262 }
14263
14264 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) {
14265         LDKChannelHandshakeLimits this_ptr_conv;
14266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14267         this_ptr_conv.is_owned = false;
14268         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
14269 }
14270
14271 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) {
14272         LDKChannelHandshakeLimits this_ptr_conv;
14273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14274         this_ptr_conv.is_owned = false;
14275         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
14276         return ret_val;
14277 }
14278
14279 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) {
14280         LDKChannelHandshakeLimits this_ptr_conv;
14281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14282         this_ptr_conv.is_owned = false;
14283         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14284 }
14285
14286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14287         LDKChannelHandshakeLimits this_ptr_conv;
14288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14289         this_ptr_conv.is_owned = false;
14290         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
14291         return ret_val;
14292 }
14293
14294 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) {
14295         LDKChannelHandshakeLimits this_ptr_conv;
14296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14297         this_ptr_conv.is_owned = false;
14298         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
14299 }
14300
14301 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
14302         LDKChannelHandshakeLimits this_ptr_conv;
14303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14304         this_ptr_conv.is_owned = false;
14305         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
14306         return ret_val;
14307 }
14308
14309 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) {
14310         LDKChannelHandshakeLimits this_ptr_conv;
14311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14312         this_ptr_conv.is_owned = false;
14313         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
14314 }
14315
14316 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
14317         LDKChannelHandshakeLimits this_ptr_conv;
14318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14319         this_ptr_conv.is_owned = false;
14320         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
14321         return ret_val;
14322 }
14323
14324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14325         LDKChannelHandshakeLimits this_ptr_conv;
14326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14327         this_ptr_conv.is_owned = false;
14328         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
14329 }
14330
14331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
14332         LDKChannelHandshakeLimits this_ptr_conv;
14333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14334         this_ptr_conv.is_owned = false;
14335         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
14336         return ret_val;
14337 }
14338
14339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14340         LDKChannelHandshakeLimits this_ptr_conv;
14341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14342         this_ptr_conv.is_owned = false;
14343         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
14344 }
14345
14346 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14347         LDKChannelHandshakeLimits this_ptr_conv;
14348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14349         this_ptr_conv.is_owned = false;
14350         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
14351         return ret_val;
14352 }
14353
14354 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) {
14355         LDKChannelHandshakeLimits this_ptr_conv;
14356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14357         this_ptr_conv.is_owned = false;
14358         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
14359 }
14360
14361 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) {
14362         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);
14363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14365         uint64_t ret_ref = (uint64_t)ret_var.inner;
14366         if (ret_var.is_owned) {
14367                 ret_ref |= 1;
14368         }
14369         return ret_ref;
14370 }
14371
14372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14373         LDKChannelHandshakeLimits orig_conv;
14374         orig_conv.inner = (void*)(orig & (~1));
14375         orig_conv.is_owned = false;
14376         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
14377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14379         uint64_t ret_ref = (uint64_t)ret_var.inner;
14380         if (ret_var.is_owned) {
14381                 ret_ref |= 1;
14382         }
14383         return ret_ref;
14384 }
14385
14386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
14387         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
14388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14390         uint64_t ret_ref = (uint64_t)ret_var.inner;
14391         if (ret_var.is_owned) {
14392                 ret_ref |= 1;
14393         }
14394         return ret_ref;
14395 }
14396
14397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14398         LDKChannelConfig this_obj_conv;
14399         this_obj_conv.inner = (void*)(this_obj & (~1));
14400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14401         ChannelConfig_free(this_obj_conv);
14402 }
14403
14404 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
14405         LDKChannelConfig this_ptr_conv;
14406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14407         this_ptr_conv.is_owned = false;
14408         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
14409         return ret_val;
14410 }
14411
14412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14413         LDKChannelConfig this_ptr_conv;
14414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14415         this_ptr_conv.is_owned = false;
14416         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
14417 }
14418
14419 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14420         LDKChannelConfig this_ptr_conv;
14421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14422         this_ptr_conv.is_owned = false;
14423         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
14424         return ret_val;
14425 }
14426
14427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14428         LDKChannelConfig this_ptr_conv;
14429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14430         this_ptr_conv.is_owned = false;
14431         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
14432 }
14433
14434 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
14435         LDKChannelConfig this_ptr_conv;
14436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14437         this_ptr_conv.is_owned = false;
14438         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
14439         return ret_val;
14440 }
14441
14442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14443         LDKChannelConfig this_ptr_conv;
14444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14445         this_ptr_conv.is_owned = false;
14446         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
14447 }
14448
14449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
14450         LDKChannelConfig this_ptr_conv;
14451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14452         this_ptr_conv.is_owned = false;
14453         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
14454         return ret_val;
14455 }
14456
14457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14458         LDKChannelConfig this_ptr_conv;
14459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14460         this_ptr_conv.is_owned = false;
14461         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
14462 }
14463
14464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14465         LDKChannelConfig this_ptr_conv;
14466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14467         this_ptr_conv.is_owned = false;
14468         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
14469         return ret_val;
14470 }
14471
14472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14473         LDKChannelConfig this_ptr_conv;
14474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14475         this_ptr_conv.is_owned = false;
14476         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
14477 }
14478
14479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14480         LDKChannelConfig this_ptr_conv;
14481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14482         this_ptr_conv.is_owned = false;
14483         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
14484         return ret_val;
14485 }
14486
14487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14488         LDKChannelConfig this_ptr_conv;
14489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14490         this_ptr_conv.is_owned = false;
14491         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
14492 }
14493
14494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
14495         LDKChannelConfig this_ptr_conv;
14496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14497         this_ptr_conv.is_owned = false;
14498         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
14499         return ret_val;
14500 }
14501
14502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14503         LDKChannelConfig this_ptr_conv;
14504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14505         this_ptr_conv.is_owned = false;
14506         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
14507 }
14508
14509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
14510         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
14511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14513         uint64_t ret_ref = (uint64_t)ret_var.inner;
14514         if (ret_var.is_owned) {
14515                 ret_ref |= 1;
14516         }
14517         return ret_ref;
14518 }
14519
14520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14521         LDKChannelConfig orig_conv;
14522         orig_conv.inner = (void*)(orig & (~1));
14523         orig_conv.is_owned = false;
14524         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
14525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14527         uint64_t ret_ref = (uint64_t)ret_var.inner;
14528         if (ret_var.is_owned) {
14529                 ret_ref |= 1;
14530         }
14531         return ret_ref;
14532 }
14533
14534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
14535         LDKChannelConfig ret_var = ChannelConfig_default();
14536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14538         uint64_t ret_ref = (uint64_t)ret_var.inner;
14539         if (ret_var.is_owned) {
14540                 ret_ref |= 1;
14541         }
14542         return ret_ref;
14543 }
14544
14545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
14546         LDKChannelConfig obj_conv;
14547         obj_conv.inner = (void*)(obj & (~1));
14548         obj_conv.is_owned = false;
14549         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
14550         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14551         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14552         CVec_u8Z_free(ret_var);
14553         return ret_arr;
14554 }
14555
14556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14557         LDKu8slice ser_ref;
14558         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14559         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14560         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14561         *ret_conv = ChannelConfig_read(ser_ref);
14562         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14563         return (uint64_t)ret_conv;
14564 }
14565
14566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14567         LDKUserConfig this_obj_conv;
14568         this_obj_conv.inner = (void*)(this_obj & (~1));
14569         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14570         UserConfig_free(this_obj_conv);
14571 }
14572
14573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
14574         LDKUserConfig this_ptr_conv;
14575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14576         this_ptr_conv.is_owned = false;
14577         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
14578         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14579         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14580         uint64_t ret_ref = (uint64_t)ret_var.inner;
14581         if (ret_var.is_owned) {
14582                 ret_ref |= 1;
14583         }
14584         return ret_ref;
14585 }
14586
14587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14588         LDKUserConfig this_ptr_conv;
14589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14590         this_ptr_conv.is_owned = false;
14591         LDKChannelHandshakeConfig val_conv;
14592         val_conv.inner = (void*)(val & (~1));
14593         val_conv.is_owned = (val & 1) || (val == 0);
14594         val_conv = ChannelHandshakeConfig_clone(&val_conv);
14595         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
14596 }
14597
14598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
14599         LDKUserConfig this_ptr_conv;
14600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14601         this_ptr_conv.is_owned = false;
14602         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
14603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14605         uint64_t ret_ref = (uint64_t)ret_var.inner;
14606         if (ret_var.is_owned) {
14607                 ret_ref |= 1;
14608         }
14609         return ret_ref;
14610 }
14611
14612 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) {
14613         LDKUserConfig this_ptr_conv;
14614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14615         this_ptr_conv.is_owned = false;
14616         LDKChannelHandshakeLimits val_conv;
14617         val_conv.inner = (void*)(val & (~1));
14618         val_conv.is_owned = (val & 1) || (val == 0);
14619         val_conv = ChannelHandshakeLimits_clone(&val_conv);
14620         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
14621 }
14622
14623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
14624         LDKUserConfig this_ptr_conv;
14625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14626         this_ptr_conv.is_owned = false;
14627         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
14628         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14629         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14630         uint64_t ret_ref = (uint64_t)ret_var.inner;
14631         if (ret_var.is_owned) {
14632                 ret_ref |= 1;
14633         }
14634         return ret_ref;
14635 }
14636
14637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14638         LDKUserConfig this_ptr_conv;
14639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14640         this_ptr_conv.is_owned = false;
14641         LDKChannelConfig val_conv;
14642         val_conv.inner = (void*)(val & (~1));
14643         val_conv.is_owned = (val & 1) || (val == 0);
14644         val_conv = ChannelConfig_clone(&val_conv);
14645         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
14646 }
14647
14648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
14649         LDKUserConfig this_ptr_conv;
14650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14651         this_ptr_conv.is_owned = false;
14652         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
14653         return ret_val;
14654 }
14655
14656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14657         LDKUserConfig this_ptr_conv;
14658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14659         this_ptr_conv.is_owned = false;
14660         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
14661 }
14662
14663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
14664         LDKChannelHandshakeConfig own_channel_config_arg_conv;
14665         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
14666         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
14667         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
14668         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
14669         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
14670         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
14671         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
14672         LDKChannelConfig channel_options_arg_conv;
14673         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
14674         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
14675         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
14676         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
14677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14679         uint64_t ret_ref = (uint64_t)ret_var.inner;
14680         if (ret_var.is_owned) {
14681                 ret_ref |= 1;
14682         }
14683         return ret_ref;
14684 }
14685
14686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14687         LDKUserConfig orig_conv;
14688         orig_conv.inner = (void*)(orig & (~1));
14689         orig_conv.is_owned = false;
14690         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
14691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14693         uint64_t ret_ref = (uint64_t)ret_var.inner;
14694         if (ret_var.is_owned) {
14695                 ret_ref |= 1;
14696         }
14697         return ret_ref;
14698 }
14699
14700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
14701         LDKUserConfig ret_var = UserConfig_default();
14702         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14703         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14704         uint64_t ret_ref = (uint64_t)ret_var.inner;
14705         if (ret_var.is_owned) {
14706                 ret_ref |= 1;
14707         }
14708         return ret_ref;
14709 }
14710
14711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14712         LDKBestBlock this_obj_conv;
14713         this_obj_conv.inner = (void*)(this_obj & (~1));
14714         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14715         BestBlock_free(this_obj_conv);
14716 }
14717
14718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14719         LDKBestBlock orig_conv;
14720         orig_conv.inner = (void*)(orig & (~1));
14721         orig_conv.is_owned = false;
14722         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
14723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14725         uint64_t ret_ref = (uint64_t)ret_var.inner;
14726         if (ret_var.is_owned) {
14727                 ret_ref |= 1;
14728         }
14729         return ret_ref;
14730 }
14731
14732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
14733         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
14734         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
14735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14737         uint64_t ret_ref = (uint64_t)ret_var.inner;
14738         if (ret_var.is_owned) {
14739                 ret_ref |= 1;
14740         }
14741         return ret_ref;
14742 }
14743
14744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
14745         LDKThirtyTwoBytes block_hash_ref;
14746         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
14747         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
14748         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
14749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14751         uint64_t ret_ref = (uint64_t)ret_var.inner;
14752         if (ret_var.is_owned) {
14753                 ret_ref |= 1;
14754         }
14755         return ret_ref;
14756 }
14757
14758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14759         LDKBestBlock this_arg_conv;
14760         this_arg_conv.inner = (void*)(this_arg & (~1));
14761         this_arg_conv.is_owned = false;
14762         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
14764         return ret_arr;
14765 }
14766
14767 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
14768         LDKBestBlock this_arg_conv;
14769         this_arg_conv.inner = (void*)(this_arg & (~1));
14770         this_arg_conv.is_owned = false;
14771         int32_t ret_val = BestBlock_height(&this_arg_conv);
14772         return ret_val;
14773 }
14774
14775 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14776         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14777         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14778         return ret_conv;
14779 }
14780
14781 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
14782         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
14783         return ret_conv;
14784 }
14785
14786 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
14787         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
14788         return ret_conv;
14789 }
14790
14791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14792         if ((this_ptr & 1) != 0) return;
14793         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14794         FREE((void*)this_ptr);
14795         Access_free(this_ptr_conv);
14796 }
14797
14798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14799         if ((this_ptr & 1) != 0) return;
14800         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14801         FREE((void*)this_ptr);
14802         Listen_free(this_ptr_conv);
14803 }
14804
14805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14806         if ((this_ptr & 1) != 0) return;
14807         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14808         FREE((void*)this_ptr);
14809         Confirm_free(this_ptr_conv);
14810 }
14811
14812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14813         if ((this_ptr & 1) != 0) return;
14814         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14815         FREE((void*)this_ptr);
14816         Watch_free(this_ptr_conv);
14817 }
14818
14819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14820         if ((this_ptr & 1) != 0) return;
14821         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14822         FREE((void*)this_ptr);
14823         Filter_free(this_ptr_conv);
14824 }
14825
14826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14827         LDKWatchedOutput this_obj_conv;
14828         this_obj_conv.inner = (void*)(this_obj & (~1));
14829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14830         WatchedOutput_free(this_obj_conv);
14831 }
14832
14833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14834         LDKWatchedOutput this_ptr_conv;
14835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14836         this_ptr_conv.is_owned = false;
14837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14839         return ret_arr;
14840 }
14841
14842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14843         LDKWatchedOutput this_ptr_conv;
14844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14845         this_ptr_conv.is_owned = false;
14846         LDKThirtyTwoBytes val_ref;
14847         CHECK((*env)->GetArrayLength(env, val) == 32);
14848         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14849         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14850 }
14851
14852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14853         LDKWatchedOutput this_ptr_conv;
14854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14855         this_ptr_conv.is_owned = false;
14856         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14859         uint64_t ret_ref = (uint64_t)ret_var.inner;
14860         if (ret_var.is_owned) {
14861                 ret_ref |= 1;
14862         }
14863         return ret_ref;
14864 }
14865
14866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14867         LDKWatchedOutput this_ptr_conv;
14868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14869         this_ptr_conv.is_owned = false;
14870         LDKOutPoint val_conv;
14871         val_conv.inner = (void*)(val & (~1));
14872         val_conv.is_owned = (val & 1) || (val == 0);
14873         val_conv = OutPoint_clone(&val_conv);
14874         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14875 }
14876
14877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14878         LDKWatchedOutput this_ptr_conv;
14879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14880         this_ptr_conv.is_owned = false;
14881         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14882         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14883         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14884         return ret_arr;
14885 }
14886
14887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14888         LDKWatchedOutput this_ptr_conv;
14889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14890         this_ptr_conv.is_owned = false;
14891         LDKCVec_u8Z val_ref;
14892         val_ref.datalen = (*env)->GetArrayLength(env, val);
14893         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14894         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14895         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14896 }
14897
14898 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) {
14899         LDKThirtyTwoBytes block_hash_arg_ref;
14900         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14901         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14902         LDKOutPoint outpoint_arg_conv;
14903         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14904         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14905         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14906         LDKCVec_u8Z script_pubkey_arg_ref;
14907         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14908         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14909         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14910         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14913         uint64_t ret_ref = (uint64_t)ret_var.inner;
14914         if (ret_var.is_owned) {
14915                 ret_ref |= 1;
14916         }
14917         return ret_ref;
14918 }
14919
14920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14921         LDKWatchedOutput orig_conv;
14922         orig_conv.inner = (void*)(orig & (~1));
14923         orig_conv.is_owned = false;
14924         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14927         uint64_t ret_ref = (uint64_t)ret_var.inner;
14928         if (ret_var.is_owned) {
14929                 ret_ref |= 1;
14930         }
14931         return ret_ref;
14932 }
14933
14934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14935         LDKWatchedOutput o_conv;
14936         o_conv.inner = (void*)(o & (~1));
14937         o_conv.is_owned = false;
14938         int64_t ret_val = WatchedOutput_hash(&o_conv);
14939         return ret_val;
14940 }
14941
14942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14943         if ((this_ptr & 1) != 0) return;
14944         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14945         FREE((void*)this_ptr);
14946         BroadcasterInterface_free(this_ptr_conv);
14947 }
14948
14949 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14950         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14951         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14952         return ret_conv;
14953 }
14954
14955 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
14956         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
14957         return ret_conv;
14958 }
14959
14960 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
14961         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
14962         return ret_conv;
14963 }
14964
14965 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
14966         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
14967         return ret_conv;
14968 }
14969
14970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
14971         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
14972         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
14973         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
14974         return ret_val;
14975 }
14976
14977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14978         if ((this_ptr & 1) != 0) return;
14979         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14980         FREE((void*)this_ptr);
14981         FeeEstimator_free(this_ptr_conv);
14982 }
14983
14984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14985         LDKChainMonitor this_obj_conv;
14986         this_obj_conv.inner = (void*)(this_obj & (~1));
14987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14988         ChainMonitor_free(this_obj_conv);
14989 }
14990
14991 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) {
14992         LDKFilter *chain_source_conv_ptr = NULL;
14993         if (chain_source != 0) {
14994                 LDKFilter chain_source_conv;
14995                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14996                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14997                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14998                         LDKFilter_JCalls_cloned(&chain_source_conv);
14999                 }
15000                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
15001                 *chain_source_conv_ptr = chain_source_conv;
15002         }
15003         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15004         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15005                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15006                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15007         }
15008         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15009         if (logger_conv.free == LDKLogger_JCalls_free) {
15010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15011                 LDKLogger_JCalls_cloned(&logger_conv);
15012         }
15013         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
15014         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
15015                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15016                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
15017         }
15018         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
15019         if (persister_conv.free == LDKPersist_JCalls_free) {
15020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15021                 LDKPersist_JCalls_cloned(&persister_conv);
15022         }
15023         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
15024         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15025         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15026         uint64_t ret_ref = (uint64_t)ret_var.inner;
15027         if (ret_var.is_owned) {
15028                 ret_ref |= 1;
15029         }
15030         return ret_ref;
15031 }
15032
15033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
15034         LDKChainMonitor this_arg_conv;
15035         this_arg_conv.inner = (void*)(this_arg & (~1));
15036         this_arg_conv.is_owned = false;
15037         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
15038         *ret = ChainMonitor_as_Listen(&this_arg_conv);
15039         return (uint64_t)ret;
15040 }
15041
15042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
15043         LDKChainMonitor this_arg_conv;
15044         this_arg_conv.inner = (void*)(this_arg & (~1));
15045         this_arg_conv.is_owned = false;
15046         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15047         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
15048         return (uint64_t)ret;
15049 }
15050
15051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
15052         LDKChainMonitor this_arg_conv;
15053         this_arg_conv.inner = (void*)(this_arg & (~1));
15054         this_arg_conv.is_owned = false;
15055         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
15056         *ret = ChainMonitor_as_Watch(&this_arg_conv);
15057         return (uint64_t)ret;
15058 }
15059
15060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
15061         LDKChainMonitor this_arg_conv;
15062         this_arg_conv.inner = (void*)(this_arg & (~1));
15063         this_arg_conv.is_owned = false;
15064         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15065         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
15066         return (uint64_t)ret;
15067 }
15068
15069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15070         LDKChannelMonitorUpdate this_obj_conv;
15071         this_obj_conv.inner = (void*)(this_obj & (~1));
15072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15073         ChannelMonitorUpdate_free(this_obj_conv);
15074 }
15075
15076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15077         LDKChannelMonitorUpdate this_ptr_conv;
15078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15079         this_ptr_conv.is_owned = false;
15080         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
15081         return ret_val;
15082 }
15083
15084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15085         LDKChannelMonitorUpdate this_ptr_conv;
15086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15087         this_ptr_conv.is_owned = false;
15088         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
15089 }
15090
15091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15092         LDKChannelMonitorUpdate orig_conv;
15093         orig_conv.inner = (void*)(orig & (~1));
15094         orig_conv.is_owned = false;
15095         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
15096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15098         uint64_t ret_ref = (uint64_t)ret_var.inner;
15099         if (ret_var.is_owned) {
15100                 ret_ref |= 1;
15101         }
15102         return ret_ref;
15103 }
15104
15105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
15106         LDKChannelMonitorUpdate obj_conv;
15107         obj_conv.inner = (void*)(obj & (~1));
15108         obj_conv.is_owned = false;
15109         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
15110         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15111         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15112         CVec_u8Z_free(ret_var);
15113         return ret_arr;
15114 }
15115
15116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15117         LDKu8slice ser_ref;
15118         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15119         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15120         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15121         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
15122         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15123         return (uint64_t)ret_conv;
15124 }
15125
15126 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15127         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
15128         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
15129         return ret_conv;
15130 }
15131
15132 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
15133         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
15134         return ret_conv;
15135 }
15136
15137 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
15138         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
15139         return ret_conv;
15140 }
15141
15142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15143         LDKMonitorUpdateError this_obj_conv;
15144         this_obj_conv.inner = (void*)(this_obj & (~1));
15145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15146         MonitorUpdateError_free(this_obj_conv);
15147 }
15148
15149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15150         LDKMonitorUpdateError orig_conv;
15151         orig_conv.inner = (void*)(orig & (~1));
15152         orig_conv.is_owned = false;
15153         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
15154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15156         uint64_t ret_ref = (uint64_t)ret_var.inner;
15157         if (ret_var.is_owned) {
15158                 ret_ref |= 1;
15159         }
15160         return ret_ref;
15161 }
15162
15163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15164         if ((this_ptr & 1) != 0) return;
15165         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
15166         FREE((void*)this_ptr);
15167         MonitorEvent_free(this_ptr_conv);
15168 }
15169
15170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15171         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
15172         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15173         *ret_copy = MonitorEvent_clone(orig_conv);
15174         uint64_t ret_ref = (uint64_t)ret_copy;
15175         return ret_ref;
15176 }
15177
15178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
15179         LDKHTLCUpdate a_conv;
15180         a_conv.inner = (void*)(a & (~1));
15181         a_conv.is_owned = (a & 1) || (a == 0);
15182         a_conv = HTLCUpdate_clone(&a_conv);
15183         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15184         *ret_copy = MonitorEvent_htlcevent(a_conv);
15185         uint64_t ret_ref = (uint64_t)ret_copy;
15186         return ret_ref;
15187 }
15188
15189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted(JNIEnv *env, jclass clz, int64_t a) {
15190         LDKOutPoint a_conv;
15191         a_conv.inner = (void*)(a & (~1));
15192         a_conv.is_owned = (a & 1) || (a == 0);
15193         a_conv = OutPoint_clone(&a_conv);
15194         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15195         *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv);
15196         uint64_t ret_ref = (uint64_t)ret_copy;
15197         return ret_ref;
15198 }
15199
15200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15201         LDKHTLCUpdate this_obj_conv;
15202         this_obj_conv.inner = (void*)(this_obj & (~1));
15203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15204         HTLCUpdate_free(this_obj_conv);
15205 }
15206
15207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15208         LDKHTLCUpdate orig_conv;
15209         orig_conv.inner = (void*)(orig & (~1));
15210         orig_conv.is_owned = false;
15211         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
15212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15214         uint64_t ret_ref = (uint64_t)ret_var.inner;
15215         if (ret_var.is_owned) {
15216                 ret_ref |= 1;
15217         }
15218         return ret_ref;
15219 }
15220
15221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
15222         LDKHTLCUpdate obj_conv;
15223         obj_conv.inner = (void*)(obj & (~1));
15224         obj_conv.is_owned = false;
15225         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
15226         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15227         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15228         CVec_u8Z_free(ret_var);
15229         return ret_arr;
15230 }
15231
15232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15233         LDKu8slice ser_ref;
15234         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15235         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15236         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15237         *ret_conv = HTLCUpdate_read(ser_ref);
15238         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15239         return (uint64_t)ret_conv;
15240 }
15241
15242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15243         LDKChannelMonitor this_obj_conv;
15244         this_obj_conv.inner = (void*)(this_obj & (~1));
15245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15246         ChannelMonitor_free(this_obj_conv);
15247 }
15248
15249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15250         LDKChannelMonitor orig_conv;
15251         orig_conv.inner = (void*)(orig & (~1));
15252         orig_conv.is_owned = false;
15253         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
15254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15256         uint64_t ret_ref = (uint64_t)ret_var.inner;
15257         if (ret_var.is_owned) {
15258                 ret_ref |= 1;
15259         }
15260         return ret_ref;
15261 }
15262
15263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15264         LDKChannelMonitor obj_conv;
15265         obj_conv.inner = (void*)(obj & (~1));
15266         obj_conv.is_owned = false;
15267         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
15268         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15269         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15270         CVec_u8Z_free(ret_var);
15271         return ret_arr;
15272 }
15273
15274 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) {
15275         LDKChannelMonitor this_arg_conv;
15276         this_arg_conv.inner = (void*)(this_arg & (~1));
15277         this_arg_conv.is_owned = false;
15278         LDKChannelMonitorUpdate updates_conv;
15279         updates_conv.inner = (void*)(updates & (~1));
15280         updates_conv.is_owned = false;
15281         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15282         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15283         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
15284         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15285         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
15286         return (uint64_t)ret_conv;
15287 }
15288
15289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15290         LDKChannelMonitor this_arg_conv;
15291         this_arg_conv.inner = (void*)(this_arg & (~1));
15292         this_arg_conv.is_owned = false;
15293         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
15294         return ret_val;
15295 }
15296
15297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
15298         LDKChannelMonitor this_arg_conv;
15299         this_arg_conv.inner = (void*)(this_arg & (~1));
15300         this_arg_conv.is_owned = false;
15301         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15302         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
15303         return (uint64_t)ret_ref;
15304 }
15305
15306 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
15307         LDKChannelMonitor this_arg_conv;
15308         this_arg_conv.inner = (void*)(this_arg & (~1));
15309         this_arg_conv.is_owned = false;
15310         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
15311         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15312         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15313         for (size_t v = 0; v < ret_var.datalen; v++) {
15314                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15315                 *ret_conv_47_ref = ret_var.data[v];
15316                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
15317         }
15318         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15319         FREE(ret_var.data);
15320         return ret_arr;
15321 }
15322
15323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
15324         LDKChannelMonitor this_arg_conv;
15325         this_arg_conv.inner = (void*)(this_arg & (~1));
15326         this_arg_conv.is_owned = false;
15327         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
15328         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
15329 }
15330
15331 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
15332         LDKChannelMonitor this_arg_conv;
15333         this_arg_conv.inner = (void*)(this_arg & (~1));
15334         this_arg_conv.is_owned = false;
15335         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
15336         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15337         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15338         for (size_t o = 0; o < ret_var.datalen; o++) {
15339                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15340                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
15341                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
15342                 ret_arr_ptr[o] = ret_conv_14_ref;
15343         }
15344         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15345         FREE(ret_var.data);
15346         return ret_arr;
15347 }
15348
15349 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
15350         LDKChannelMonitor this_arg_conv;
15351         this_arg_conv.inner = (void*)(this_arg & (~1));
15352         this_arg_conv.is_owned = false;
15353         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
15354         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15355         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15356         for (size_t h = 0; h < ret_var.datalen; h++) {
15357                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15358                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
15359                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
15360                 ret_arr_ptr[h] = ret_conv_7_ref;
15361         }
15362         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15363         FREE(ret_var.data);
15364         return ret_arr;
15365 }
15366
15367 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) {
15368         LDKChannelMonitor this_arg_conv;
15369         this_arg_conv.inner = (void*)(this_arg & (~1));
15370         this_arg_conv.is_owned = false;
15371         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
15372         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
15373         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15374         ;
15375         for (size_t i = 0; i < ret_var.datalen; i++) {
15376                 LDKTransaction ret_conv_8_var = ret_var.data[i];
15377                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
15378                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
15379                 Transaction_free(ret_conv_8_var);
15380                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15381         }
15382         FREE(ret_var.data);
15383         return ret_arr;
15384 }
15385
15386 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) {
15387         LDKChannelMonitor this_arg_conv;
15388         this_arg_conv.inner = (void*)(this_arg & (~1));
15389         this_arg_conv.is_owned = false;
15390         unsigned char header_arr[80];
15391         CHECK((*env)->GetArrayLength(env, header) == 80);
15392         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15393         unsigned char (*header_ref)[80] = &header_arr;
15394         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15395         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15396         if (txdata_constr.datalen > 0)
15397                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15398         else
15399                 txdata_constr.data = NULL;
15400         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15401         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15402                 int64_t txdata_conv_24 = txdata_vals[y];
15403                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15404                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15405                 txdata_constr.data[y] = txdata_conv_24_conv;
15406         }
15407         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15408         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15409         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15410                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15411                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15412         }
15413         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15414         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15416                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15417         }
15418         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15419         if (logger_conv.free == LDKLogger_JCalls_free) {
15420                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15421                 LDKLogger_JCalls_cloned(&logger_conv);
15422         }
15423         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);
15424         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15425         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15426         for (size_t u = 0; u < ret_var.datalen; u++) {
15427                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15428                 *ret_conv_46_ref = ret_var.data[u];
15429                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15430         }
15431         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15432         FREE(ret_var.data);
15433         return ret_arr;
15434 }
15435
15436 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) {
15437         LDKChannelMonitor this_arg_conv;
15438         this_arg_conv.inner = (void*)(this_arg & (~1));
15439         this_arg_conv.is_owned = false;
15440         unsigned char header_arr[80];
15441         CHECK((*env)->GetArrayLength(env, header) == 80);
15442         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15443         unsigned char (*header_ref)[80] = &header_arr;
15444         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15445         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15446                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15447                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15448         }
15449         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15450         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15451                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15452                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15453         }
15454         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15455         if (logger_conv.free == LDKLogger_JCalls_free) {
15456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15457                 LDKLogger_JCalls_cloned(&logger_conv);
15458         }
15459         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15460 }
15461
15462 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) {
15463         LDKChannelMonitor this_arg_conv;
15464         this_arg_conv.inner = (void*)(this_arg & (~1));
15465         this_arg_conv.is_owned = false;
15466         unsigned char header_arr[80];
15467         CHECK((*env)->GetArrayLength(env, header) == 80);
15468         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15469         unsigned char (*header_ref)[80] = &header_arr;
15470         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15471         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15472         if (txdata_constr.datalen > 0)
15473                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15474         else
15475                 txdata_constr.data = NULL;
15476         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15477         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15478                 int64_t txdata_conv_24 = txdata_vals[y];
15479                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15480                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15481                 txdata_constr.data[y] = txdata_conv_24_conv;
15482         }
15483         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15484         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15485         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15486                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15487                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15488         }
15489         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15490         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15491                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15492                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15493         }
15494         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15495         if (logger_conv.free == LDKLogger_JCalls_free) {
15496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15497                 LDKLogger_JCalls_cloned(&logger_conv);
15498         }
15499         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);
15500         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15501         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15502         for (size_t u = 0; u < ret_var.datalen; u++) {
15503                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15504                 *ret_conv_46_ref = ret_var.data[u];
15505                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15506         }
15507         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15508         FREE(ret_var.data);
15509         return ret_arr;
15510 }
15511
15512 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) {
15513         LDKChannelMonitor this_arg_conv;
15514         this_arg_conv.inner = (void*)(this_arg & (~1));
15515         this_arg_conv.is_owned = false;
15516         unsigned char txid_arr[32];
15517         CHECK((*env)->GetArrayLength(env, txid) == 32);
15518         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
15519         unsigned char (*txid_ref)[32] = &txid_arr;
15520         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15521         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15522                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15523                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15524         }
15525         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15526         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15528                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15529         }
15530         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15531         if (logger_conv.free == LDKLogger_JCalls_free) {
15532                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15533                 LDKLogger_JCalls_cloned(&logger_conv);
15534         }
15535         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
15536 }
15537
15538 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) {
15539         LDKChannelMonitor this_arg_conv;
15540         this_arg_conv.inner = (void*)(this_arg & (~1));
15541         this_arg_conv.is_owned = false;
15542         unsigned char header_arr[80];
15543         CHECK((*env)->GetArrayLength(env, header) == 80);
15544         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15545         unsigned char (*header_ref)[80] = &header_arr;
15546         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15547         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15549                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15550         }
15551         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15552         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15553                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15554                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15555         }
15556         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15557         if (logger_conv.free == LDKLogger_JCalls_free) {
15558                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15559                 LDKLogger_JCalls_cloned(&logger_conv);
15560         }
15561         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15562         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15563         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15564         for (size_t u = 0; u < ret_var.datalen; u++) {
15565                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15566                 *ret_conv_46_ref = ret_var.data[u];
15567                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15568         }
15569         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15570         FREE(ret_var.data);
15571         return ret_arr;
15572 }
15573
15574 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
15575         LDKChannelMonitor this_arg_conv;
15576         this_arg_conv.inner = (void*)(this_arg & (~1));
15577         this_arg_conv.is_owned = false;
15578         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
15579         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15580         ;
15581         for (size_t i = 0; i < ret_var.datalen; i++) {
15582                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
15583                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
15584                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15585         }
15586         FREE(ret_var.data);
15587         return ret_arr;
15588 }
15589
15590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
15591         LDKChannelMonitor this_arg_conv;
15592         this_arg_conv.inner = (void*)(this_arg & (~1));
15593         this_arg_conv.is_owned = false;
15594         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
15595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15597         uint64_t ret_ref = (uint64_t)ret_var.inner;
15598         if (ret_var.is_owned) {
15599                 ret_ref |= 1;
15600         }
15601         return ret_ref;
15602 }
15603
15604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15605         if ((this_ptr & 1) != 0) return;
15606         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
15607         FREE((void*)this_ptr);
15608         Persist_free(this_ptr_conv);
15609 }
15610
15611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
15612         LDKu8slice ser_ref;
15613         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15614         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15615         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
15616         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
15617         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
15618         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15619         return (uint64_t)ret_conv;
15620 }
15621
15622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15623         LDKOutPoint this_obj_conv;
15624         this_obj_conv.inner = (void*)(this_obj & (~1));
15625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15626         OutPoint_free(this_obj_conv);
15627 }
15628
15629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
15630         LDKOutPoint this_ptr_conv;
15631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15632         this_ptr_conv.is_owned = false;
15633         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15634         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
15635         return ret_arr;
15636 }
15637
15638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15639         LDKOutPoint this_ptr_conv;
15640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15641         this_ptr_conv.is_owned = false;
15642         LDKThirtyTwoBytes val_ref;
15643         CHECK((*env)->GetArrayLength(env, val) == 32);
15644         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15645         OutPoint_set_txid(&this_ptr_conv, val_ref);
15646 }
15647
15648 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
15649         LDKOutPoint this_ptr_conv;
15650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15651         this_ptr_conv.is_owned = false;
15652         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
15653         return ret_val;
15654 }
15655
15656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15657         LDKOutPoint this_ptr_conv;
15658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15659         this_ptr_conv.is_owned = false;
15660         OutPoint_set_index(&this_ptr_conv, val);
15661 }
15662
15663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
15664         LDKThirtyTwoBytes txid_arg_ref;
15665         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
15666         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
15667         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
15668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15670         uint64_t ret_ref = (uint64_t)ret_var.inner;
15671         if (ret_var.is_owned) {
15672                 ret_ref |= 1;
15673         }
15674         return ret_ref;
15675 }
15676
15677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15678         LDKOutPoint orig_conv;
15679         orig_conv.inner = (void*)(orig & (~1));
15680         orig_conv.is_owned = false;
15681         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
15682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15684         uint64_t ret_ref = (uint64_t)ret_var.inner;
15685         if (ret_var.is_owned) {
15686                 ret_ref |= 1;
15687         }
15688         return ret_ref;
15689 }
15690
15691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15692         LDKOutPoint a_conv;
15693         a_conv.inner = (void*)(a & (~1));
15694         a_conv.is_owned = false;
15695         LDKOutPoint b_conv;
15696         b_conv.inner = (void*)(b & (~1));
15697         b_conv.is_owned = false;
15698         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
15699         return ret_val;
15700 }
15701
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
15703         LDKOutPoint o_conv;
15704         o_conv.inner = (void*)(o & (~1));
15705         o_conv.is_owned = false;
15706         int64_t ret_val = OutPoint_hash(&o_conv);
15707         return ret_val;
15708 }
15709
15710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15711         LDKOutPoint this_arg_conv;
15712         this_arg_conv.inner = (void*)(this_arg & (~1));
15713         this_arg_conv.is_owned = false;
15714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
15716         return ret_arr;
15717 }
15718
15719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
15720         LDKOutPoint obj_conv;
15721         obj_conv.inner = (void*)(obj & (~1));
15722         obj_conv.is_owned = false;
15723         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
15724         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15725         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15726         CVec_u8Z_free(ret_var);
15727         return ret_arr;
15728 }
15729
15730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15731         LDKu8slice ser_ref;
15732         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15733         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15734         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15735         *ret_conv = OutPoint_read(ser_ref);
15736         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15737         return (uint64_t)ret_conv;
15738 }
15739
15740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15741         LDKDelayedPaymentOutputDescriptor this_obj_conv;
15742         this_obj_conv.inner = (void*)(this_obj & (~1));
15743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15744         DelayedPaymentOutputDescriptor_free(this_obj_conv);
15745 }
15746
15747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15748         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15750         this_ptr_conv.is_owned = false;
15751         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15754         uint64_t ret_ref = (uint64_t)ret_var.inner;
15755         if (ret_var.is_owned) {
15756                 ret_ref |= 1;
15757         }
15758         return ret_ref;
15759 }
15760
15761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15762         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15764         this_ptr_conv.is_owned = false;
15765         LDKOutPoint val_conv;
15766         val_conv.inner = (void*)(val & (~1));
15767         val_conv.is_owned = (val & 1) || (val == 0);
15768         val_conv = OutPoint_clone(&val_conv);
15769         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15770 }
15771
15772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15773         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15775         this_ptr_conv.is_owned = false;
15776         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
15778         return ret_arr;
15779 }
15780
15781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15782         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15784         this_ptr_conv.is_owned = false;
15785         LDKPublicKey val_ref;
15786         CHECK((*env)->GetArrayLength(env, val) == 33);
15787         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15788         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
15789 }
15790
15791 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15792         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15794         this_ptr_conv.is_owned = false;
15795         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
15796         return ret_val;
15797 }
15798
15799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15800         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15802         this_ptr_conv.is_owned = false;
15803         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
15804 }
15805
15806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15807         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15809         this_ptr_conv.is_owned = false;
15810         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15811         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15812 }
15813
15814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15815         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15817         this_ptr_conv.is_owned = false;
15818         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
15820         return ret_arr;
15821 }
15822
15823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15824         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15826         this_ptr_conv.is_owned = false;
15827         LDKPublicKey val_ref;
15828         CHECK((*env)->GetArrayLength(env, val) == 33);
15829         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15830         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
15831 }
15832
15833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15834         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15836         this_ptr_conv.is_owned = false;
15837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15839         return ret_arr;
15840 }
15841
15842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15843         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15845         this_ptr_conv.is_owned = false;
15846         LDKThirtyTwoBytes val_ref;
15847         CHECK((*env)->GetArrayLength(env, val) == 32);
15848         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15849         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15850 }
15851
15852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15853         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15855         this_ptr_conv.is_owned = false;
15856         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15857         return ret_val;
15858 }
15859
15860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15861         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15863         this_ptr_conv.is_owned = false;
15864         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15865 }
15866
15867 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) {
15868         LDKOutPoint outpoint_arg_conv;
15869         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15870         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15871         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15872         LDKPublicKey per_commitment_point_arg_ref;
15873         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15874         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15875         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15876         LDKPublicKey revocation_pubkey_arg_ref;
15877         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15878         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15879         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15880         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15881         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15882         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);
15883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15885         uint64_t ret_ref = (uint64_t)ret_var.inner;
15886         if (ret_var.is_owned) {
15887                 ret_ref |= 1;
15888         }
15889         return ret_ref;
15890 }
15891
15892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15893         LDKDelayedPaymentOutputDescriptor orig_conv;
15894         orig_conv.inner = (void*)(orig & (~1));
15895         orig_conv.is_owned = false;
15896         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15899         uint64_t ret_ref = (uint64_t)ret_var.inner;
15900         if (ret_var.is_owned) {
15901                 ret_ref |= 1;
15902         }
15903         return ret_ref;
15904 }
15905
15906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15907         LDKDelayedPaymentOutputDescriptor obj_conv;
15908         obj_conv.inner = (void*)(obj & (~1));
15909         obj_conv.is_owned = false;
15910         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15913         CVec_u8Z_free(ret_var);
15914         return ret_arr;
15915 }
15916
15917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15918         LDKu8slice ser_ref;
15919         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15920         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15921         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15922         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15923         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15924         return (uint64_t)ret_conv;
15925 }
15926
15927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15928         LDKStaticPaymentOutputDescriptor this_obj_conv;
15929         this_obj_conv.inner = (void*)(this_obj & (~1));
15930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15931         StaticPaymentOutputDescriptor_free(this_obj_conv);
15932 }
15933
15934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15935         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15937         this_ptr_conv.is_owned = false;
15938         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15941         uint64_t ret_ref = (uint64_t)ret_var.inner;
15942         if (ret_var.is_owned) {
15943                 ret_ref |= 1;
15944         }
15945         return ret_ref;
15946 }
15947
15948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15949         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15951         this_ptr_conv.is_owned = false;
15952         LDKOutPoint val_conv;
15953         val_conv.inner = (void*)(val & (~1));
15954         val_conv.is_owned = (val & 1) || (val == 0);
15955         val_conv = OutPoint_clone(&val_conv);
15956         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15957 }
15958
15959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15960         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15962         this_ptr_conv.is_owned = false;
15963         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15964         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15965 }
15966
15967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15968         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15970         this_ptr_conv.is_owned = false;
15971         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15972         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15973         return ret_arr;
15974 }
15975
15976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15977         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15979         this_ptr_conv.is_owned = false;
15980         LDKThirtyTwoBytes val_ref;
15981         CHECK((*env)->GetArrayLength(env, val) == 32);
15982         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15983         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15984 }
15985
15986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15987         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15989         this_ptr_conv.is_owned = false;
15990         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15991         return ret_val;
15992 }
15993
15994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15995         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15997         this_ptr_conv.is_owned = false;
15998         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15999 }
16000
16001 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) {
16002         LDKOutPoint outpoint_arg_conv;
16003         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
16004         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
16005         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
16006         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
16007         LDKThirtyTwoBytes channel_keys_id_arg_ref;
16008         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
16009         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
16010         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
16011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16013         uint64_t ret_ref = (uint64_t)ret_var.inner;
16014         if (ret_var.is_owned) {
16015                 ret_ref |= 1;
16016         }
16017         return ret_ref;
16018 }
16019
16020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16021         LDKStaticPaymentOutputDescriptor orig_conv;
16022         orig_conv.inner = (void*)(orig & (~1));
16023         orig_conv.is_owned = false;
16024         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
16025         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16026         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16027         uint64_t ret_ref = (uint64_t)ret_var.inner;
16028         if (ret_var.is_owned) {
16029                 ret_ref |= 1;
16030         }
16031         return ret_ref;
16032 }
16033
16034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
16035         LDKStaticPaymentOutputDescriptor obj_conv;
16036         obj_conv.inner = (void*)(obj & (~1));
16037         obj_conv.is_owned = false;
16038         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
16039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16041         CVec_u8Z_free(ret_var);
16042         return ret_arr;
16043 }
16044
16045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16046         LDKu8slice ser_ref;
16047         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16048         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16049         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16050         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
16051         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16052         return (uint64_t)ret_conv;
16053 }
16054
16055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16056         if ((this_ptr & 1) != 0) return;
16057         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
16058         FREE((void*)this_ptr);
16059         SpendableOutputDescriptor_free(this_ptr_conv);
16060 }
16061
16062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16063         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
16064         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16065         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
16066         uint64_t ret_ref = (uint64_t)ret_copy;
16067         return ret_ref;
16068 }
16069
16070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
16071         LDKOutPoint outpoint_conv;
16072         outpoint_conv.inner = (void*)(outpoint & (~1));
16073         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
16074         outpoint_conv = OutPoint_clone(&outpoint_conv);
16075         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
16076         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16077         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
16078         uint64_t ret_ref = (uint64_t)ret_copy;
16079         return ret_ref;
16080 }
16081
16082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
16083         LDKDelayedPaymentOutputDescriptor a_conv;
16084         a_conv.inner = (void*)(a & (~1));
16085         a_conv.is_owned = (a & 1) || (a == 0);
16086         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
16087         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16088         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
16089         uint64_t ret_ref = (uint64_t)ret_copy;
16090         return ret_ref;
16091 }
16092
16093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
16094         LDKStaticPaymentOutputDescriptor a_conv;
16095         a_conv.inner = (void*)(a & (~1));
16096         a_conv.is_owned = (a & 1) || (a == 0);
16097         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
16098         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16099         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
16100         uint64_t ret_ref = (uint64_t)ret_copy;
16101         return ret_ref;
16102 }
16103
16104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
16105         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
16106         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
16107         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16108         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16109         CVec_u8Z_free(ret_var);
16110         return ret_arr;
16111 }
16112
16113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16114         LDKu8slice ser_ref;
16115         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16116         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16117         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16118         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
16119         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16120         return (uint64_t)ret_conv;
16121 }
16122
16123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16124         if ((this_ptr & 1) != 0) return;
16125         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
16126         FREE((void*)this_ptr);
16127         BaseSign_free(this_ptr_conv);
16128 }
16129
16130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16131         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
16132         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
16133         *ret = Sign_clone(orig_conv);
16134         return (uint64_t)ret;
16135 }
16136
16137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16138         if ((this_ptr & 1) != 0) return;
16139         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
16140         FREE((void*)this_ptr);
16141         Sign_free(this_ptr_conv);
16142 }
16143
16144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16145         if ((this_ptr & 1) != 0) return;
16146         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
16147         FREE((void*)this_ptr);
16148         KeysInterface_free(this_ptr_conv);
16149 }
16150
16151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16152         LDKInMemorySigner this_obj_conv;
16153         this_obj_conv.inner = (void*)(this_obj & (~1));
16154         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16155         InMemorySigner_free(this_obj_conv);
16156 }
16157
16158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16159         LDKInMemorySigner this_ptr_conv;
16160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16161         this_ptr_conv.is_owned = false;
16162         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
16164         return ret_arr;
16165 }
16166
16167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16168         LDKInMemorySigner this_ptr_conv;
16169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16170         this_ptr_conv.is_owned = false;
16171         LDKSecretKey val_ref;
16172         CHECK((*env)->GetArrayLength(env, val) == 32);
16173         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16174         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
16175 }
16176
16177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16178         LDKInMemorySigner this_ptr_conv;
16179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16180         this_ptr_conv.is_owned = false;
16181         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
16183         return ret_arr;
16184 }
16185
16186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16187         LDKInMemorySigner this_ptr_conv;
16188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16189         this_ptr_conv.is_owned = false;
16190         LDKSecretKey val_ref;
16191         CHECK((*env)->GetArrayLength(env, val) == 32);
16192         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16193         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
16194 }
16195
16196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16197         LDKInMemorySigner this_ptr_conv;
16198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16199         this_ptr_conv.is_owned = false;
16200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
16202         return ret_arr;
16203 }
16204
16205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16206         LDKInMemorySigner this_ptr_conv;
16207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16208         this_ptr_conv.is_owned = false;
16209         LDKSecretKey val_ref;
16210         CHECK((*env)->GetArrayLength(env, val) == 32);
16211         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16212         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
16213 }
16214
16215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16216         LDKInMemorySigner this_ptr_conv;
16217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16218         this_ptr_conv.is_owned = false;
16219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
16221         return ret_arr;
16222 }
16223
16224 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) {
16225         LDKInMemorySigner this_ptr_conv;
16226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16227         this_ptr_conv.is_owned = false;
16228         LDKSecretKey val_ref;
16229         CHECK((*env)->GetArrayLength(env, val) == 32);
16230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16231         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
16232 }
16233
16234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
16235         LDKInMemorySigner this_ptr_conv;
16236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16237         this_ptr_conv.is_owned = false;
16238         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
16240         return ret_arr;
16241 }
16242
16243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16244         LDKInMemorySigner this_ptr_conv;
16245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16246         this_ptr_conv.is_owned = false;
16247         LDKSecretKey val_ref;
16248         CHECK((*env)->GetArrayLength(env, val) == 32);
16249         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
16250         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
16251 }
16252
16253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
16254         LDKInMemorySigner this_ptr_conv;
16255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16256         this_ptr_conv.is_owned = false;
16257         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16258         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
16259         return ret_arr;
16260 }
16261
16262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16263         LDKInMemorySigner this_ptr_conv;
16264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16265         this_ptr_conv.is_owned = false;
16266         LDKThirtyTwoBytes val_ref;
16267         CHECK((*env)->GetArrayLength(env, val) == 32);
16268         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16269         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
16270 }
16271
16272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16273         LDKInMemorySigner orig_conv;
16274         orig_conv.inner = (void*)(orig & (~1));
16275         orig_conv.is_owned = false;
16276         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
16277         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16278         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16279         uint64_t ret_ref = (uint64_t)ret_var.inner;
16280         if (ret_var.is_owned) {
16281                 ret_ref |= 1;
16282         }
16283         return ret_ref;
16284 }
16285
16286 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) {
16287         LDKSecretKey funding_key_ref;
16288         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
16289         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
16290         LDKSecretKey revocation_base_key_ref;
16291         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
16292         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
16293         LDKSecretKey payment_key_ref;
16294         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
16295         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
16296         LDKSecretKey delayed_payment_base_key_ref;
16297         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
16298         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
16299         LDKSecretKey htlc_base_key_ref;
16300         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
16301         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
16302         LDKThirtyTwoBytes commitment_seed_ref;
16303         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
16304         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
16305         LDKThirtyTwoBytes channel_keys_id_ref;
16306         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
16307         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
16308         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);
16309         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16310         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16311         uint64_t ret_ref = (uint64_t)ret_var.inner;
16312         if (ret_var.is_owned) {
16313                 ret_ref |= 1;
16314         }
16315         return ret_ref;
16316 }
16317
16318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
16319         LDKInMemorySigner this_arg_conv;
16320         this_arg_conv.inner = (void*)(this_arg & (~1));
16321         this_arg_conv.is_owned = false;
16322         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
16323         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16324         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16325         uint64_t ret_ref = (uint64_t)ret_var.inner;
16326         if (ret_var.is_owned) {
16327                 ret_ref |= 1;
16328         }
16329         return ret_ref;
16330 }
16331
16332 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
16333         LDKInMemorySigner this_arg_conv;
16334         this_arg_conv.inner = (void*)(this_arg & (~1));
16335         this_arg_conv.is_owned = false;
16336         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
16337         return ret_val;
16338 }
16339
16340 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
16341         LDKInMemorySigner this_arg_conv;
16342         this_arg_conv.inner = (void*)(this_arg & (~1));
16343         this_arg_conv.is_owned = false;
16344         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
16345         return ret_val;
16346 }
16347
16348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
16349         LDKInMemorySigner this_arg_conv;
16350         this_arg_conv.inner = (void*)(this_arg & (~1));
16351         this_arg_conv.is_owned = false;
16352         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
16353         return ret_val;
16354 }
16355
16356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
16357         LDKInMemorySigner this_arg_conv;
16358         this_arg_conv.inner = (void*)(this_arg & (~1));
16359         this_arg_conv.is_owned = false;
16360         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
16361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16363         uint64_t ret_ref = (uint64_t)ret_var.inner;
16364         if (ret_var.is_owned) {
16365                 ret_ref |= 1;
16366         }
16367         return ret_ref;
16368 }
16369
16370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
16371         LDKInMemorySigner this_arg_conv;
16372         this_arg_conv.inner = (void*)(this_arg & (~1));
16373         this_arg_conv.is_owned = false;
16374         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
16375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16377         uint64_t ret_ref = (uint64_t)ret_var.inner;
16378         if (ret_var.is_owned) {
16379                 ret_ref |= 1;
16380         }
16381         return ret_ref;
16382 }
16383
16384 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) {
16385         LDKInMemorySigner this_arg_conv;
16386         this_arg_conv.inner = (void*)(this_arg & (~1));
16387         this_arg_conv.is_owned = false;
16388         LDKTransaction spend_tx_ref;
16389         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16390         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16391         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16392         spend_tx_ref.data_is_owned = true;
16393         LDKStaticPaymentOutputDescriptor descriptor_conv;
16394         descriptor_conv.inner = (void*)(descriptor & (~1));
16395         descriptor_conv.is_owned = false;
16396         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16397         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16398         return (uint64_t)ret_conv;
16399 }
16400
16401 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) {
16402         LDKInMemorySigner this_arg_conv;
16403         this_arg_conv.inner = (void*)(this_arg & (~1));
16404         this_arg_conv.is_owned = false;
16405         LDKTransaction spend_tx_ref;
16406         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16407         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16408         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16409         spend_tx_ref.data_is_owned = true;
16410         LDKDelayedPaymentOutputDescriptor descriptor_conv;
16411         descriptor_conv.inner = (void*)(descriptor & (~1));
16412         descriptor_conv.is_owned = false;
16413         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16414         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16415         return (uint64_t)ret_conv;
16416 }
16417
16418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
16419         LDKInMemorySigner this_arg_conv;
16420         this_arg_conv.inner = (void*)(this_arg & (~1));
16421         this_arg_conv.is_owned = false;
16422         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
16423         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
16424         return (uint64_t)ret;
16425 }
16426
16427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
16428         LDKInMemorySigner this_arg_conv;
16429         this_arg_conv.inner = (void*)(this_arg & (~1));
16430         this_arg_conv.is_owned = false;
16431         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
16432         *ret = InMemorySigner_as_Sign(&this_arg_conv);
16433         return (uint64_t)ret;
16434 }
16435
16436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
16437         LDKInMemorySigner obj_conv;
16438         obj_conv.inner = (void*)(obj & (~1));
16439         obj_conv.is_owned = false;
16440         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
16441         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16442         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16443         CVec_u8Z_free(ret_var);
16444         return ret_arr;
16445 }
16446
16447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16448         LDKu8slice ser_ref;
16449         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16450         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16451         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16452         *ret_conv = InMemorySigner_read(ser_ref);
16453         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16454         return (uint64_t)ret_conv;
16455 }
16456
16457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16458         LDKKeysManager this_obj_conv;
16459         this_obj_conv.inner = (void*)(this_obj & (~1));
16460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16461         KeysManager_free(this_obj_conv);
16462 }
16463
16464 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) {
16465         unsigned char seed_arr[32];
16466         CHECK((*env)->GetArrayLength(env, seed) == 32);
16467         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
16468         unsigned char (*seed_ref)[32] = &seed_arr;
16469         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
16470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16472         uint64_t ret_ref = (uint64_t)ret_var.inner;
16473         if (ret_var.is_owned) {
16474                 ret_ref |= 1;
16475         }
16476         return ret_ref;
16477 }
16478
16479 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) {
16480         LDKKeysManager this_arg_conv;
16481         this_arg_conv.inner = (void*)(this_arg & (~1));
16482         this_arg_conv.is_owned = false;
16483         unsigned char params_arr[32];
16484         CHECK((*env)->GetArrayLength(env, params) == 32);
16485         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
16486         unsigned char (*params_ref)[32] = &params_arr;
16487         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
16488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16490         uint64_t ret_ref = (uint64_t)ret_var.inner;
16491         if (ret_var.is_owned) {
16492                 ret_ref |= 1;
16493         }
16494         return ret_ref;
16495 }
16496
16497 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) {
16498         LDKKeysManager this_arg_conv;
16499         this_arg_conv.inner = (void*)(this_arg & (~1));
16500         this_arg_conv.is_owned = false;
16501         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
16502         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
16503         if (descriptors_constr.datalen > 0)
16504                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16505         else
16506                 descriptors_constr.data = NULL;
16507         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
16508         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
16509                 int64_t descriptors_conv_27 = descriptors_vals[b];
16510                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
16511                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
16512                 descriptors_constr.data[b] = descriptors_conv_27_conv;
16513         }
16514         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
16515         LDKCVec_TxOutZ outputs_constr;
16516         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
16517         if (outputs_constr.datalen > 0)
16518                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16519         else
16520                 outputs_constr.data = NULL;
16521         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
16522         for (size_t h = 0; h < outputs_constr.datalen; h++) {
16523                 int64_t outputs_conv_7 = outputs_vals[h];
16524                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
16525                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
16526                 outputs_constr.data[h] = outputs_conv_7_conv;
16527         }
16528         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
16529         LDKCVec_u8Z change_destination_script_ref;
16530         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
16531         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
16532         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
16533         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16534         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
16535         return (uint64_t)ret_conv;
16536 }
16537
16538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
16539         LDKKeysManager this_arg_conv;
16540         this_arg_conv.inner = (void*)(this_arg & (~1));
16541         this_arg_conv.is_owned = false;
16542         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
16543         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
16544         return (uint64_t)ret;
16545 }
16546
16547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16548         LDKChannelManager this_obj_conv;
16549         this_obj_conv.inner = (void*)(this_obj & (~1));
16550         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16551         ChannelManager_free(this_obj_conv);
16552 }
16553
16554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16555         LDKChainParameters this_obj_conv;
16556         this_obj_conv.inner = (void*)(this_obj & (~1));
16557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16558         ChainParameters_free(this_obj_conv);
16559 }
16560
16561 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
16562         LDKChainParameters this_ptr_conv;
16563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16564         this_ptr_conv.is_owned = false;
16565         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
16566         return ret_conv;
16567 }
16568
16569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
16570         LDKChainParameters this_ptr_conv;
16571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16572         this_ptr_conv.is_owned = false;
16573         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
16574         ChainParameters_set_network(&this_ptr_conv, val_conv);
16575 }
16576
16577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
16578         LDKChainParameters this_ptr_conv;
16579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16580         this_ptr_conv.is_owned = false;
16581         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
16582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16584         uint64_t ret_ref = (uint64_t)ret_var.inner;
16585         if (ret_var.is_owned) {
16586                 ret_ref |= 1;
16587         }
16588         return ret_ref;
16589 }
16590
16591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16592         LDKChainParameters this_ptr_conv;
16593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16594         this_ptr_conv.is_owned = false;
16595         LDKBestBlock val_conv;
16596         val_conv.inner = (void*)(val & (~1));
16597         val_conv.is_owned = (val & 1) || (val == 0);
16598         val_conv = BestBlock_clone(&val_conv);
16599         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
16600 }
16601
16602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
16603         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
16604         LDKBestBlock best_block_arg_conv;
16605         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
16606         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
16607         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
16608         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
16609         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16610         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16611         uint64_t ret_ref = (uint64_t)ret_var.inner;
16612         if (ret_var.is_owned) {
16613                 ret_ref |= 1;
16614         }
16615         return ret_ref;
16616 }
16617
16618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16619         LDKChainParameters orig_conv;
16620         orig_conv.inner = (void*)(orig & (~1));
16621         orig_conv.is_owned = false;
16622         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
16623         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16624         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16625         uint64_t ret_ref = (uint64_t)ret_var.inner;
16626         if (ret_var.is_owned) {
16627                 ret_ref |= 1;
16628         }
16629         return ret_ref;
16630 }
16631
16632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16633         LDKChannelCounterparty this_obj_conv;
16634         this_obj_conv.inner = (void*)(this_obj & (~1));
16635         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16636         ChannelCounterparty_free(this_obj_conv);
16637 }
16638
16639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16640         LDKChannelCounterparty this_ptr_conv;
16641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16642         this_ptr_conv.is_owned = false;
16643         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
16645         return ret_arr;
16646 }
16647
16648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16649         LDKChannelCounterparty this_ptr_conv;
16650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16651         this_ptr_conv.is_owned = false;
16652         LDKPublicKey val_ref;
16653         CHECK((*env)->GetArrayLength(env, val) == 33);
16654         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16655         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
16656 }
16657
16658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16659         LDKChannelCounterparty this_ptr_conv;
16660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16661         this_ptr_conv.is_owned = false;
16662         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
16663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16665         uint64_t ret_ref = (uint64_t)ret_var.inner;
16666         if (ret_var.is_owned) {
16667                 ret_ref |= 1;
16668         }
16669         return ret_ref;
16670 }
16671
16672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16673         LDKChannelCounterparty this_ptr_conv;
16674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16675         this_ptr_conv.is_owned = false;
16676         LDKInitFeatures val_conv;
16677         val_conv.inner = (void*)(val & (~1));
16678         val_conv.is_owned = (val & 1) || (val == 0);
16679         val_conv = InitFeatures_clone(&val_conv);
16680         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
16681 }
16682
16683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16684         LDKChannelCounterparty this_ptr_conv;
16685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16686         this_ptr_conv.is_owned = false;
16687         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
16688         return ret_val;
16689 }
16690
16691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16692         LDKChannelCounterparty this_ptr_conv;
16693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16694         this_ptr_conv.is_owned = false;
16695         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
16696 }
16697
16698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16699         LDKChannelCounterparty orig_conv;
16700         orig_conv.inner = (void*)(orig & (~1));
16701         orig_conv.is_owned = false;
16702         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
16703         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16704         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16705         uint64_t ret_ref = (uint64_t)ret_var.inner;
16706         if (ret_var.is_owned) {
16707                 ret_ref |= 1;
16708         }
16709         return ret_ref;
16710 }
16711
16712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16713         LDKChannelDetails this_obj_conv;
16714         this_obj_conv.inner = (void*)(this_obj & (~1));
16715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16716         ChannelDetails_free(this_obj_conv);
16717 }
16718
16719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16720         LDKChannelDetails this_ptr_conv;
16721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16722         this_ptr_conv.is_owned = false;
16723         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
16725         return ret_arr;
16726 }
16727
16728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16729         LDKChannelDetails this_ptr_conv;
16730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16731         this_ptr_conv.is_owned = false;
16732         LDKThirtyTwoBytes val_ref;
16733         CHECK((*env)->GetArrayLength(env, val) == 32);
16734         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16735         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
16736 }
16737
16738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
16739         LDKChannelDetails this_ptr_conv;
16740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16741         this_ptr_conv.is_owned = false;
16742         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
16743         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16744         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16745         uint64_t ret_ref = (uint64_t)ret_var.inner;
16746         if (ret_var.is_owned) {
16747                 ret_ref |= 1;
16748         }
16749         return ret_ref;
16750 }
16751
16752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16753         LDKChannelDetails this_ptr_conv;
16754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16755         this_ptr_conv.is_owned = false;
16756         LDKChannelCounterparty val_conv;
16757         val_conv.inner = (void*)(val & (~1));
16758         val_conv.is_owned = (val & 1) || (val == 0);
16759         val_conv = ChannelCounterparty_clone(&val_conv);
16760         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
16761 }
16762
16763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
16764         LDKChannelDetails this_ptr_conv;
16765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16766         this_ptr_conv.is_owned = false;
16767         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
16768         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16769         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16770         uint64_t ret_ref = (uint64_t)ret_var.inner;
16771         if (ret_var.is_owned) {
16772                 ret_ref |= 1;
16773         }
16774         return ret_ref;
16775 }
16776
16777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16778         LDKChannelDetails this_ptr_conv;
16779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16780         this_ptr_conv.is_owned = false;
16781         LDKOutPoint val_conv;
16782         val_conv.inner = (void*)(val & (~1));
16783         val_conv.is_owned = (val & 1) || (val == 0);
16784         val_conv = OutPoint_clone(&val_conv);
16785         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
16786 }
16787
16788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16789         LDKChannelDetails this_ptr_conv;
16790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16791         this_ptr_conv.is_owned = false;
16792         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16793         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
16794         uint64_t ret_ref = (uint64_t)ret_copy;
16795         return ret_ref;
16796 }
16797
16798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16799         LDKChannelDetails this_ptr_conv;
16800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16801         this_ptr_conv.is_owned = false;
16802         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16803         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
16804 }
16805
16806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16807         LDKChannelDetails this_ptr_conv;
16808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16809         this_ptr_conv.is_owned = false;
16810         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
16811         return ret_val;
16812 }
16813
16814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16815         LDKChannelDetails this_ptr_conv;
16816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16817         this_ptr_conv.is_owned = false;
16818         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
16819 }
16820
16821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16822         LDKChannelDetails this_ptr_conv;
16823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16824         this_ptr_conv.is_owned = false;
16825         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16826         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16827         uint64_t ret_ref = (uint64_t)ret_copy;
16828         return ret_ref;
16829 }
16830
16831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16832         LDKChannelDetails this_ptr_conv;
16833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16834         this_ptr_conv.is_owned = false;
16835         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16836         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16837 }
16838
16839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16840         LDKChannelDetails this_ptr_conv;
16841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16842         this_ptr_conv.is_owned = false;
16843         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
16844         return ret_val;
16845 }
16846
16847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16848         LDKChannelDetails this_ptr_conv;
16849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16850         this_ptr_conv.is_owned = false;
16851         ChannelDetails_set_user_id(&this_ptr_conv, val);
16852 }
16853
16854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16855         LDKChannelDetails this_ptr_conv;
16856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16857         this_ptr_conv.is_owned = false;
16858         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16859         return ret_val;
16860 }
16861
16862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16863         LDKChannelDetails this_ptr_conv;
16864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16865         this_ptr_conv.is_owned = false;
16866         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16867 }
16868
16869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16870         LDKChannelDetails this_ptr_conv;
16871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16872         this_ptr_conv.is_owned = false;
16873         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16874         return ret_val;
16875 }
16876
16877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16878         LDKChannelDetails this_ptr_conv;
16879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16880         this_ptr_conv.is_owned = false;
16881         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16882 }
16883
16884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16885         LDKChannelDetails this_ptr_conv;
16886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16887         this_ptr_conv.is_owned = false;
16888         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16889         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16890         uint64_t ret_ref = (uint64_t)ret_copy;
16891         return ret_ref;
16892 }
16893
16894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16895         LDKChannelDetails this_ptr_conv;
16896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16897         this_ptr_conv.is_owned = false;
16898         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16899         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16900 }
16901
16902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16903         LDKChannelDetails this_ptr_conv;
16904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16905         this_ptr_conv.is_owned = false;
16906         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16907         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16908         uint64_t ret_ref = (uint64_t)ret_copy;
16909         return ret_ref;
16910 }
16911
16912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16913         LDKChannelDetails this_ptr_conv;
16914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16915         this_ptr_conv.is_owned = false;
16916         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16917         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16918 }
16919
16920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16921         LDKChannelDetails this_ptr_conv;
16922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16923         this_ptr_conv.is_owned = false;
16924         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16925         return ret_val;
16926 }
16927
16928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16929         LDKChannelDetails this_ptr_conv;
16930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16931         this_ptr_conv.is_owned = false;
16932         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16933 }
16934
16935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16936         LDKChannelDetails this_ptr_conv;
16937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16938         this_ptr_conv.is_owned = false;
16939         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16940         return ret_val;
16941 }
16942
16943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16944         LDKChannelDetails this_ptr_conv;
16945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16946         this_ptr_conv.is_owned = false;
16947         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16948 }
16949
16950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16951         LDKChannelDetails this_ptr_conv;
16952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16953         this_ptr_conv.is_owned = false;
16954         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16955         return ret_val;
16956 }
16957
16958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16959         LDKChannelDetails this_ptr_conv;
16960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16961         this_ptr_conv.is_owned = false;
16962         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16963 }
16964
16965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16966         LDKChannelDetails this_ptr_conv;
16967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16968         this_ptr_conv.is_owned = false;
16969         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16970         return ret_val;
16971 }
16972
16973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16974         LDKChannelDetails this_ptr_conv;
16975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16976         this_ptr_conv.is_owned = false;
16977         ChannelDetails_set_is_public(&this_ptr_conv, val);
16978 }
16979
16980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
16981         LDKThirtyTwoBytes channel_id_arg_ref;
16982         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16983         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16984         LDKChannelCounterparty counterparty_arg_conv;
16985         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16986         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16987         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16988         LDKOutPoint funding_txo_arg_conv;
16989         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16990         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16991         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16992         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16993         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16994         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16995         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16996         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
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 int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17007         LDKChannelDetails orig_conv;
17008         orig_conv.inner = (void*)(orig & (~1));
17009         orig_conv.is_owned = false;
17010         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
17011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17013         uint64_t ret_ref = (uint64_t)ret_var.inner;
17014         if (ret_var.is_owned) {
17015                 ret_ref |= 1;
17016         }
17017         return ret_ref;
17018 }
17019
17020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
17021         if ((this_ptr & 1) != 0) return;
17022         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
17023         FREE((void*)this_ptr);
17024         PaymentSendFailure_free(this_ptr_conv);
17025 }
17026
17027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17028         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
17029         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17030         *ret_copy = PaymentSendFailure_clone(orig_conv);
17031         uint64_t ret_ref = (uint64_t)ret_copy;
17032         return ret_ref;
17033 }
17034
17035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
17036         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
17037         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17038         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
17039         uint64_t ret_ref = (uint64_t)ret_copy;
17040         return ret_ref;
17041 }
17042
17043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
17044         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
17045         a_constr.datalen = (*env)->GetArrayLength(env, a);
17046         if (a_constr.datalen > 0)
17047                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17048         else
17049                 a_constr.data = NULL;
17050         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
17051         for (size_t w = 0; w < a_constr.datalen; w++) {
17052                 int64_t a_conv_22 = a_vals[w];
17053                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
17054                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
17055                 a_constr.data[w] = a_conv_22_conv;
17056         }
17057         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
17058         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17059         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
17060         uint64_t ret_ref = (uint64_t)ret_copy;
17061         return ret_ref;
17062 }
17063
17064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
17065         LDKCVec_APIErrorZ a_constr;
17066         a_constr.datalen = (*env)->GetArrayLength(env, a);
17067         if (a_constr.datalen > 0)
17068                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17069         else
17070                 a_constr.data = NULL;
17071         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
17072         for (size_t k = 0; k < a_constr.datalen; k++) {
17073                 int64_t a_conv_10 = a_vals[k];
17074                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
17075                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
17076                 a_constr.data[k] = a_conv_10_conv;
17077         }
17078         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
17079         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17080         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
17081         uint64_t ret_ref = (uint64_t)ret_copy;
17082         return ret_ref;
17083 }
17084
17085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
17086         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
17087         a_constr.datalen = (*env)->GetArrayLength(env, a);
17088         if (a_constr.datalen > 0)
17089                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17090         else
17091                 a_constr.data = NULL;
17092         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
17093         for (size_t w = 0; w < a_constr.datalen; w++) {
17094                 int64_t a_conv_22 = a_vals[w];
17095                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
17096                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
17097                 a_constr.data[w] = a_conv_22_conv;
17098         }
17099         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
17100         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17101         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
17102         uint64_t ret_ref = (uint64_t)ret_copy;
17103         return ret_ref;
17104 }
17105
17106 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) {
17107         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
17108         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
17109                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17110                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
17111         }
17112         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
17113         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
17114                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17115                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
17116         }
17117         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
17118         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17119                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17120                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
17121         }
17122         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17123         if (logger_conv.free == LDKLogger_JCalls_free) {
17124                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17125                 LDKLogger_JCalls_cloned(&logger_conv);
17126         }
17127         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
17128         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
17129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17130                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
17131         }
17132         LDKUserConfig config_conv;
17133         config_conv.inner = (void*)(config & (~1));
17134         config_conv.is_owned = (config & 1) || (config == 0);
17135         config_conv = UserConfig_clone(&config_conv);
17136         LDKChainParameters params_conv;
17137         params_conv.inner = (void*)(params & (~1));
17138         params_conv.is_owned = (params & 1) || (params == 0);
17139         params_conv = ChainParameters_clone(&params_conv);
17140         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
17141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17143         uint64_t ret_ref = (uint64_t)ret_var.inner;
17144         if (ret_var.is_owned) {
17145                 ret_ref |= 1;
17146         }
17147         return ret_ref;
17148 }
17149
17150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
17151         LDKChannelManager this_arg_conv;
17152         this_arg_conv.inner = (void*)(this_arg & (~1));
17153         this_arg_conv.is_owned = false;
17154         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
17155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17157         uint64_t ret_ref = (uint64_t)ret_var.inner;
17158         if (ret_var.is_owned) {
17159                 ret_ref |= 1;
17160         }
17161         return ret_ref;
17162 }
17163
17164 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) {
17165         LDKChannelManager this_arg_conv;
17166         this_arg_conv.inner = (void*)(this_arg & (~1));
17167         this_arg_conv.is_owned = false;
17168         LDKPublicKey their_network_key_ref;
17169         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
17170         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
17171         LDKUserConfig override_config_conv;
17172         override_config_conv.inner = (void*)(override_config & (~1));
17173         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
17174         override_config_conv = UserConfig_clone(&override_config_conv);
17175         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17176         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
17177         return (uint64_t)ret_conv;
17178 }
17179
17180 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
17181         LDKChannelManager this_arg_conv;
17182         this_arg_conv.inner = (void*)(this_arg & (~1));
17183         this_arg_conv.is_owned = false;
17184         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
17185         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17186         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17187         for (size_t q = 0; q < ret_var.datalen; q++) {
17188                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
17189                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17190                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17191                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
17192                 if (ret_conv_16_var.is_owned) {
17193                         ret_conv_16_ref |= 1;
17194                 }
17195                 ret_arr_ptr[q] = ret_conv_16_ref;
17196         }
17197         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17198         FREE(ret_var.data);
17199         return ret_arr;
17200 }
17201
17202 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
17203         LDKChannelManager this_arg_conv;
17204         this_arg_conv.inner = (void*)(this_arg & (~1));
17205         this_arg_conv.is_owned = false;
17206         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
17207         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
17208         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
17209         for (size_t q = 0; q < ret_var.datalen; q++) {
17210                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
17211                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17212                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17213                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
17214                 if (ret_conv_16_var.is_owned) {
17215                         ret_conv_16_ref |= 1;
17216                 }
17217                 ret_arr_ptr[q] = ret_conv_16_ref;
17218         }
17219         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
17220         FREE(ret_var.data);
17221         return ret_arr;
17222 }
17223
17224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
17225         LDKChannelManager this_arg_conv;
17226         this_arg_conv.inner = (void*)(this_arg & (~1));
17227         this_arg_conv.is_owned = false;
17228         unsigned char channel_id_arr[32];
17229         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17230         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
17231         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
17232         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17233         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
17234         return (uint64_t)ret_conv;
17235 }
17236
17237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
17238         LDKChannelManager this_arg_conv;
17239         this_arg_conv.inner = (void*)(this_arg & (~1));
17240         this_arg_conv.is_owned = false;
17241         unsigned char channel_id_arr[32];
17242         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17243         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
17244         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
17245         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17246         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
17247         return (uint64_t)ret_conv;
17248 }
17249
17250 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) {
17251         LDKChannelManager this_arg_conv;
17252         this_arg_conv.inner = (void*)(this_arg & (~1));
17253         this_arg_conv.is_owned = false;
17254         unsigned char channel_id_arr[32];
17255         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
17256         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
17257         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
17258         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17259         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
17260         return (uint64_t)ret_conv;
17261 }
17262
17263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
17264         LDKChannelManager this_arg_conv;
17265         this_arg_conv.inner = (void*)(this_arg & (~1));
17266         this_arg_conv.is_owned = false;
17267         ChannelManager_force_close_all_channels(&this_arg_conv);
17268 }
17269
17270 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) {
17271         LDKChannelManager this_arg_conv;
17272         this_arg_conv.inner = (void*)(this_arg & (~1));
17273         this_arg_conv.is_owned = false;
17274         LDKRoute route_conv;
17275         route_conv.inner = (void*)(route & (~1));
17276         route_conv.is_owned = false;
17277         LDKThirtyTwoBytes payment_hash_ref;
17278         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17279         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17280         LDKThirtyTwoBytes payment_secret_ref;
17281         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
17282         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
17283         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17284         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
17285         return (uint64_t)ret_conv;
17286 }
17287
17288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
17289         LDKChannelManager this_arg_conv;
17290         this_arg_conv.inner = (void*)(this_arg & (~1));
17291         this_arg_conv.is_owned = false;
17292         LDKRoute route_conv;
17293         route_conv.inner = (void*)(route & (~1));
17294         route_conv.is_owned = false;
17295         LDKThirtyTwoBytes payment_preimage_ref;
17296         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
17297         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
17298         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
17299         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
17300         return (uint64_t)ret_conv;
17301 }
17302
17303 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) {
17304         LDKChannelManager this_arg_conv;
17305         this_arg_conv.inner = (void*)(this_arg & (~1));
17306         this_arg_conv.is_owned = false;
17307         unsigned char temporary_channel_id_arr[32];
17308         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
17309         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
17310         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
17311         LDKTransaction funding_transaction_ref;
17312         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
17313         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
17314         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
17315         funding_transaction_ref.data_is_owned = true;
17316         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17317         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
17318         return (uint64_t)ret_conv;
17319 }
17320
17321 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) {
17322         LDKChannelManager this_arg_conv;
17323         this_arg_conv.inner = (void*)(this_arg & (~1));
17324         this_arg_conv.is_owned = false;
17325         LDKThreeBytes rgb_ref;
17326         CHECK((*env)->GetArrayLength(env, rgb) == 3);
17327         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
17328         LDKThirtyTwoBytes alias_ref;
17329         CHECK((*env)->GetArrayLength(env, alias) == 32);
17330         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
17331         LDKCVec_NetAddressZ addresses_constr;
17332         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
17333         if (addresses_constr.datalen > 0)
17334                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17335         else
17336                 addresses_constr.data = NULL;
17337         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
17338         for (size_t m = 0; m < addresses_constr.datalen; m++) {
17339                 int64_t addresses_conv_12 = addresses_vals[m];
17340                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
17341                 addresses_constr.data[m] = addresses_conv_12_conv;
17342         }
17343         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
17344         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
17345 }
17346
17347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
17348         LDKChannelManager this_arg_conv;
17349         this_arg_conv.inner = (void*)(this_arg & (~1));
17350         this_arg_conv.is_owned = false;
17351         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
17352 }
17353
17354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
17355         LDKChannelManager this_arg_conv;
17356         this_arg_conv.inner = (void*)(this_arg & (~1));
17357         this_arg_conv.is_owned = false;
17358         ChannelManager_timer_tick_occurred(&this_arg_conv);
17359 }
17360
17361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
17362         LDKChannelManager this_arg_conv;
17363         this_arg_conv.inner = (void*)(this_arg & (~1));
17364         this_arg_conv.is_owned = false;
17365         unsigned char payment_hash_arr[32];
17366         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17367         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
17368         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
17369         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
17370         return ret_val;
17371 }
17372
17373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
17374         LDKChannelManager this_arg_conv;
17375         this_arg_conv.inner = (void*)(this_arg & (~1));
17376         this_arg_conv.is_owned = false;
17377         LDKThirtyTwoBytes payment_preimage_ref;
17378         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
17379         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
17380         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
17381         return ret_val;
17382 }
17383
17384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17385         LDKChannelManager this_arg_conv;
17386         this_arg_conv.inner = (void*)(this_arg & (~1));
17387         this_arg_conv.is_owned = false;
17388         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
17390         return ret_arr;
17391 }
17392
17393 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) {
17394         LDKChannelManager this_arg_conv;
17395         this_arg_conv.inner = (void*)(this_arg & (~1));
17396         this_arg_conv.is_owned = false;
17397         LDKOutPoint funding_txo_conv;
17398         funding_txo_conv.inner = (void*)(funding_txo & (~1));
17399         funding_txo_conv.is_owned = false;
17400         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
17401 }
17402
17403 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) {
17404         LDKChannelManager this_arg_conv;
17405         this_arg_conv.inner = (void*)(this_arg & (~1));
17406         this_arg_conv.is_owned = false;
17407         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17408         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17409         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
17410         return (uint64_t)ret_ref;
17411 }
17412
17413 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) {
17414         LDKChannelManager this_arg_conv;
17415         this_arg_conv.inner = (void*)(this_arg & (~1));
17416         this_arg_conv.is_owned = false;
17417         LDKThirtyTwoBytes payment_hash_ref;
17418         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17419         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17420         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17421         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17422         *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);
17423         return (uint64_t)ret_conv;
17424 }
17425
17426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17427         LDKChannelManager this_arg_conv;
17428         this_arg_conv.inner = (void*)(this_arg & (~1));
17429         this_arg_conv.is_owned = false;
17430         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17431         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
17432         return (uint64_t)ret;
17433 }
17434
17435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17436         LDKChannelManager this_arg_conv;
17437         this_arg_conv.inner = (void*)(this_arg & (~1));
17438         this_arg_conv.is_owned = false;
17439         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
17440         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
17441         return (uint64_t)ret;
17442 }
17443
17444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
17445         LDKChannelManager this_arg_conv;
17446         this_arg_conv.inner = (void*)(this_arg & (~1));
17447         this_arg_conv.is_owned = false;
17448         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
17449         *ret = ChannelManager_as_Listen(&this_arg_conv);
17450         return (uint64_t)ret;
17451 }
17452
17453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
17454         LDKChannelManager this_arg_conv;
17455         this_arg_conv.inner = (void*)(this_arg & (~1));
17456         this_arg_conv.is_owned = false;
17457         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
17458         *ret = ChannelManager_as_Confirm(&this_arg_conv);
17459         return (uint64_t)ret;
17460 }
17461
17462 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) {
17463         LDKChannelManager this_arg_conv;
17464         this_arg_conv.inner = (void*)(this_arg & (~1));
17465         this_arg_conv.is_owned = false;
17466         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
17467         return ret_val;
17468 }
17469
17470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
17471         LDKChannelManager this_arg_conv;
17472         this_arg_conv.inner = (void*)(this_arg & (~1));
17473         this_arg_conv.is_owned = false;
17474         ChannelManager_await_persistable_update(&this_arg_conv);
17475 }
17476
17477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
17478         LDKChannelManager this_arg_conv;
17479         this_arg_conv.inner = (void*)(this_arg & (~1));
17480         this_arg_conv.is_owned = false;
17481         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
17482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17484         uint64_t ret_ref = (uint64_t)ret_var.inner;
17485         if (ret_var.is_owned) {
17486                 ret_ref |= 1;
17487         }
17488         return ret_ref;
17489 }
17490
17491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17492         LDKChannelManager this_arg_conv;
17493         this_arg_conv.inner = (void*)(this_arg & (~1));
17494         this_arg_conv.is_owned = false;
17495         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
17496         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
17497         return (uint64_t)ret;
17498 }
17499
17500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
17501         LDKChannelManager obj_conv;
17502         obj_conv.inner = (void*)(obj & (~1));
17503         obj_conv.is_owned = false;
17504         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
17505         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17506         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17507         CVec_u8Z_free(ret_var);
17508         return ret_arr;
17509 }
17510
17511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17512         LDKChannelManagerReadArgs this_obj_conv;
17513         this_obj_conv.inner = (void*)(this_obj & (~1));
17514         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17515         ChannelManagerReadArgs_free(this_obj_conv);
17516 }
17517
17518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
17519         LDKChannelManagerReadArgs this_ptr_conv;
17520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17521         this_ptr_conv.is_owned = false;
17522         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
17523         return ret_ret;
17524 }
17525
17526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17527         LDKChannelManagerReadArgs this_ptr_conv;
17528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17529         this_ptr_conv.is_owned = false;
17530         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
17531         if (val_conv.free == LDKKeysInterface_JCalls_free) {
17532                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17533                 LDKKeysInterface_JCalls_cloned(&val_conv);
17534         }
17535         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
17536 }
17537
17538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
17539         LDKChannelManagerReadArgs this_ptr_conv;
17540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17541         this_ptr_conv.is_owned = false;
17542         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
17543         return ret_ret;
17544 }
17545
17546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17547         LDKChannelManagerReadArgs this_ptr_conv;
17548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17549         this_ptr_conv.is_owned = false;
17550         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
17551         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
17552                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17553                 LDKFeeEstimator_JCalls_cloned(&val_conv);
17554         }
17555         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
17556 }
17557
17558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
17559         LDKChannelManagerReadArgs this_ptr_conv;
17560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17561         this_ptr_conv.is_owned = false;
17562         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
17563         return ret_ret;
17564 }
17565
17566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17567         LDKChannelManagerReadArgs this_ptr_conv;
17568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17569         this_ptr_conv.is_owned = false;
17570         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
17571         if (val_conv.free == LDKWatch_JCalls_free) {
17572                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17573                 LDKWatch_JCalls_cloned(&val_conv);
17574         }
17575         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
17576 }
17577
17578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
17579         LDKChannelManagerReadArgs this_ptr_conv;
17580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17581         this_ptr_conv.is_owned = false;
17582         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
17583         return ret_ret;
17584 }
17585
17586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17587         LDKChannelManagerReadArgs this_ptr_conv;
17588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17589         this_ptr_conv.is_owned = false;
17590         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
17591         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
17592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17593                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
17594         }
17595         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
17596 }
17597
17598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
17599         LDKChannelManagerReadArgs this_ptr_conv;
17600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17601         this_ptr_conv.is_owned = false;
17602         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
17603         return ret_ret;
17604 }
17605
17606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17607         LDKChannelManagerReadArgs this_ptr_conv;
17608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17609         this_ptr_conv.is_owned = false;
17610         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
17611         if (val_conv.free == LDKLogger_JCalls_free) {
17612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17613                 LDKLogger_JCalls_cloned(&val_conv);
17614         }
17615         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
17616 }
17617
17618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
17619         LDKChannelManagerReadArgs this_ptr_conv;
17620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17621         this_ptr_conv.is_owned = false;
17622         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
17623         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17624         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17625         uint64_t ret_ref = (uint64_t)ret_var.inner;
17626         if (ret_var.is_owned) {
17627                 ret_ref |= 1;
17628         }
17629         return ret_ref;
17630 }
17631
17632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17633         LDKChannelManagerReadArgs this_ptr_conv;
17634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17635         this_ptr_conv.is_owned = false;
17636         LDKUserConfig val_conv;
17637         val_conv.inner = (void*)(val & (~1));
17638         val_conv.is_owned = (val & 1) || (val == 0);
17639         val_conv = UserConfig_clone(&val_conv);
17640         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
17641 }
17642
17643 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) {
17644         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
17645         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
17646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17647                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
17648         }
17649         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17650         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17651                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17652                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17653         }
17654         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
17655         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
17656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17657                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
17658         }
17659         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
17660         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17661                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17662                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
17663         }
17664         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17665         if (logger_conv.free == LDKLogger_JCalls_free) {
17666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17667                 LDKLogger_JCalls_cloned(&logger_conv);
17668         }
17669         LDKUserConfig default_config_conv;
17670         default_config_conv.inner = (void*)(default_config & (~1));
17671         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
17672         default_config_conv = UserConfig_clone(&default_config_conv);
17673         LDKCVec_ChannelMonitorZ channel_monitors_constr;
17674         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
17675         if (channel_monitors_constr.datalen > 0)
17676                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
17677         else
17678                 channel_monitors_constr.data = NULL;
17679         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
17680         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
17681                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
17682                 LDKChannelMonitor channel_monitors_conv_16_conv;
17683                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
17684                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
17685                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
17686         }
17687         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
17688         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);
17689         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17690         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17691         uint64_t ret_ref = (uint64_t)ret_var.inner;
17692         if (ret_var.is_owned) {
17693                 ret_ref |= 1;
17694         }
17695         return ret_ref;
17696 }
17697
17698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
17699         LDKu8slice ser_ref;
17700         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17701         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17702         LDKChannelManagerReadArgs arg_conv;
17703         arg_conv.inner = (void*)(arg & (~1));
17704         arg_conv.is_owned = (arg & 1) || (arg == 0);
17705         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
17706         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
17707         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
17708         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17709         return (uint64_t)ret_conv;
17710 }
17711
17712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17713         LDKDecodeError this_obj_conv;
17714         this_obj_conv.inner = (void*)(this_obj & (~1));
17715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17716         DecodeError_free(this_obj_conv);
17717 }
17718
17719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17720         LDKDecodeError orig_conv;
17721         orig_conv.inner = (void*)(orig & (~1));
17722         orig_conv.is_owned = false;
17723         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
17724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17726         uint64_t ret_ref = (uint64_t)ret_var.inner;
17727         if (ret_var.is_owned) {
17728                 ret_ref |= 1;
17729         }
17730         return ret_ref;
17731 }
17732
17733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17734         LDKInit this_obj_conv;
17735         this_obj_conv.inner = (void*)(this_obj & (~1));
17736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17737         Init_free(this_obj_conv);
17738 }
17739
17740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
17741         LDKInit this_ptr_conv;
17742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17743         this_ptr_conv.is_owned = false;
17744         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
17745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17747         uint64_t ret_ref = (uint64_t)ret_var.inner;
17748         if (ret_var.is_owned) {
17749                 ret_ref |= 1;
17750         }
17751         return ret_ref;
17752 }
17753
17754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17755         LDKInit this_ptr_conv;
17756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17757         this_ptr_conv.is_owned = false;
17758         LDKInitFeatures val_conv;
17759         val_conv.inner = (void*)(val & (~1));
17760         val_conv.is_owned = (val & 1) || (val == 0);
17761         val_conv = InitFeatures_clone(&val_conv);
17762         Init_set_features(&this_ptr_conv, val_conv);
17763 }
17764
17765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
17766         LDKInitFeatures features_arg_conv;
17767         features_arg_conv.inner = (void*)(features_arg & (~1));
17768         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17769         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17770         LDKInit ret_var = Init_new(features_arg_conv);
17771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17773         uint64_t ret_ref = (uint64_t)ret_var.inner;
17774         if (ret_var.is_owned) {
17775                 ret_ref |= 1;
17776         }
17777         return ret_ref;
17778 }
17779
17780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17781         LDKInit orig_conv;
17782         orig_conv.inner = (void*)(orig & (~1));
17783         orig_conv.is_owned = false;
17784         LDKInit ret_var = Init_clone(&orig_conv);
17785         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17786         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17787         uint64_t ret_ref = (uint64_t)ret_var.inner;
17788         if (ret_var.is_owned) {
17789                 ret_ref |= 1;
17790         }
17791         return ret_ref;
17792 }
17793
17794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17795         LDKErrorMessage this_obj_conv;
17796         this_obj_conv.inner = (void*)(this_obj & (~1));
17797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17798         ErrorMessage_free(this_obj_conv);
17799 }
17800
17801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17802         LDKErrorMessage this_ptr_conv;
17803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17804         this_ptr_conv.is_owned = false;
17805         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17806         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
17807         return ret_arr;
17808 }
17809
17810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17811         LDKErrorMessage this_ptr_conv;
17812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17813         this_ptr_conv.is_owned = false;
17814         LDKThirtyTwoBytes val_ref;
17815         CHECK((*env)->GetArrayLength(env, val) == 32);
17816         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17817         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
17818 }
17819
17820 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
17821         LDKErrorMessage this_ptr_conv;
17822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17823         this_ptr_conv.is_owned = false;
17824         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
17825         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
17826         Str_free(ret_str);
17827         return ret_conv;
17828 }
17829
17830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
17831         LDKErrorMessage this_ptr_conv;
17832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17833         this_ptr_conv.is_owned = false;
17834         LDKStr val_conv = java_to_owned_str(env, val);
17835         ErrorMessage_set_data(&this_ptr_conv, val_conv);
17836 }
17837
17838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
17839         LDKThirtyTwoBytes channel_id_arg_ref;
17840         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17841         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17842         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
17843         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
17844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17846         uint64_t ret_ref = (uint64_t)ret_var.inner;
17847         if (ret_var.is_owned) {
17848                 ret_ref |= 1;
17849         }
17850         return ret_ref;
17851 }
17852
17853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17854         LDKErrorMessage orig_conv;
17855         orig_conv.inner = (void*)(orig & (~1));
17856         orig_conv.is_owned = false;
17857         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
17858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17860         uint64_t ret_ref = (uint64_t)ret_var.inner;
17861         if (ret_var.is_owned) {
17862                 ret_ref |= 1;
17863         }
17864         return ret_ref;
17865 }
17866
17867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17868         LDKPing this_obj_conv;
17869         this_obj_conv.inner = (void*)(this_obj & (~1));
17870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17871         Ping_free(this_obj_conv);
17872 }
17873
17874 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17875         LDKPing this_ptr_conv;
17876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17877         this_ptr_conv.is_owned = false;
17878         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17879         return ret_val;
17880 }
17881
17882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17883         LDKPing this_ptr_conv;
17884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17885         this_ptr_conv.is_owned = false;
17886         Ping_set_ponglen(&this_ptr_conv, val);
17887 }
17888
17889 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17890         LDKPing this_ptr_conv;
17891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17892         this_ptr_conv.is_owned = false;
17893         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17894         return ret_val;
17895 }
17896
17897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17898         LDKPing this_ptr_conv;
17899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17900         this_ptr_conv.is_owned = false;
17901         Ping_set_byteslen(&this_ptr_conv, val);
17902 }
17903
17904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
17905         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17908         uint64_t ret_ref = (uint64_t)ret_var.inner;
17909         if (ret_var.is_owned) {
17910                 ret_ref |= 1;
17911         }
17912         return ret_ref;
17913 }
17914
17915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17916         LDKPing orig_conv;
17917         orig_conv.inner = (void*)(orig & (~1));
17918         orig_conv.is_owned = false;
17919         LDKPing ret_var = Ping_clone(&orig_conv);
17920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17922         uint64_t ret_ref = (uint64_t)ret_var.inner;
17923         if (ret_var.is_owned) {
17924                 ret_ref |= 1;
17925         }
17926         return ret_ref;
17927 }
17928
17929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17930         LDKPong this_obj_conv;
17931         this_obj_conv.inner = (void*)(this_obj & (~1));
17932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17933         Pong_free(this_obj_conv);
17934 }
17935
17936 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17937         LDKPong this_ptr_conv;
17938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17939         this_ptr_conv.is_owned = false;
17940         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17941         return ret_val;
17942 }
17943
17944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17945         LDKPong this_ptr_conv;
17946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17947         this_ptr_conv.is_owned = false;
17948         Pong_set_byteslen(&this_ptr_conv, val);
17949 }
17950
17951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
17952         LDKPong ret_var = Pong_new(byteslen_arg);
17953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17955         uint64_t ret_ref = (uint64_t)ret_var.inner;
17956         if (ret_var.is_owned) {
17957                 ret_ref |= 1;
17958         }
17959         return ret_ref;
17960 }
17961
17962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17963         LDKPong orig_conv;
17964         orig_conv.inner = (void*)(orig & (~1));
17965         orig_conv.is_owned = false;
17966         LDKPong ret_var = Pong_clone(&orig_conv);
17967         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17968         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17969         uint64_t ret_ref = (uint64_t)ret_var.inner;
17970         if (ret_var.is_owned) {
17971                 ret_ref |= 1;
17972         }
17973         return ret_ref;
17974 }
17975
17976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17977         LDKOpenChannel this_obj_conv;
17978         this_obj_conv.inner = (void*)(this_obj & (~1));
17979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17980         OpenChannel_free(this_obj_conv);
17981 }
17982
17983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17984         LDKOpenChannel this_ptr_conv;
17985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17986         this_ptr_conv.is_owned = false;
17987         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17988         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17989         return ret_arr;
17990 }
17991
17992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17993         LDKOpenChannel this_ptr_conv;
17994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17995         this_ptr_conv.is_owned = false;
17996         LDKThirtyTwoBytes val_ref;
17997         CHECK((*env)->GetArrayLength(env, val) == 32);
17998         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17999         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
18000 }
18001
18002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18003         LDKOpenChannel this_ptr_conv;
18004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18005         this_ptr_conv.is_owned = false;
18006         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
18008         return ret_arr;
18009 }
18010
18011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18012         LDKOpenChannel this_ptr_conv;
18013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18014         this_ptr_conv.is_owned = false;
18015         LDKThirtyTwoBytes val_ref;
18016         CHECK((*env)->GetArrayLength(env, val) == 32);
18017         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18018         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
18019 }
18020
18021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18022         LDKOpenChannel this_ptr_conv;
18023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18024         this_ptr_conv.is_owned = false;
18025         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
18026         return ret_val;
18027 }
18028
18029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18030         LDKOpenChannel this_ptr_conv;
18031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18032         this_ptr_conv.is_owned = false;
18033         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
18034 }
18035
18036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18037         LDKOpenChannel this_ptr_conv;
18038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18039         this_ptr_conv.is_owned = false;
18040         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
18041         return ret_val;
18042 }
18043
18044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18045         LDKOpenChannel this_ptr_conv;
18046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18047         this_ptr_conv.is_owned = false;
18048         OpenChannel_set_push_msat(&this_ptr_conv, val);
18049 }
18050
18051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18052         LDKOpenChannel this_ptr_conv;
18053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18054         this_ptr_conv.is_owned = false;
18055         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
18056         return ret_val;
18057 }
18058
18059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18060         LDKOpenChannel this_ptr_conv;
18061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18062         this_ptr_conv.is_owned = false;
18063         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
18064 }
18065
18066 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) {
18067         LDKOpenChannel this_ptr_conv;
18068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18069         this_ptr_conv.is_owned = false;
18070         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
18071         return ret_val;
18072 }
18073
18074 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) {
18075         LDKOpenChannel this_ptr_conv;
18076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18077         this_ptr_conv.is_owned = false;
18078         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
18079 }
18080
18081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18082         LDKOpenChannel this_ptr_conv;
18083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18084         this_ptr_conv.is_owned = false;
18085         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
18086         return ret_val;
18087 }
18088
18089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18090         LDKOpenChannel this_ptr_conv;
18091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18092         this_ptr_conv.is_owned = false;
18093         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
18094 }
18095
18096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18097         LDKOpenChannel this_ptr_conv;
18098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18099         this_ptr_conv.is_owned = false;
18100         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
18101         return ret_val;
18102 }
18103
18104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18105         LDKOpenChannel this_ptr_conv;
18106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18107         this_ptr_conv.is_owned = false;
18108         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
18109 }
18110
18111 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
18112         LDKOpenChannel this_ptr_conv;
18113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18114         this_ptr_conv.is_owned = false;
18115         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
18116         return ret_val;
18117 }
18118
18119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18120         LDKOpenChannel this_ptr_conv;
18121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18122         this_ptr_conv.is_owned = false;
18123         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
18124 }
18125
18126 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18127         LDKOpenChannel this_ptr_conv;
18128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18129         this_ptr_conv.is_owned = false;
18130         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
18131         return ret_val;
18132 }
18133
18134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18135         LDKOpenChannel this_ptr_conv;
18136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18137         this_ptr_conv.is_owned = false;
18138         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
18139 }
18140
18141 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
18142         LDKOpenChannel this_ptr_conv;
18143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18144         this_ptr_conv.is_owned = false;
18145         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
18146         return ret_val;
18147 }
18148
18149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18150         LDKOpenChannel this_ptr_conv;
18151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18152         this_ptr_conv.is_owned = false;
18153         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
18154 }
18155
18156 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18157         LDKOpenChannel this_ptr_conv;
18158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18159         this_ptr_conv.is_owned = false;
18160         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18161         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
18162         return ret_arr;
18163 }
18164
18165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18166         LDKOpenChannel this_ptr_conv;
18167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18168         this_ptr_conv.is_owned = false;
18169         LDKPublicKey val_ref;
18170         CHECK((*env)->GetArrayLength(env, val) == 33);
18171         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18172         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
18173 }
18174
18175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18176         LDKOpenChannel this_ptr_conv;
18177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18178         this_ptr_conv.is_owned = false;
18179         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18181         return ret_arr;
18182 }
18183
18184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18185         LDKOpenChannel this_ptr_conv;
18186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18187         this_ptr_conv.is_owned = false;
18188         LDKPublicKey val_ref;
18189         CHECK((*env)->GetArrayLength(env, val) == 33);
18190         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18191         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
18192 }
18193
18194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18195         LDKOpenChannel this_ptr_conv;
18196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18197         this_ptr_conv.is_owned = false;
18198         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
18200         return ret_arr;
18201 }
18202
18203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18204         LDKOpenChannel this_ptr_conv;
18205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18206         this_ptr_conv.is_owned = false;
18207         LDKPublicKey val_ref;
18208         CHECK((*env)->GetArrayLength(env, val) == 33);
18209         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18210         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
18211 }
18212
18213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18214         LDKOpenChannel this_ptr_conv;
18215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18216         this_ptr_conv.is_owned = false;
18217         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18219         return ret_arr;
18220 }
18221
18222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18223         LDKOpenChannel this_ptr_conv;
18224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18225         this_ptr_conv.is_owned = false;
18226         LDKPublicKey val_ref;
18227         CHECK((*env)->GetArrayLength(env, val) == 33);
18228         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18229         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18230 }
18231
18232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18233         LDKOpenChannel this_ptr_conv;
18234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18235         this_ptr_conv.is_owned = false;
18236         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18238         return ret_arr;
18239 }
18240
18241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18242         LDKOpenChannel this_ptr_conv;
18243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18244         this_ptr_conv.is_owned = false;
18245         LDKPublicKey val_ref;
18246         CHECK((*env)->GetArrayLength(env, val) == 33);
18247         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18248         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
18249 }
18250
18251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18252         LDKOpenChannel this_ptr_conv;
18253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18254         this_ptr_conv.is_owned = false;
18255         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18256         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
18257         return ret_arr;
18258 }
18259
18260 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) {
18261         LDKOpenChannel this_ptr_conv;
18262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18263         this_ptr_conv.is_owned = false;
18264         LDKPublicKey val_ref;
18265         CHECK((*env)->GetArrayLength(env, val) == 33);
18266         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18267         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
18268 }
18269
18270 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
18271         LDKOpenChannel this_ptr_conv;
18272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18273         this_ptr_conv.is_owned = false;
18274         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
18275         return ret_val;
18276 }
18277
18278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
18279         LDKOpenChannel this_ptr_conv;
18280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18281         this_ptr_conv.is_owned = false;
18282         OpenChannel_set_channel_flags(&this_ptr_conv, val);
18283 }
18284
18285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18286         LDKOpenChannel orig_conv;
18287         orig_conv.inner = (void*)(orig & (~1));
18288         orig_conv.is_owned = false;
18289         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
18290         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18291         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18292         uint64_t ret_ref = (uint64_t)ret_var.inner;
18293         if (ret_var.is_owned) {
18294                 ret_ref |= 1;
18295         }
18296         return ret_ref;
18297 }
18298
18299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18300         LDKAcceptChannel this_obj_conv;
18301         this_obj_conv.inner = (void*)(this_obj & (~1));
18302         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18303         AcceptChannel_free(this_obj_conv);
18304 }
18305
18306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18307         LDKAcceptChannel this_ptr_conv;
18308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18309         this_ptr_conv.is_owned = false;
18310         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
18312         return ret_arr;
18313 }
18314
18315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18316         LDKAcceptChannel this_ptr_conv;
18317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18318         this_ptr_conv.is_owned = false;
18319         LDKThirtyTwoBytes val_ref;
18320         CHECK((*env)->GetArrayLength(env, val) == 32);
18321         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18322         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
18323 }
18324
18325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18326         LDKAcceptChannel this_ptr_conv;
18327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18328         this_ptr_conv.is_owned = false;
18329         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
18330         return ret_val;
18331 }
18332
18333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18334         LDKAcceptChannel this_ptr_conv;
18335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18336         this_ptr_conv.is_owned = false;
18337         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
18338 }
18339
18340 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) {
18341         LDKAcceptChannel this_ptr_conv;
18342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18343         this_ptr_conv.is_owned = false;
18344         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
18345         return ret_val;
18346 }
18347
18348 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) {
18349         LDKAcceptChannel this_ptr_conv;
18350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18351         this_ptr_conv.is_owned = false;
18352         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
18353 }
18354
18355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18356         LDKAcceptChannel this_ptr_conv;
18357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18358         this_ptr_conv.is_owned = false;
18359         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
18360         return ret_val;
18361 }
18362
18363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18364         LDKAcceptChannel this_ptr_conv;
18365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18366         this_ptr_conv.is_owned = false;
18367         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
18368 }
18369
18370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18371         LDKAcceptChannel this_ptr_conv;
18372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18373         this_ptr_conv.is_owned = false;
18374         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
18375         return ret_val;
18376 }
18377
18378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18379         LDKAcceptChannel this_ptr_conv;
18380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18381         this_ptr_conv.is_owned = false;
18382         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
18383 }
18384
18385 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
18386         LDKAcceptChannel this_ptr_conv;
18387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18388         this_ptr_conv.is_owned = false;
18389         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
18390         return ret_val;
18391 }
18392
18393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18394         LDKAcceptChannel this_ptr_conv;
18395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18396         this_ptr_conv.is_owned = false;
18397         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
18398 }
18399
18400 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18401         LDKAcceptChannel this_ptr_conv;
18402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18403         this_ptr_conv.is_owned = false;
18404         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
18405         return ret_val;
18406 }
18407
18408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18409         LDKAcceptChannel this_ptr_conv;
18410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18411         this_ptr_conv.is_owned = false;
18412         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
18413 }
18414
18415 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
18416         LDKAcceptChannel this_ptr_conv;
18417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18418         this_ptr_conv.is_owned = false;
18419         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
18420         return ret_val;
18421 }
18422
18423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18424         LDKAcceptChannel this_ptr_conv;
18425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18426         this_ptr_conv.is_owned = false;
18427         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
18428 }
18429
18430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18431         LDKAcceptChannel this_ptr_conv;
18432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18433         this_ptr_conv.is_owned = false;
18434         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
18436         return ret_arr;
18437 }
18438
18439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18440         LDKAcceptChannel this_ptr_conv;
18441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18442         this_ptr_conv.is_owned = false;
18443         LDKPublicKey val_ref;
18444         CHECK((*env)->GetArrayLength(env, val) == 33);
18445         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18446         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
18447 }
18448
18449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18450         LDKAcceptChannel this_ptr_conv;
18451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18452         this_ptr_conv.is_owned = false;
18453         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18455         return ret_arr;
18456 }
18457
18458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18459         LDKAcceptChannel this_ptr_conv;
18460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18461         this_ptr_conv.is_owned = false;
18462         LDKPublicKey val_ref;
18463         CHECK((*env)->GetArrayLength(env, val) == 33);
18464         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18465         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
18466 }
18467
18468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18469         LDKAcceptChannel this_ptr_conv;
18470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18471         this_ptr_conv.is_owned = false;
18472         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
18474         return ret_arr;
18475 }
18476
18477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18478         LDKAcceptChannel this_ptr_conv;
18479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18480         this_ptr_conv.is_owned = false;
18481         LDKPublicKey val_ref;
18482         CHECK((*env)->GetArrayLength(env, val) == 33);
18483         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18484         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
18485 }
18486
18487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18488         LDKAcceptChannel this_ptr_conv;
18489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18490         this_ptr_conv.is_owned = false;
18491         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18493         return ret_arr;
18494 }
18495
18496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18497         LDKAcceptChannel this_ptr_conv;
18498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18499         this_ptr_conv.is_owned = false;
18500         LDKPublicKey val_ref;
18501         CHECK((*env)->GetArrayLength(env, val) == 33);
18502         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18503         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18504 }
18505
18506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18507         LDKAcceptChannel this_ptr_conv;
18508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18509         this_ptr_conv.is_owned = false;
18510         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18512         return ret_arr;
18513 }
18514
18515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18516         LDKAcceptChannel this_ptr_conv;
18517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18518         this_ptr_conv.is_owned = false;
18519         LDKPublicKey val_ref;
18520         CHECK((*env)->GetArrayLength(env, val) == 33);
18521         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18522         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
18523 }
18524
18525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18526         LDKAcceptChannel this_ptr_conv;
18527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18528         this_ptr_conv.is_owned = false;
18529         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
18531         return ret_arr;
18532 }
18533
18534 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) {
18535         LDKAcceptChannel this_ptr_conv;
18536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18537         this_ptr_conv.is_owned = false;
18538         LDKPublicKey val_ref;
18539         CHECK((*env)->GetArrayLength(env, val) == 33);
18540         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18541         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
18542 }
18543
18544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18545         LDKAcceptChannel orig_conv;
18546         orig_conv.inner = (void*)(orig & (~1));
18547         orig_conv.is_owned = false;
18548         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
18549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18551         uint64_t ret_ref = (uint64_t)ret_var.inner;
18552         if (ret_var.is_owned) {
18553                 ret_ref |= 1;
18554         }
18555         return ret_ref;
18556 }
18557
18558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18559         LDKFundingCreated this_obj_conv;
18560         this_obj_conv.inner = (void*)(this_obj & (~1));
18561         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18562         FundingCreated_free(this_obj_conv);
18563 }
18564
18565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18566         LDKFundingCreated this_ptr_conv;
18567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18568         this_ptr_conv.is_owned = false;
18569         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
18571         return ret_arr;
18572 }
18573
18574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18575         LDKFundingCreated this_ptr_conv;
18576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18577         this_ptr_conv.is_owned = false;
18578         LDKThirtyTwoBytes val_ref;
18579         CHECK((*env)->GetArrayLength(env, val) == 32);
18580         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18581         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
18582 }
18583
18584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18585         LDKFundingCreated this_ptr_conv;
18586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18587         this_ptr_conv.is_owned = false;
18588         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
18590         return ret_arr;
18591 }
18592
18593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18594         LDKFundingCreated this_ptr_conv;
18595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18596         this_ptr_conv.is_owned = false;
18597         LDKThirtyTwoBytes val_ref;
18598         CHECK((*env)->GetArrayLength(env, val) == 32);
18599         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18600         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
18601 }
18602
18603 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18604         LDKFundingCreated this_ptr_conv;
18605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18606         this_ptr_conv.is_owned = false;
18607         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
18608         return ret_val;
18609 }
18610
18611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18612         LDKFundingCreated this_ptr_conv;
18613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18614         this_ptr_conv.is_owned = false;
18615         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
18616 }
18617
18618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18619         LDKFundingCreated this_ptr_conv;
18620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18621         this_ptr_conv.is_owned = false;
18622         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
18624         return ret_arr;
18625 }
18626
18627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18628         LDKFundingCreated this_ptr_conv;
18629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18630         this_ptr_conv.is_owned = false;
18631         LDKSignature val_ref;
18632         CHECK((*env)->GetArrayLength(env, val) == 64);
18633         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18634         FundingCreated_set_signature(&this_ptr_conv, val_ref);
18635 }
18636
18637 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) {
18638         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
18639         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
18640         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
18641         LDKThirtyTwoBytes funding_txid_arg_ref;
18642         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
18643         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
18644         LDKSignature signature_arg_ref;
18645         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18646         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18647         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
18648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18650         uint64_t ret_ref = (uint64_t)ret_var.inner;
18651         if (ret_var.is_owned) {
18652                 ret_ref |= 1;
18653         }
18654         return ret_ref;
18655 }
18656
18657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18658         LDKFundingCreated orig_conv;
18659         orig_conv.inner = (void*)(orig & (~1));
18660         orig_conv.is_owned = false;
18661         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
18662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18664         uint64_t ret_ref = (uint64_t)ret_var.inner;
18665         if (ret_var.is_owned) {
18666                 ret_ref |= 1;
18667         }
18668         return ret_ref;
18669 }
18670
18671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18672         LDKFundingSigned this_obj_conv;
18673         this_obj_conv.inner = (void*)(this_obj & (~1));
18674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18675         FundingSigned_free(this_obj_conv);
18676 }
18677
18678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18679         LDKFundingSigned this_ptr_conv;
18680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18681         this_ptr_conv.is_owned = false;
18682         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18683         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
18684         return ret_arr;
18685 }
18686
18687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18688         LDKFundingSigned this_ptr_conv;
18689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18690         this_ptr_conv.is_owned = false;
18691         LDKThirtyTwoBytes val_ref;
18692         CHECK((*env)->GetArrayLength(env, val) == 32);
18693         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18694         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
18695 }
18696
18697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18698         LDKFundingSigned this_ptr_conv;
18699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18700         this_ptr_conv.is_owned = false;
18701         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18702         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
18703         return ret_arr;
18704 }
18705
18706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18707         LDKFundingSigned this_ptr_conv;
18708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18709         this_ptr_conv.is_owned = false;
18710         LDKSignature val_ref;
18711         CHECK((*env)->GetArrayLength(env, val) == 64);
18712         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18713         FundingSigned_set_signature(&this_ptr_conv, val_ref);
18714 }
18715
18716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
18717         LDKThirtyTwoBytes channel_id_arg_ref;
18718         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18719         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18720         LDKSignature signature_arg_ref;
18721         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18722         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18723         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
18724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18726         uint64_t ret_ref = (uint64_t)ret_var.inner;
18727         if (ret_var.is_owned) {
18728                 ret_ref |= 1;
18729         }
18730         return ret_ref;
18731 }
18732
18733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18734         LDKFundingSigned orig_conv;
18735         orig_conv.inner = (void*)(orig & (~1));
18736         orig_conv.is_owned = false;
18737         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
18738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18740         uint64_t ret_ref = (uint64_t)ret_var.inner;
18741         if (ret_var.is_owned) {
18742                 ret_ref |= 1;
18743         }
18744         return ret_ref;
18745 }
18746
18747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18748         LDKFundingLocked this_obj_conv;
18749         this_obj_conv.inner = (void*)(this_obj & (~1));
18750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18751         FundingLocked_free(this_obj_conv);
18752 }
18753
18754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18755         LDKFundingLocked this_ptr_conv;
18756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18757         this_ptr_conv.is_owned = false;
18758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
18760         return ret_arr;
18761 }
18762
18763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18764         LDKFundingLocked this_ptr_conv;
18765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18766         this_ptr_conv.is_owned = false;
18767         LDKThirtyTwoBytes val_ref;
18768         CHECK((*env)->GetArrayLength(env, val) == 32);
18769         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18770         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
18771 }
18772
18773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18774         LDKFundingLocked this_ptr_conv;
18775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18776         this_ptr_conv.is_owned = false;
18777         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18779         return ret_arr;
18780 }
18781
18782 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) {
18783         LDKFundingLocked this_ptr_conv;
18784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18785         this_ptr_conv.is_owned = false;
18786         LDKPublicKey val_ref;
18787         CHECK((*env)->GetArrayLength(env, val) == 33);
18788         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18789         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18790 }
18791
18792 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) {
18793         LDKThirtyTwoBytes channel_id_arg_ref;
18794         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18795         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18796         LDKPublicKey next_per_commitment_point_arg_ref;
18797         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18798         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18799         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
18800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18802         uint64_t ret_ref = (uint64_t)ret_var.inner;
18803         if (ret_var.is_owned) {
18804                 ret_ref |= 1;
18805         }
18806         return ret_ref;
18807 }
18808
18809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18810         LDKFundingLocked orig_conv;
18811         orig_conv.inner = (void*)(orig & (~1));
18812         orig_conv.is_owned = false;
18813         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
18814         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18815         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18816         uint64_t ret_ref = (uint64_t)ret_var.inner;
18817         if (ret_var.is_owned) {
18818                 ret_ref |= 1;
18819         }
18820         return ret_ref;
18821 }
18822
18823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18824         LDKShutdown this_obj_conv;
18825         this_obj_conv.inner = (void*)(this_obj & (~1));
18826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18827         Shutdown_free(this_obj_conv);
18828 }
18829
18830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18831         LDKShutdown this_ptr_conv;
18832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18833         this_ptr_conv.is_owned = false;
18834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
18836         return ret_arr;
18837 }
18838
18839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18840         LDKShutdown this_ptr_conv;
18841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18842         this_ptr_conv.is_owned = false;
18843         LDKThirtyTwoBytes val_ref;
18844         CHECK((*env)->GetArrayLength(env, val) == 32);
18845         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18846         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
18847 }
18848
18849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18850         LDKShutdown this_ptr_conv;
18851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18852         this_ptr_conv.is_owned = false;
18853         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
18854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18856         return ret_arr;
18857 }
18858
18859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18860         LDKShutdown this_ptr_conv;
18861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18862         this_ptr_conv.is_owned = false;
18863         LDKCVec_u8Z val_ref;
18864         val_ref.datalen = (*env)->GetArrayLength(env, val);
18865         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18866         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18867         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18868 }
18869
18870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18871         LDKThirtyTwoBytes channel_id_arg_ref;
18872         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18873         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18874         LDKCVec_u8Z scriptpubkey_arg_ref;
18875         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
18876         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18877         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
18878         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18879         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18880         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18881         uint64_t ret_ref = (uint64_t)ret_var.inner;
18882         if (ret_var.is_owned) {
18883                 ret_ref |= 1;
18884         }
18885         return ret_ref;
18886 }
18887
18888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18889         LDKShutdown orig_conv;
18890         orig_conv.inner = (void*)(orig & (~1));
18891         orig_conv.is_owned = false;
18892         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18895         uint64_t ret_ref = (uint64_t)ret_var.inner;
18896         if (ret_var.is_owned) {
18897                 ret_ref |= 1;
18898         }
18899         return ret_ref;
18900 }
18901
18902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18903         LDKClosingSignedFeeRange this_obj_conv;
18904         this_obj_conv.inner = (void*)(this_obj & (~1));
18905         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18906         ClosingSignedFeeRange_free(this_obj_conv);
18907 }
18908
18909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18910         LDKClosingSignedFeeRange this_ptr_conv;
18911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18912         this_ptr_conv.is_owned = false;
18913         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
18914         return ret_val;
18915 }
18916
18917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18918         LDKClosingSignedFeeRange this_ptr_conv;
18919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18920         this_ptr_conv.is_owned = false;
18921         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
18922 }
18923
18924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18925         LDKClosingSignedFeeRange this_ptr_conv;
18926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18927         this_ptr_conv.is_owned = false;
18928         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
18929         return ret_val;
18930 }
18931
18932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18933         LDKClosingSignedFeeRange this_ptr_conv;
18934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18935         this_ptr_conv.is_owned = false;
18936         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
18937 }
18938
18939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
18940         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
18941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18943         uint64_t ret_ref = (uint64_t)ret_var.inner;
18944         if (ret_var.is_owned) {
18945                 ret_ref |= 1;
18946         }
18947         return ret_ref;
18948 }
18949
18950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18951         LDKClosingSignedFeeRange orig_conv;
18952         orig_conv.inner = (void*)(orig & (~1));
18953         orig_conv.is_owned = false;
18954         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
18955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18957         uint64_t ret_ref = (uint64_t)ret_var.inner;
18958         if (ret_var.is_owned) {
18959                 ret_ref |= 1;
18960         }
18961         return ret_ref;
18962 }
18963
18964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18965         LDKClosingSigned this_obj_conv;
18966         this_obj_conv.inner = (void*)(this_obj & (~1));
18967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18968         ClosingSigned_free(this_obj_conv);
18969 }
18970
18971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18972         LDKClosingSigned this_ptr_conv;
18973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18974         this_ptr_conv.is_owned = false;
18975         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18976         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
18977         return ret_arr;
18978 }
18979
18980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18981         LDKClosingSigned this_ptr_conv;
18982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18983         this_ptr_conv.is_owned = false;
18984         LDKThirtyTwoBytes val_ref;
18985         CHECK((*env)->GetArrayLength(env, val) == 32);
18986         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18987         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18988 }
18989
18990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18991         LDKClosingSigned this_ptr_conv;
18992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18993         this_ptr_conv.is_owned = false;
18994         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18995         return ret_val;
18996 }
18997
18998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18999         LDKClosingSigned this_ptr_conv;
19000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19001         this_ptr_conv.is_owned = false;
19002         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
19003 }
19004
19005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19006         LDKClosingSigned this_ptr_conv;
19007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19008         this_ptr_conv.is_owned = false;
19009         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
19011         return ret_arr;
19012 }
19013
19014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19015         LDKClosingSigned this_ptr_conv;
19016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19017         this_ptr_conv.is_owned = false;
19018         LDKSignature val_ref;
19019         CHECK((*env)->GetArrayLength(env, val) == 64);
19020         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19021         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
19022 }
19023
19024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
19025         LDKClosingSigned this_ptr_conv;
19026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19027         this_ptr_conv.is_owned = false;
19028         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
19029         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19030         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19031         uint64_t ret_ref = (uint64_t)ret_var.inner;
19032         if (ret_var.is_owned) {
19033                 ret_ref |= 1;
19034         }
19035         return ret_ref;
19036 }
19037
19038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19039         LDKClosingSigned this_ptr_conv;
19040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19041         this_ptr_conv.is_owned = false;
19042         LDKClosingSignedFeeRange val_conv;
19043         val_conv.inner = (void*)(val & (~1));
19044         val_conv.is_owned = (val & 1) || (val == 0);
19045         val_conv = ClosingSignedFeeRange_clone(&val_conv);
19046         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
19047 }
19048
19049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, int64_t fee_range_arg) {
19050         LDKThirtyTwoBytes channel_id_arg_ref;
19051         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19052         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19053         LDKSignature signature_arg_ref;
19054         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19055         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19056         LDKClosingSignedFeeRange fee_range_arg_conv;
19057         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
19058         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
19059         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
19060         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
19061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19063         uint64_t ret_ref = (uint64_t)ret_var.inner;
19064         if (ret_var.is_owned) {
19065                 ret_ref |= 1;
19066         }
19067         return ret_ref;
19068 }
19069
19070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19071         LDKClosingSigned orig_conv;
19072         orig_conv.inner = (void*)(orig & (~1));
19073         orig_conv.is_owned = false;
19074         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
19075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19077         uint64_t ret_ref = (uint64_t)ret_var.inner;
19078         if (ret_var.is_owned) {
19079                 ret_ref |= 1;
19080         }
19081         return ret_ref;
19082 }
19083
19084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19085         LDKUpdateAddHTLC this_obj_conv;
19086         this_obj_conv.inner = (void*)(this_obj & (~1));
19087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19088         UpdateAddHTLC_free(this_obj_conv);
19089 }
19090
19091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19092         LDKUpdateAddHTLC this_ptr_conv;
19093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19094         this_ptr_conv.is_owned = false;
19095         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19096         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
19097         return ret_arr;
19098 }
19099
19100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19101         LDKUpdateAddHTLC this_ptr_conv;
19102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19103         this_ptr_conv.is_owned = false;
19104         LDKThirtyTwoBytes val_ref;
19105         CHECK((*env)->GetArrayLength(env, val) == 32);
19106         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19107         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
19108 }
19109
19110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19111         LDKUpdateAddHTLC this_ptr_conv;
19112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19113         this_ptr_conv.is_owned = false;
19114         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
19115         return ret_val;
19116 }
19117
19118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19119         LDKUpdateAddHTLC this_ptr_conv;
19120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19121         this_ptr_conv.is_owned = false;
19122         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
19123 }
19124
19125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
19126         LDKUpdateAddHTLC this_ptr_conv;
19127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19128         this_ptr_conv.is_owned = false;
19129         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
19130         return ret_val;
19131 }
19132
19133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19134         LDKUpdateAddHTLC this_ptr_conv;
19135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19136         this_ptr_conv.is_owned = false;
19137         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
19138 }
19139
19140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19141         LDKUpdateAddHTLC this_ptr_conv;
19142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19143         this_ptr_conv.is_owned = false;
19144         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
19146         return ret_arr;
19147 }
19148
19149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19150         LDKUpdateAddHTLC this_ptr_conv;
19151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19152         this_ptr_conv.is_owned = false;
19153         LDKThirtyTwoBytes val_ref;
19154         CHECK((*env)->GetArrayLength(env, val) == 32);
19155         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19156         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
19157 }
19158
19159 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
19160         LDKUpdateAddHTLC this_ptr_conv;
19161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19162         this_ptr_conv.is_owned = false;
19163         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
19164         return ret_val;
19165 }
19166
19167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19168         LDKUpdateAddHTLC this_ptr_conv;
19169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19170         this_ptr_conv.is_owned = false;
19171         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
19172 }
19173
19174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19175         LDKUpdateAddHTLC orig_conv;
19176         orig_conv.inner = (void*)(orig & (~1));
19177         orig_conv.is_owned = false;
19178         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
19179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19181         uint64_t ret_ref = (uint64_t)ret_var.inner;
19182         if (ret_var.is_owned) {
19183                 ret_ref |= 1;
19184         }
19185         return ret_ref;
19186 }
19187
19188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19189         LDKUpdateFulfillHTLC this_obj_conv;
19190         this_obj_conv.inner = (void*)(this_obj & (~1));
19191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19192         UpdateFulfillHTLC_free(this_obj_conv);
19193 }
19194
19195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19196         LDKUpdateFulfillHTLC this_ptr_conv;
19197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19198         this_ptr_conv.is_owned = false;
19199         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
19201         return ret_arr;
19202 }
19203
19204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19205         LDKUpdateFulfillHTLC this_ptr_conv;
19206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19207         this_ptr_conv.is_owned = false;
19208         LDKThirtyTwoBytes val_ref;
19209         CHECK((*env)->GetArrayLength(env, val) == 32);
19210         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19211         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
19212 }
19213
19214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19215         LDKUpdateFulfillHTLC this_ptr_conv;
19216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19217         this_ptr_conv.is_owned = false;
19218         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
19219         return ret_val;
19220 }
19221
19222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19223         LDKUpdateFulfillHTLC this_ptr_conv;
19224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19225         this_ptr_conv.is_owned = false;
19226         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
19227 }
19228
19229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
19230         LDKUpdateFulfillHTLC this_ptr_conv;
19231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19232         this_ptr_conv.is_owned = false;
19233         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19234         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
19235         return ret_arr;
19236 }
19237
19238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19239         LDKUpdateFulfillHTLC this_ptr_conv;
19240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19241         this_ptr_conv.is_owned = false;
19242         LDKThirtyTwoBytes val_ref;
19243         CHECK((*env)->GetArrayLength(env, val) == 32);
19244         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19245         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
19246 }
19247
19248 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) {
19249         LDKThirtyTwoBytes channel_id_arg_ref;
19250         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19251         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19252         LDKThirtyTwoBytes payment_preimage_arg_ref;
19253         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
19254         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
19255         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
19256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19258         uint64_t ret_ref = (uint64_t)ret_var.inner;
19259         if (ret_var.is_owned) {
19260                 ret_ref |= 1;
19261         }
19262         return ret_ref;
19263 }
19264
19265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19266         LDKUpdateFulfillHTLC orig_conv;
19267         orig_conv.inner = (void*)(orig & (~1));
19268         orig_conv.is_owned = false;
19269         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
19270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19272         uint64_t ret_ref = (uint64_t)ret_var.inner;
19273         if (ret_var.is_owned) {
19274                 ret_ref |= 1;
19275         }
19276         return ret_ref;
19277 }
19278
19279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19280         LDKUpdateFailHTLC this_obj_conv;
19281         this_obj_conv.inner = (void*)(this_obj & (~1));
19282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19283         UpdateFailHTLC_free(this_obj_conv);
19284 }
19285
19286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19287         LDKUpdateFailHTLC this_ptr_conv;
19288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19289         this_ptr_conv.is_owned = false;
19290         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
19292         return ret_arr;
19293 }
19294
19295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19296         LDKUpdateFailHTLC this_ptr_conv;
19297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19298         this_ptr_conv.is_owned = false;
19299         LDKThirtyTwoBytes val_ref;
19300         CHECK((*env)->GetArrayLength(env, val) == 32);
19301         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19302         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
19303 }
19304
19305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19306         LDKUpdateFailHTLC this_ptr_conv;
19307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19308         this_ptr_conv.is_owned = false;
19309         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
19310         return ret_val;
19311 }
19312
19313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19314         LDKUpdateFailHTLC this_ptr_conv;
19315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19316         this_ptr_conv.is_owned = false;
19317         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
19318 }
19319
19320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19321         LDKUpdateFailHTLC orig_conv;
19322         orig_conv.inner = (void*)(orig & (~1));
19323         orig_conv.is_owned = false;
19324         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
19325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19327         uint64_t ret_ref = (uint64_t)ret_var.inner;
19328         if (ret_var.is_owned) {
19329                 ret_ref |= 1;
19330         }
19331         return ret_ref;
19332 }
19333
19334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19335         LDKUpdateFailMalformedHTLC this_obj_conv;
19336         this_obj_conv.inner = (void*)(this_obj & (~1));
19337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19338         UpdateFailMalformedHTLC_free(this_obj_conv);
19339 }
19340
19341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19342         LDKUpdateFailMalformedHTLC this_ptr_conv;
19343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19344         this_ptr_conv.is_owned = false;
19345         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19346         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
19347         return ret_arr;
19348 }
19349
19350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19351         LDKUpdateFailMalformedHTLC this_ptr_conv;
19352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19353         this_ptr_conv.is_owned = false;
19354         LDKThirtyTwoBytes val_ref;
19355         CHECK((*env)->GetArrayLength(env, val) == 32);
19356         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19357         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
19358 }
19359
19360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19361         LDKUpdateFailMalformedHTLC this_ptr_conv;
19362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19363         this_ptr_conv.is_owned = false;
19364         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
19365         return ret_val;
19366 }
19367
19368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19369         LDKUpdateFailMalformedHTLC this_ptr_conv;
19370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19371         this_ptr_conv.is_owned = false;
19372         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
19373 }
19374
19375 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
19376         LDKUpdateFailMalformedHTLC this_ptr_conv;
19377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19378         this_ptr_conv.is_owned = false;
19379         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
19380         return ret_val;
19381 }
19382
19383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
19384         LDKUpdateFailMalformedHTLC this_ptr_conv;
19385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19386         this_ptr_conv.is_owned = false;
19387         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
19388 }
19389
19390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19391         LDKUpdateFailMalformedHTLC orig_conv;
19392         orig_conv.inner = (void*)(orig & (~1));
19393         orig_conv.is_owned = false;
19394         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
19395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19397         uint64_t ret_ref = (uint64_t)ret_var.inner;
19398         if (ret_var.is_owned) {
19399                 ret_ref |= 1;
19400         }
19401         return ret_ref;
19402 }
19403
19404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19405         LDKCommitmentSigned this_obj_conv;
19406         this_obj_conv.inner = (void*)(this_obj & (~1));
19407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19408         CommitmentSigned_free(this_obj_conv);
19409 }
19410
19411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19412         LDKCommitmentSigned this_ptr_conv;
19413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19414         this_ptr_conv.is_owned = false;
19415         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
19417         return ret_arr;
19418 }
19419
19420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19421         LDKCommitmentSigned this_ptr_conv;
19422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19423         this_ptr_conv.is_owned = false;
19424         LDKThirtyTwoBytes val_ref;
19425         CHECK((*env)->GetArrayLength(env, val) == 32);
19426         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19427         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
19428 }
19429
19430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19431         LDKCommitmentSigned this_ptr_conv;
19432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19433         this_ptr_conv.is_owned = false;
19434         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
19436         return ret_arr;
19437 }
19438
19439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19440         LDKCommitmentSigned this_ptr_conv;
19441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19442         this_ptr_conv.is_owned = false;
19443         LDKSignature val_ref;
19444         CHECK((*env)->GetArrayLength(env, val) == 64);
19445         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19446         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
19447 }
19448
19449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
19450         LDKCommitmentSigned this_ptr_conv;
19451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19452         this_ptr_conv.is_owned = false;
19453         LDKCVec_SignatureZ val_constr;
19454         val_constr.datalen = (*env)->GetArrayLength(env, val);
19455         if (val_constr.datalen > 0)
19456                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19457         else
19458                 val_constr.data = NULL;
19459         for (size_t i = 0; i < val_constr.datalen; i++) {
19460                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
19461                 LDKSignature val_conv_8_ref;
19462                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
19463                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
19464                 val_constr.data[i] = val_conv_8_ref;
19465         }
19466         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
19467 }
19468
19469 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) {
19470         LDKThirtyTwoBytes channel_id_arg_ref;
19471         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19472         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19473         LDKSignature signature_arg_ref;
19474         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19475         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19476         LDKCVec_SignatureZ htlc_signatures_arg_constr;
19477         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
19478         if (htlc_signatures_arg_constr.datalen > 0)
19479                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19480         else
19481                 htlc_signatures_arg_constr.data = NULL;
19482         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
19483                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
19484                 LDKSignature htlc_signatures_arg_conv_8_ref;
19485                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
19486                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
19487                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
19488         }
19489         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
19490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19492         uint64_t ret_ref = (uint64_t)ret_var.inner;
19493         if (ret_var.is_owned) {
19494                 ret_ref |= 1;
19495         }
19496         return ret_ref;
19497 }
19498
19499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19500         LDKCommitmentSigned orig_conv;
19501         orig_conv.inner = (void*)(orig & (~1));
19502         orig_conv.is_owned = false;
19503         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
19504         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19505         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19506         uint64_t ret_ref = (uint64_t)ret_var.inner;
19507         if (ret_var.is_owned) {
19508                 ret_ref |= 1;
19509         }
19510         return ret_ref;
19511 }
19512
19513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19514         LDKRevokeAndACK this_obj_conv;
19515         this_obj_conv.inner = (void*)(this_obj & (~1));
19516         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19517         RevokeAndACK_free(this_obj_conv);
19518 }
19519
19520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19521         LDKRevokeAndACK this_ptr_conv;
19522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19523         this_ptr_conv.is_owned = false;
19524         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19525         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
19526         return ret_arr;
19527 }
19528
19529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19530         LDKRevokeAndACK this_ptr_conv;
19531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19532         this_ptr_conv.is_owned = false;
19533         LDKThirtyTwoBytes val_ref;
19534         CHECK((*env)->GetArrayLength(env, val) == 32);
19535         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19536         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
19537 }
19538
19539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19540         LDKRevokeAndACK this_ptr_conv;
19541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19542         this_ptr_conv.is_owned = false;
19543         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
19545         return ret_arr;
19546 }
19547
19548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19549         LDKRevokeAndACK this_ptr_conv;
19550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19551         this_ptr_conv.is_owned = false;
19552         LDKThirtyTwoBytes val_ref;
19553         CHECK((*env)->GetArrayLength(env, val) == 32);
19554         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19555         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
19556 }
19557
19558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19559         LDKRevokeAndACK this_ptr_conv;
19560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19561         this_ptr_conv.is_owned = false;
19562         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19563         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
19564         return ret_arr;
19565 }
19566
19567 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) {
19568         LDKRevokeAndACK this_ptr_conv;
19569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19570         this_ptr_conv.is_owned = false;
19571         LDKPublicKey val_ref;
19572         CHECK((*env)->GetArrayLength(env, val) == 33);
19573         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19574         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
19575 }
19576
19577 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) {
19578         LDKThirtyTwoBytes channel_id_arg_ref;
19579         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19580         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19581         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
19582         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
19583         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
19584         LDKPublicKey next_per_commitment_point_arg_ref;
19585         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
19586         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
19587         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
19588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19590         uint64_t ret_ref = (uint64_t)ret_var.inner;
19591         if (ret_var.is_owned) {
19592                 ret_ref |= 1;
19593         }
19594         return ret_ref;
19595 }
19596
19597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19598         LDKRevokeAndACK orig_conv;
19599         orig_conv.inner = (void*)(orig & (~1));
19600         orig_conv.is_owned = false;
19601         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
19602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19604         uint64_t ret_ref = (uint64_t)ret_var.inner;
19605         if (ret_var.is_owned) {
19606                 ret_ref |= 1;
19607         }
19608         return ret_ref;
19609 }
19610
19611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19612         LDKUpdateFee this_obj_conv;
19613         this_obj_conv.inner = (void*)(this_obj & (~1));
19614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19615         UpdateFee_free(this_obj_conv);
19616 }
19617
19618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19619         LDKUpdateFee this_ptr_conv;
19620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19621         this_ptr_conv.is_owned = false;
19622         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
19624         return ret_arr;
19625 }
19626
19627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19628         LDKUpdateFee this_ptr_conv;
19629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19630         this_ptr_conv.is_owned = false;
19631         LDKThirtyTwoBytes val_ref;
19632         CHECK((*env)->GetArrayLength(env, val) == 32);
19633         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19634         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
19635 }
19636
19637 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
19638         LDKUpdateFee this_ptr_conv;
19639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19640         this_ptr_conv.is_owned = false;
19641         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
19642         return ret_val;
19643 }
19644
19645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19646         LDKUpdateFee this_ptr_conv;
19647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19648         this_ptr_conv.is_owned = false;
19649         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
19650 }
19651
19652 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) {
19653         LDKThirtyTwoBytes channel_id_arg_ref;
19654         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19655         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19656         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
19657         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19658         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19659         uint64_t ret_ref = (uint64_t)ret_var.inner;
19660         if (ret_var.is_owned) {
19661                 ret_ref |= 1;
19662         }
19663         return ret_ref;
19664 }
19665
19666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19667         LDKUpdateFee orig_conv;
19668         orig_conv.inner = (void*)(orig & (~1));
19669         orig_conv.is_owned = false;
19670         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
19671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19673         uint64_t ret_ref = (uint64_t)ret_var.inner;
19674         if (ret_var.is_owned) {
19675                 ret_ref |= 1;
19676         }
19677         return ret_ref;
19678 }
19679
19680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19681         LDKDataLossProtect this_obj_conv;
19682         this_obj_conv.inner = (void*)(this_obj & (~1));
19683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19684         DataLossProtect_free(this_obj_conv);
19685 }
19686
19687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19688         LDKDataLossProtect this_ptr_conv;
19689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19690         this_ptr_conv.is_owned = false;
19691         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19692         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
19693         return ret_arr;
19694 }
19695
19696 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) {
19697         LDKDataLossProtect this_ptr_conv;
19698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19699         this_ptr_conv.is_owned = false;
19700         LDKThirtyTwoBytes val_ref;
19701         CHECK((*env)->GetArrayLength(env, val) == 32);
19702         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19703         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
19704 }
19705
19706 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19707         LDKDataLossProtect this_ptr_conv;
19708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19709         this_ptr_conv.is_owned = false;
19710         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19711         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
19712         return ret_arr;
19713 }
19714
19715 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) {
19716         LDKDataLossProtect this_ptr_conv;
19717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19718         this_ptr_conv.is_owned = false;
19719         LDKPublicKey val_ref;
19720         CHECK((*env)->GetArrayLength(env, val) == 33);
19721         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19722         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
19723 }
19724
19725 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) {
19726         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
19727         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
19728         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
19729         LDKPublicKey my_current_per_commitment_point_arg_ref;
19730         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
19731         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
19732         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
19733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19735         uint64_t ret_ref = (uint64_t)ret_var.inner;
19736         if (ret_var.is_owned) {
19737                 ret_ref |= 1;
19738         }
19739         return ret_ref;
19740 }
19741
19742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19743         LDKDataLossProtect orig_conv;
19744         orig_conv.inner = (void*)(orig & (~1));
19745         orig_conv.is_owned = false;
19746         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
19747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19749         uint64_t ret_ref = (uint64_t)ret_var.inner;
19750         if (ret_var.is_owned) {
19751                 ret_ref |= 1;
19752         }
19753         return ret_ref;
19754 }
19755
19756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19757         LDKChannelReestablish this_obj_conv;
19758         this_obj_conv.inner = (void*)(this_obj & (~1));
19759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19760         ChannelReestablish_free(this_obj_conv);
19761 }
19762
19763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19764         LDKChannelReestablish this_ptr_conv;
19765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19766         this_ptr_conv.is_owned = false;
19767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
19769         return ret_arr;
19770 }
19771
19772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19773         LDKChannelReestablish this_ptr_conv;
19774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19775         this_ptr_conv.is_owned = false;
19776         LDKThirtyTwoBytes val_ref;
19777         CHECK((*env)->GetArrayLength(env, val) == 32);
19778         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19779         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
19780 }
19781
19782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19783         LDKChannelReestablish this_ptr_conv;
19784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19785         this_ptr_conv.is_owned = false;
19786         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
19787         return ret_val;
19788 }
19789
19790 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) {
19791         LDKChannelReestablish this_ptr_conv;
19792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19793         this_ptr_conv.is_owned = false;
19794         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
19795 }
19796
19797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19798         LDKChannelReestablish this_ptr_conv;
19799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19800         this_ptr_conv.is_owned = false;
19801         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
19802         return ret_val;
19803 }
19804
19805 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) {
19806         LDKChannelReestablish this_ptr_conv;
19807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19808         this_ptr_conv.is_owned = false;
19809         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
19810 }
19811
19812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19813         LDKChannelReestablish orig_conv;
19814         orig_conv.inner = (void*)(orig & (~1));
19815         orig_conv.is_owned = false;
19816         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
19817         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19818         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19819         uint64_t ret_ref = (uint64_t)ret_var.inner;
19820         if (ret_var.is_owned) {
19821                 ret_ref |= 1;
19822         }
19823         return ret_ref;
19824 }
19825
19826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19827         LDKAnnouncementSignatures this_obj_conv;
19828         this_obj_conv.inner = (void*)(this_obj & (~1));
19829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19830         AnnouncementSignatures_free(this_obj_conv);
19831 }
19832
19833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19834         LDKAnnouncementSignatures this_ptr_conv;
19835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19836         this_ptr_conv.is_owned = false;
19837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
19839         return ret_arr;
19840 }
19841
19842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19843         LDKAnnouncementSignatures this_ptr_conv;
19844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19845         this_ptr_conv.is_owned = false;
19846         LDKThirtyTwoBytes val_ref;
19847         CHECK((*env)->GetArrayLength(env, val) == 32);
19848         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19849         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
19850 }
19851
19852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19853         LDKAnnouncementSignatures this_ptr_conv;
19854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19855         this_ptr_conv.is_owned = false;
19856         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
19857         return ret_val;
19858 }
19859
19860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19861         LDKAnnouncementSignatures this_ptr_conv;
19862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19863         this_ptr_conv.is_owned = false;
19864         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19865 }
19866
19867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19868         LDKAnnouncementSignatures this_ptr_conv;
19869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19870         this_ptr_conv.is_owned = false;
19871         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19872         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
19873         return ret_arr;
19874 }
19875
19876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19877         LDKAnnouncementSignatures this_ptr_conv;
19878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19879         this_ptr_conv.is_owned = false;
19880         LDKSignature val_ref;
19881         CHECK((*env)->GetArrayLength(env, val) == 64);
19882         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19883         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19884 }
19885
19886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19887         LDKAnnouncementSignatures this_ptr_conv;
19888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19889         this_ptr_conv.is_owned = false;
19890         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
19892         return ret_arr;
19893 }
19894
19895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19896         LDKAnnouncementSignatures this_ptr_conv;
19897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19898         this_ptr_conv.is_owned = false;
19899         LDKSignature val_ref;
19900         CHECK((*env)->GetArrayLength(env, val) == 64);
19901         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19902         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19903 }
19904
19905 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) {
19906         LDKThirtyTwoBytes channel_id_arg_ref;
19907         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19908         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19909         LDKSignature node_signature_arg_ref;
19910         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
19911         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
19912         LDKSignature bitcoin_signature_arg_ref;
19913         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
19914         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
19915         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19916         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19917         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19918         uint64_t ret_ref = (uint64_t)ret_var.inner;
19919         if (ret_var.is_owned) {
19920                 ret_ref |= 1;
19921         }
19922         return ret_ref;
19923 }
19924
19925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19926         LDKAnnouncementSignatures orig_conv;
19927         orig_conv.inner = (void*)(orig & (~1));
19928         orig_conv.is_owned = false;
19929         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19932         uint64_t ret_ref = (uint64_t)ret_var.inner;
19933         if (ret_var.is_owned) {
19934                 ret_ref |= 1;
19935         }
19936         return ret_ref;
19937 }
19938
19939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19940         if ((this_ptr & 1) != 0) return;
19941         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19942         FREE((void*)this_ptr);
19943         NetAddress_free(this_ptr_conv);
19944 }
19945
19946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19947         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19948         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19949         *ret_copy = NetAddress_clone(orig_conv);
19950         uint64_t ret_ref = (uint64_t)ret_copy;
19951         return ret_ref;
19952 }
19953
19954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19955         LDKFourBytes addr_ref;
19956         CHECK((*env)->GetArrayLength(env, addr) == 4);
19957         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
19958         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19959         *ret_copy = NetAddress_ipv4(addr_ref, port);
19960         uint64_t ret_ref = (uint64_t)ret_copy;
19961         return ret_ref;
19962 }
19963
19964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19965         LDKSixteenBytes addr_ref;
19966         CHECK((*env)->GetArrayLength(env, addr) == 16);
19967         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
19968         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19969         *ret_copy = NetAddress_ipv6(addr_ref, port);
19970         uint64_t ret_ref = (uint64_t)ret_copy;
19971         return ret_ref;
19972 }
19973
19974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19975         LDKTenBytes addr_ref;
19976         CHECK((*env)->GetArrayLength(env, addr) == 10);
19977         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
19978         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19979         *ret_copy = NetAddress_onion_v2(addr_ref, port);
19980         uint64_t ret_ref = (uint64_t)ret_copy;
19981         return ret_ref;
19982 }
19983
19984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
19985         LDKThirtyTwoBytes ed25519_pubkey_ref;
19986         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
19987         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
19988         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19989         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
19990         uint64_t ret_ref = (uint64_t)ret_copy;
19991         return ret_ref;
19992 }
19993
19994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
19995         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19996         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19997         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19998         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19999         CVec_u8Z_free(ret_var);
20000         return ret_arr;
20001 }
20002
20003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20004         LDKu8slice ser_ref;
20005         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20006         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20007         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
20008         *ret_conv = Result_read(ser_ref);
20009         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20010         return (uint64_t)ret_conv;
20011 }
20012
20013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20014         LDKu8slice ser_ref;
20015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20017         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20018         *ret_conv = NetAddress_read(ser_ref);
20019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20020         return (uint64_t)ret_conv;
20021 }
20022
20023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20024         LDKUnsignedNodeAnnouncement this_obj_conv;
20025         this_obj_conv.inner = (void*)(this_obj & (~1));
20026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20027         UnsignedNodeAnnouncement_free(this_obj_conv);
20028 }
20029
20030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20031         LDKUnsignedNodeAnnouncement this_ptr_conv;
20032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20033         this_ptr_conv.is_owned = false;
20034         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
20035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20037         uint64_t ret_ref = (uint64_t)ret_var.inner;
20038         if (ret_var.is_owned) {
20039                 ret_ref |= 1;
20040         }
20041         return ret_ref;
20042 }
20043
20044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20045         LDKUnsignedNodeAnnouncement this_ptr_conv;
20046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20047         this_ptr_conv.is_owned = false;
20048         LDKNodeFeatures val_conv;
20049         val_conv.inner = (void*)(val & (~1));
20050         val_conv.is_owned = (val & 1) || (val == 0);
20051         val_conv = NodeFeatures_clone(&val_conv);
20052         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
20053 }
20054
20055 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20056         LDKUnsignedNodeAnnouncement this_ptr_conv;
20057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20058         this_ptr_conv.is_owned = false;
20059         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
20060         return ret_val;
20061 }
20062
20063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20064         LDKUnsignedNodeAnnouncement this_ptr_conv;
20065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20066         this_ptr_conv.is_owned = false;
20067         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
20068 }
20069
20070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20071         LDKUnsignedNodeAnnouncement this_ptr_conv;
20072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20073         this_ptr_conv.is_owned = false;
20074         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20075         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
20076         return ret_arr;
20077 }
20078
20079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20080         LDKUnsignedNodeAnnouncement this_ptr_conv;
20081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20082         this_ptr_conv.is_owned = false;
20083         LDKPublicKey val_ref;
20084         CHECK((*env)->GetArrayLength(env, val) == 33);
20085         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20086         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
20087 }
20088
20089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
20090         LDKUnsignedNodeAnnouncement this_ptr_conv;
20091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20092         this_ptr_conv.is_owned = false;
20093         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
20094         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
20095         return ret_arr;
20096 }
20097
20098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20099         LDKUnsignedNodeAnnouncement this_ptr_conv;
20100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20101         this_ptr_conv.is_owned = false;
20102         LDKThreeBytes val_ref;
20103         CHECK((*env)->GetArrayLength(env, val) == 3);
20104         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
20105         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
20106 }
20107
20108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
20109         LDKUnsignedNodeAnnouncement this_ptr_conv;
20110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20111         this_ptr_conv.is_owned = false;
20112         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
20114         return ret_arr;
20115 }
20116
20117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20118         LDKUnsignedNodeAnnouncement this_ptr_conv;
20119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20120         this_ptr_conv.is_owned = false;
20121         LDKThirtyTwoBytes val_ref;
20122         CHECK((*env)->GetArrayLength(env, val) == 32);
20123         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20124         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
20125 }
20126
20127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20128         LDKUnsignedNodeAnnouncement this_ptr_conv;
20129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20130         this_ptr_conv.is_owned = false;
20131         LDKCVec_NetAddressZ val_constr;
20132         val_constr.datalen = (*env)->GetArrayLength(env, val);
20133         if (val_constr.datalen > 0)
20134                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20135         else
20136                 val_constr.data = NULL;
20137         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20138         for (size_t m = 0; m < val_constr.datalen; m++) {
20139                 int64_t val_conv_12 = val_vals[m];
20140                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
20141                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
20142                 val_constr.data[m] = val_conv_12_conv;
20143         }
20144         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20145         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
20146 }
20147
20148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20149         LDKUnsignedNodeAnnouncement orig_conv;
20150         orig_conv.inner = (void*)(orig & (~1));
20151         orig_conv.is_owned = false;
20152         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
20153         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20154         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20155         uint64_t ret_ref = (uint64_t)ret_var.inner;
20156         if (ret_var.is_owned) {
20157                 ret_ref |= 1;
20158         }
20159         return ret_ref;
20160 }
20161
20162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20163         LDKNodeAnnouncement this_obj_conv;
20164         this_obj_conv.inner = (void*)(this_obj & (~1));
20165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20166         NodeAnnouncement_free(this_obj_conv);
20167 }
20168
20169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20170         LDKNodeAnnouncement this_ptr_conv;
20171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20172         this_ptr_conv.is_owned = false;
20173         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
20175         return ret_arr;
20176 }
20177
20178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20179         LDKNodeAnnouncement this_ptr_conv;
20180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20181         this_ptr_conv.is_owned = false;
20182         LDKSignature val_ref;
20183         CHECK((*env)->GetArrayLength(env, val) == 64);
20184         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20185         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
20186 }
20187
20188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20189         LDKNodeAnnouncement this_ptr_conv;
20190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20191         this_ptr_conv.is_owned = false;
20192         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
20193         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20194         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20195         uint64_t ret_ref = (uint64_t)ret_var.inner;
20196         if (ret_var.is_owned) {
20197                 ret_ref |= 1;
20198         }
20199         return ret_ref;
20200 }
20201
20202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20203         LDKNodeAnnouncement this_ptr_conv;
20204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20205         this_ptr_conv.is_owned = false;
20206         LDKUnsignedNodeAnnouncement val_conv;
20207         val_conv.inner = (void*)(val & (~1));
20208         val_conv.is_owned = (val & 1) || (val == 0);
20209         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
20210         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
20211 }
20212
20213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
20214         LDKSignature signature_arg_ref;
20215         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20216         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20217         LDKUnsignedNodeAnnouncement contents_arg_conv;
20218         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20219         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20220         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
20221         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
20222         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20223         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20224         uint64_t ret_ref = (uint64_t)ret_var.inner;
20225         if (ret_var.is_owned) {
20226                 ret_ref |= 1;
20227         }
20228         return ret_ref;
20229 }
20230
20231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20232         LDKNodeAnnouncement orig_conv;
20233         orig_conv.inner = (void*)(orig & (~1));
20234         orig_conv.is_owned = false;
20235         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
20236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20238         uint64_t ret_ref = (uint64_t)ret_var.inner;
20239         if (ret_var.is_owned) {
20240                 ret_ref |= 1;
20241         }
20242         return ret_ref;
20243 }
20244
20245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20246         LDKUnsignedChannelAnnouncement this_obj_conv;
20247         this_obj_conv.inner = (void*)(this_obj & (~1));
20248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20249         UnsignedChannelAnnouncement_free(this_obj_conv);
20250 }
20251
20252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
20253         LDKUnsignedChannelAnnouncement this_ptr_conv;
20254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20255         this_ptr_conv.is_owned = false;
20256         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
20257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20259         uint64_t ret_ref = (uint64_t)ret_var.inner;
20260         if (ret_var.is_owned) {
20261                 ret_ref |= 1;
20262         }
20263         return ret_ref;
20264 }
20265
20266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20267         LDKUnsignedChannelAnnouncement this_ptr_conv;
20268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20269         this_ptr_conv.is_owned = false;
20270         LDKChannelFeatures val_conv;
20271         val_conv.inner = (void*)(val & (~1));
20272         val_conv.is_owned = (val & 1) || (val == 0);
20273         val_conv = ChannelFeatures_clone(&val_conv);
20274         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
20275 }
20276
20277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20278         LDKUnsignedChannelAnnouncement this_ptr_conv;
20279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20280         this_ptr_conv.is_owned = false;
20281         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
20283         return ret_arr;
20284 }
20285
20286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20287         LDKUnsignedChannelAnnouncement this_ptr_conv;
20288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20289         this_ptr_conv.is_owned = false;
20290         LDKThirtyTwoBytes val_ref;
20291         CHECK((*env)->GetArrayLength(env, val) == 32);
20292         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20293         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
20294 }
20295
20296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20297         LDKUnsignedChannelAnnouncement this_ptr_conv;
20298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20299         this_ptr_conv.is_owned = false;
20300         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
20301         return ret_val;
20302 }
20303
20304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20305         LDKUnsignedChannelAnnouncement this_ptr_conv;
20306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20307         this_ptr_conv.is_owned = false;
20308         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
20309 }
20310
20311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20312         LDKUnsignedChannelAnnouncement this_ptr_conv;
20313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20314         this_ptr_conv.is_owned = false;
20315         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
20317         return ret_arr;
20318 }
20319
20320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20321         LDKUnsignedChannelAnnouncement this_ptr_conv;
20322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20323         this_ptr_conv.is_owned = false;
20324         LDKPublicKey val_ref;
20325         CHECK((*env)->GetArrayLength(env, val) == 33);
20326         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20327         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
20328 }
20329
20330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20331         LDKUnsignedChannelAnnouncement this_ptr_conv;
20332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20333         this_ptr_conv.is_owned = false;
20334         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20335         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
20336         return ret_arr;
20337 }
20338
20339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20340         LDKUnsignedChannelAnnouncement this_ptr_conv;
20341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20342         this_ptr_conv.is_owned = false;
20343         LDKPublicKey val_ref;
20344         CHECK((*env)->GetArrayLength(env, val) == 33);
20345         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20346         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
20347 }
20348
20349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20350         LDKUnsignedChannelAnnouncement this_ptr_conv;
20351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20352         this_ptr_conv.is_owned = false;
20353         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20354         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
20355         return ret_arr;
20356 }
20357
20358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20359         LDKUnsignedChannelAnnouncement this_ptr_conv;
20360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20361         this_ptr_conv.is_owned = false;
20362         LDKPublicKey val_ref;
20363         CHECK((*env)->GetArrayLength(env, val) == 33);
20364         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20365         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
20366 }
20367
20368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20369         LDKUnsignedChannelAnnouncement this_ptr_conv;
20370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20371         this_ptr_conv.is_owned = false;
20372         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
20373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
20374         return ret_arr;
20375 }
20376
20377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20378         LDKUnsignedChannelAnnouncement this_ptr_conv;
20379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20380         this_ptr_conv.is_owned = false;
20381         LDKPublicKey val_ref;
20382         CHECK((*env)->GetArrayLength(env, val) == 33);
20383         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
20384         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
20385 }
20386
20387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20388         LDKUnsignedChannelAnnouncement orig_conv;
20389         orig_conv.inner = (void*)(orig & (~1));
20390         orig_conv.is_owned = false;
20391         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
20392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20394         uint64_t ret_ref = (uint64_t)ret_var.inner;
20395         if (ret_var.is_owned) {
20396                 ret_ref |= 1;
20397         }
20398         return ret_ref;
20399 }
20400
20401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20402         LDKChannelAnnouncement this_obj_conv;
20403         this_obj_conv.inner = (void*)(this_obj & (~1));
20404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20405         ChannelAnnouncement_free(this_obj_conv);
20406 }
20407
20408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20409         LDKChannelAnnouncement this_ptr_conv;
20410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20411         this_ptr_conv.is_owned = false;
20412         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
20414         return ret_arr;
20415 }
20416
20417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20418         LDKChannelAnnouncement this_ptr_conv;
20419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20420         this_ptr_conv.is_owned = false;
20421         LDKSignature val_ref;
20422         CHECK((*env)->GetArrayLength(env, val) == 64);
20423         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20424         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
20425 }
20426
20427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20428         LDKChannelAnnouncement this_ptr_conv;
20429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20430         this_ptr_conv.is_owned = false;
20431         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20432         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
20433         return ret_arr;
20434 }
20435
20436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20437         LDKChannelAnnouncement this_ptr_conv;
20438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20439         this_ptr_conv.is_owned = false;
20440         LDKSignature val_ref;
20441         CHECK((*env)->GetArrayLength(env, val) == 64);
20442         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20443         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
20444 }
20445
20446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
20447         LDKChannelAnnouncement this_ptr_conv;
20448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20449         this_ptr_conv.is_owned = false;
20450         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
20452         return ret_arr;
20453 }
20454
20455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20456         LDKChannelAnnouncement this_ptr_conv;
20457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20458         this_ptr_conv.is_owned = false;
20459         LDKSignature val_ref;
20460         CHECK((*env)->GetArrayLength(env, val) == 64);
20461         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20462         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
20463 }
20464
20465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
20466         LDKChannelAnnouncement this_ptr_conv;
20467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20468         this_ptr_conv.is_owned = false;
20469         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
20471         return ret_arr;
20472 }
20473
20474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20475         LDKChannelAnnouncement this_ptr_conv;
20476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20477         this_ptr_conv.is_owned = false;
20478         LDKSignature val_ref;
20479         CHECK((*env)->GetArrayLength(env, val) == 64);
20480         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20481         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
20482 }
20483
20484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20485         LDKChannelAnnouncement this_ptr_conv;
20486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20487         this_ptr_conv.is_owned = false;
20488         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
20489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20491         uint64_t ret_ref = (uint64_t)ret_var.inner;
20492         if (ret_var.is_owned) {
20493                 ret_ref |= 1;
20494         }
20495         return ret_ref;
20496 }
20497
20498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20499         LDKChannelAnnouncement this_ptr_conv;
20500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20501         this_ptr_conv.is_owned = false;
20502         LDKUnsignedChannelAnnouncement val_conv;
20503         val_conv.inner = (void*)(val & (~1));
20504         val_conv.is_owned = (val & 1) || (val == 0);
20505         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
20506         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
20507 }
20508
20509 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) {
20510         LDKSignature node_signature_1_arg_ref;
20511         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
20512         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
20513         LDKSignature node_signature_2_arg_ref;
20514         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
20515         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
20516         LDKSignature bitcoin_signature_1_arg_ref;
20517         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
20518         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
20519         LDKSignature bitcoin_signature_2_arg_ref;
20520         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
20521         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
20522         LDKUnsignedChannelAnnouncement contents_arg_conv;
20523         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20524         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20525         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
20526         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);
20527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20529         uint64_t ret_ref = (uint64_t)ret_var.inner;
20530         if (ret_var.is_owned) {
20531                 ret_ref |= 1;
20532         }
20533         return ret_ref;
20534 }
20535
20536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20537         LDKChannelAnnouncement orig_conv;
20538         orig_conv.inner = (void*)(orig & (~1));
20539         orig_conv.is_owned = false;
20540         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
20541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20543         uint64_t ret_ref = (uint64_t)ret_var.inner;
20544         if (ret_var.is_owned) {
20545                 ret_ref |= 1;
20546         }
20547         return ret_ref;
20548 }
20549
20550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20551         LDKUnsignedChannelUpdate this_obj_conv;
20552         this_obj_conv.inner = (void*)(this_obj & (~1));
20553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20554         UnsignedChannelUpdate_free(this_obj_conv);
20555 }
20556
20557 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20558         LDKUnsignedChannelUpdate this_ptr_conv;
20559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20560         this_ptr_conv.is_owned = false;
20561         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20562         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
20563         return ret_arr;
20564 }
20565
20566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20567         LDKUnsignedChannelUpdate this_ptr_conv;
20568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20569         this_ptr_conv.is_owned = false;
20570         LDKThirtyTwoBytes val_ref;
20571         CHECK((*env)->GetArrayLength(env, val) == 32);
20572         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20573         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
20574 }
20575
20576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20577         LDKUnsignedChannelUpdate this_ptr_conv;
20578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20579         this_ptr_conv.is_owned = false;
20580         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
20581         return ret_val;
20582 }
20583
20584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20585         LDKUnsignedChannelUpdate this_ptr_conv;
20586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20587         this_ptr_conv.is_owned = false;
20588         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
20589 }
20590
20591 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20592         LDKUnsignedChannelUpdate this_ptr_conv;
20593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20594         this_ptr_conv.is_owned = false;
20595         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
20596         return ret_val;
20597 }
20598
20599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20600         LDKUnsignedChannelUpdate this_ptr_conv;
20601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20602         this_ptr_conv.is_owned = false;
20603         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
20604 }
20605
20606 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
20607         LDKUnsignedChannelUpdate this_ptr_conv;
20608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20609         this_ptr_conv.is_owned = false;
20610         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
20611         return ret_val;
20612 }
20613
20614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
20615         LDKUnsignedChannelUpdate this_ptr_conv;
20616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20617         this_ptr_conv.is_owned = false;
20618         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
20619 }
20620
20621 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20622         LDKUnsignedChannelUpdate this_ptr_conv;
20623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20624         this_ptr_conv.is_owned = false;
20625         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
20626         return ret_val;
20627 }
20628
20629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20630         LDKUnsignedChannelUpdate this_ptr_conv;
20631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20632         this_ptr_conv.is_owned = false;
20633         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
20634 }
20635
20636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20637         LDKUnsignedChannelUpdate this_ptr_conv;
20638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20639         this_ptr_conv.is_owned = false;
20640         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
20641         return ret_val;
20642 }
20643
20644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20645         LDKUnsignedChannelUpdate this_ptr_conv;
20646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20647         this_ptr_conv.is_owned = false;
20648         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
20649 }
20650
20651 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20652         LDKUnsignedChannelUpdate this_ptr_conv;
20653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20654         this_ptr_conv.is_owned = false;
20655         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
20656         return ret_val;
20657 }
20658
20659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20660         LDKUnsignedChannelUpdate this_ptr_conv;
20661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20662         this_ptr_conv.is_owned = false;
20663         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
20664 }
20665
20666 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20667         LDKUnsignedChannelUpdate this_ptr_conv;
20668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20669         this_ptr_conv.is_owned = false;
20670         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
20671         return ret_val;
20672 }
20673
20674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20675         LDKUnsignedChannelUpdate this_ptr_conv;
20676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20677         this_ptr_conv.is_owned = false;
20678         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
20679 }
20680
20681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20682         LDKUnsignedChannelUpdate orig_conv;
20683         orig_conv.inner = (void*)(orig & (~1));
20684         orig_conv.is_owned = false;
20685         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
20686         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20687         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20688         uint64_t ret_ref = (uint64_t)ret_var.inner;
20689         if (ret_var.is_owned) {
20690                 ret_ref |= 1;
20691         }
20692         return ret_ref;
20693 }
20694
20695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20696         LDKChannelUpdate this_obj_conv;
20697         this_obj_conv.inner = (void*)(this_obj & (~1));
20698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20699         ChannelUpdate_free(this_obj_conv);
20700 }
20701
20702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20703         LDKChannelUpdate this_ptr_conv;
20704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20705         this_ptr_conv.is_owned = false;
20706         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
20708         return ret_arr;
20709 }
20710
20711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20712         LDKChannelUpdate this_ptr_conv;
20713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20714         this_ptr_conv.is_owned = false;
20715         LDKSignature val_ref;
20716         CHECK((*env)->GetArrayLength(env, val) == 64);
20717         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20718         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
20719 }
20720
20721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20722         LDKChannelUpdate this_ptr_conv;
20723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20724         this_ptr_conv.is_owned = false;
20725         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
20726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20728         uint64_t ret_ref = (uint64_t)ret_var.inner;
20729         if (ret_var.is_owned) {
20730                 ret_ref |= 1;
20731         }
20732         return ret_ref;
20733 }
20734
20735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20736         LDKChannelUpdate this_ptr_conv;
20737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20738         this_ptr_conv.is_owned = false;
20739         LDKUnsignedChannelUpdate val_conv;
20740         val_conv.inner = (void*)(val & (~1));
20741         val_conv.is_owned = (val & 1) || (val == 0);
20742         val_conv = UnsignedChannelUpdate_clone(&val_conv);
20743         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
20744 }
20745
20746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
20747         LDKSignature signature_arg_ref;
20748         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20749         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20750         LDKUnsignedChannelUpdate contents_arg_conv;
20751         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20752         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20753         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
20754         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
20755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20757         uint64_t ret_ref = (uint64_t)ret_var.inner;
20758         if (ret_var.is_owned) {
20759                 ret_ref |= 1;
20760         }
20761         return ret_ref;
20762 }
20763
20764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20765         LDKChannelUpdate orig_conv;
20766         orig_conv.inner = (void*)(orig & (~1));
20767         orig_conv.is_owned = false;
20768         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
20769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20771         uint64_t ret_ref = (uint64_t)ret_var.inner;
20772         if (ret_var.is_owned) {
20773                 ret_ref |= 1;
20774         }
20775         return ret_ref;
20776 }
20777
20778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20779         LDKQueryChannelRange this_obj_conv;
20780         this_obj_conv.inner = (void*)(this_obj & (~1));
20781         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20782         QueryChannelRange_free(this_obj_conv);
20783 }
20784
20785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20786         LDKQueryChannelRange this_ptr_conv;
20787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20788         this_ptr_conv.is_owned = false;
20789         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
20791         return ret_arr;
20792 }
20793
20794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20795         LDKQueryChannelRange this_ptr_conv;
20796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20797         this_ptr_conv.is_owned = false;
20798         LDKThirtyTwoBytes val_ref;
20799         CHECK((*env)->GetArrayLength(env, val) == 32);
20800         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20801         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20802 }
20803
20804 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20805         LDKQueryChannelRange this_ptr_conv;
20806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20807         this_ptr_conv.is_owned = false;
20808         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
20809         return ret_val;
20810 }
20811
20812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20813         LDKQueryChannelRange this_ptr_conv;
20814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20815         this_ptr_conv.is_owned = false;
20816         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
20817 }
20818
20819 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20820         LDKQueryChannelRange this_ptr_conv;
20821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20822         this_ptr_conv.is_owned = false;
20823         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
20824         return ret_val;
20825 }
20826
20827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20828         LDKQueryChannelRange this_ptr_conv;
20829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20830         this_ptr_conv.is_owned = false;
20831         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20832 }
20833
20834 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) {
20835         LDKThirtyTwoBytes chain_hash_arg_ref;
20836         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20837         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20838         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
20839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20841         uint64_t ret_ref = (uint64_t)ret_var.inner;
20842         if (ret_var.is_owned) {
20843                 ret_ref |= 1;
20844         }
20845         return ret_ref;
20846 }
20847
20848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20849         LDKQueryChannelRange orig_conv;
20850         orig_conv.inner = (void*)(orig & (~1));
20851         orig_conv.is_owned = false;
20852         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
20853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20855         uint64_t ret_ref = (uint64_t)ret_var.inner;
20856         if (ret_var.is_owned) {
20857                 ret_ref |= 1;
20858         }
20859         return ret_ref;
20860 }
20861
20862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20863         LDKReplyChannelRange this_obj_conv;
20864         this_obj_conv.inner = (void*)(this_obj & (~1));
20865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20866         ReplyChannelRange_free(this_obj_conv);
20867 }
20868
20869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20870         LDKReplyChannelRange this_ptr_conv;
20871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20872         this_ptr_conv.is_owned = false;
20873         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
20875         return ret_arr;
20876 }
20877
20878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20879         LDKReplyChannelRange this_ptr_conv;
20880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20881         this_ptr_conv.is_owned = false;
20882         LDKThirtyTwoBytes val_ref;
20883         CHECK((*env)->GetArrayLength(env, val) == 32);
20884         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20885         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20886 }
20887
20888 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20889         LDKReplyChannelRange this_ptr_conv;
20890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20891         this_ptr_conv.is_owned = false;
20892         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20893         return ret_val;
20894 }
20895
20896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20897         LDKReplyChannelRange this_ptr_conv;
20898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20899         this_ptr_conv.is_owned = false;
20900         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20901 }
20902
20903 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20904         LDKReplyChannelRange this_ptr_conv;
20905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20906         this_ptr_conv.is_owned = false;
20907         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20908         return ret_val;
20909 }
20910
20911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20912         LDKReplyChannelRange this_ptr_conv;
20913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20914         this_ptr_conv.is_owned = false;
20915         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20916 }
20917
20918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
20919         LDKReplyChannelRange this_ptr_conv;
20920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20921         this_ptr_conv.is_owned = false;
20922         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20923         return ret_val;
20924 }
20925
20926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20927         LDKReplyChannelRange this_ptr_conv;
20928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20929         this_ptr_conv.is_owned = false;
20930         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20931 }
20932
20933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20934         LDKReplyChannelRange this_ptr_conv;
20935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20936         this_ptr_conv.is_owned = false;
20937         LDKCVec_u64Z val_constr;
20938         val_constr.datalen = (*env)->GetArrayLength(env, val);
20939         if (val_constr.datalen > 0)
20940                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20941         else
20942                 val_constr.data = NULL;
20943         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20944         for (size_t g = 0; g < val_constr.datalen; g++) {
20945                 int64_t val_conv_6 = val_vals[g];
20946                 val_constr.data[g] = val_conv_6;
20947         }
20948         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20949         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20950 }
20951
20952 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) {
20953         LDKThirtyTwoBytes chain_hash_arg_ref;
20954         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20955         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20956         LDKCVec_u64Z short_channel_ids_arg_constr;
20957         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20958         if (short_channel_ids_arg_constr.datalen > 0)
20959                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20960         else
20961                 short_channel_ids_arg_constr.data = NULL;
20962         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20963         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20964                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20965                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20966         }
20967         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20968         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20971         uint64_t ret_ref = (uint64_t)ret_var.inner;
20972         if (ret_var.is_owned) {
20973                 ret_ref |= 1;
20974         }
20975         return ret_ref;
20976 }
20977
20978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20979         LDKReplyChannelRange orig_conv;
20980         orig_conv.inner = (void*)(orig & (~1));
20981         orig_conv.is_owned = false;
20982         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20985         uint64_t ret_ref = (uint64_t)ret_var.inner;
20986         if (ret_var.is_owned) {
20987                 ret_ref |= 1;
20988         }
20989         return ret_ref;
20990 }
20991
20992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20993         LDKQueryShortChannelIds this_obj_conv;
20994         this_obj_conv.inner = (void*)(this_obj & (~1));
20995         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20996         QueryShortChannelIds_free(this_obj_conv);
20997 }
20998
20999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21000         LDKQueryShortChannelIds this_ptr_conv;
21001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21002         this_ptr_conv.is_owned = false;
21003         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
21005         return ret_arr;
21006 }
21007
21008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21009         LDKQueryShortChannelIds this_ptr_conv;
21010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21011         this_ptr_conv.is_owned = false;
21012         LDKThirtyTwoBytes val_ref;
21013         CHECK((*env)->GetArrayLength(env, val) == 32);
21014         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21015         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
21016 }
21017
21018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21019         LDKQueryShortChannelIds this_ptr_conv;
21020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21021         this_ptr_conv.is_owned = false;
21022         LDKCVec_u64Z val_constr;
21023         val_constr.datalen = (*env)->GetArrayLength(env, val);
21024         if (val_constr.datalen > 0)
21025                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21026         else
21027                 val_constr.data = NULL;
21028         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21029         for (size_t g = 0; g < val_constr.datalen; g++) {
21030                 int64_t val_conv_6 = val_vals[g];
21031                 val_constr.data[g] = val_conv_6;
21032         }
21033         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21034         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
21035 }
21036
21037 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) {
21038         LDKThirtyTwoBytes chain_hash_arg_ref;
21039         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
21040         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
21041         LDKCVec_u64Z short_channel_ids_arg_constr;
21042         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
21043         if (short_channel_ids_arg_constr.datalen > 0)
21044                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21045         else
21046                 short_channel_ids_arg_constr.data = NULL;
21047         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
21048         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
21049                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
21050                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
21051         }
21052         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
21053         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
21054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21056         uint64_t ret_ref = (uint64_t)ret_var.inner;
21057         if (ret_var.is_owned) {
21058                 ret_ref |= 1;
21059         }
21060         return ret_ref;
21061 }
21062
21063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21064         LDKQueryShortChannelIds orig_conv;
21065         orig_conv.inner = (void*)(orig & (~1));
21066         orig_conv.is_owned = false;
21067         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
21068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21070         uint64_t ret_ref = (uint64_t)ret_var.inner;
21071         if (ret_var.is_owned) {
21072                 ret_ref |= 1;
21073         }
21074         return ret_ref;
21075 }
21076
21077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21078         LDKReplyShortChannelIdsEnd this_obj_conv;
21079         this_obj_conv.inner = (void*)(this_obj & (~1));
21080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21081         ReplyShortChannelIdsEnd_free(this_obj_conv);
21082 }
21083
21084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21085         LDKReplyShortChannelIdsEnd this_ptr_conv;
21086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21087         this_ptr_conv.is_owned = false;
21088         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
21090         return ret_arr;
21091 }
21092
21093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21094         LDKReplyShortChannelIdsEnd this_ptr_conv;
21095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21096         this_ptr_conv.is_owned = false;
21097         LDKThirtyTwoBytes val_ref;
21098         CHECK((*env)->GetArrayLength(env, val) == 32);
21099         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21100         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
21101 }
21102
21103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
21104         LDKReplyShortChannelIdsEnd this_ptr_conv;
21105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21106         this_ptr_conv.is_owned = false;
21107         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
21108         return ret_val;
21109 }
21110
21111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21112         LDKReplyShortChannelIdsEnd this_ptr_conv;
21113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21114         this_ptr_conv.is_owned = false;
21115         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
21116 }
21117
21118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
21119         LDKThirtyTwoBytes chain_hash_arg_ref;
21120         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
21121         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
21122         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
21123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21125         uint64_t ret_ref = (uint64_t)ret_var.inner;
21126         if (ret_var.is_owned) {
21127                 ret_ref |= 1;
21128         }
21129         return ret_ref;
21130 }
21131
21132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21133         LDKReplyShortChannelIdsEnd orig_conv;
21134         orig_conv.inner = (void*)(orig & (~1));
21135         orig_conv.is_owned = false;
21136         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
21137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21139         uint64_t ret_ref = (uint64_t)ret_var.inner;
21140         if (ret_var.is_owned) {
21141                 ret_ref |= 1;
21142         }
21143         return ret_ref;
21144 }
21145
21146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21147         LDKGossipTimestampFilter this_obj_conv;
21148         this_obj_conv.inner = (void*)(this_obj & (~1));
21149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21150         GossipTimestampFilter_free(this_obj_conv);
21151 }
21152
21153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21154         LDKGossipTimestampFilter 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, 32);
21158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
21159         return ret_arr;
21160 }
21161
21162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21163         LDKGossipTimestampFilter this_ptr_conv;
21164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21165         this_ptr_conv.is_owned = false;
21166         LDKThirtyTwoBytes val_ref;
21167         CHECK((*env)->GetArrayLength(env, val) == 32);
21168         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21169         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
21170 }
21171
21172 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
21173         LDKGossipTimestampFilter this_ptr_conv;
21174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21175         this_ptr_conv.is_owned = false;
21176         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
21177         return ret_val;
21178 }
21179
21180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21181         LDKGossipTimestampFilter this_ptr_conv;
21182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21183         this_ptr_conv.is_owned = false;
21184         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
21185 }
21186
21187 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
21188         LDKGossipTimestampFilter this_ptr_conv;
21189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21190         this_ptr_conv.is_owned = false;
21191         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
21192         return ret_val;
21193 }
21194
21195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21196         LDKGossipTimestampFilter this_ptr_conv;
21197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21198         this_ptr_conv.is_owned = false;
21199         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
21200 }
21201
21202 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) {
21203         LDKThirtyTwoBytes chain_hash_arg_ref;
21204         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
21205         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
21206         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
21207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21209         uint64_t ret_ref = (uint64_t)ret_var.inner;
21210         if (ret_var.is_owned) {
21211                 ret_ref |= 1;
21212         }
21213         return ret_ref;
21214 }
21215
21216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21217         LDKGossipTimestampFilter orig_conv;
21218         orig_conv.inner = (void*)(orig & (~1));
21219         orig_conv.is_owned = false;
21220         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
21221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21223         uint64_t ret_ref = (uint64_t)ret_var.inner;
21224         if (ret_var.is_owned) {
21225                 ret_ref |= 1;
21226         }
21227         return ret_ref;
21228 }
21229
21230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21231         if ((this_ptr & 1) != 0) return;
21232         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
21233         FREE((void*)this_ptr);
21234         ErrorAction_free(this_ptr_conv);
21235 }
21236
21237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21238         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
21239         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21240         *ret_copy = ErrorAction_clone(orig_conv);
21241         uint64_t ret_ref = (uint64_t)ret_copy;
21242         return ret_ref;
21243 }
21244
21245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
21246         LDKErrorMessage msg_conv;
21247         msg_conv.inner = (void*)(msg & (~1));
21248         msg_conv.is_owned = (msg & 1) || (msg == 0);
21249         msg_conv = ErrorMessage_clone(&msg_conv);
21250         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21251         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
21252         uint64_t ret_ref = (uint64_t)ret_copy;
21253         return ret_ref;
21254 }
21255
21256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
21257         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21258         *ret_copy = ErrorAction_ignore_error();
21259         uint64_t ret_ref = (uint64_t)ret_copy;
21260         return ret_ref;
21261 }
21262
21263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
21264         LDKLevel a_conv = LDKLevel_from_java(env, a);
21265         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21266         *ret_copy = ErrorAction_ignore_and_log(a_conv);
21267         uint64_t ret_ref = (uint64_t)ret_copy;
21268         return ret_ref;
21269 }
21270
21271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
21272         LDKErrorMessage msg_conv;
21273         msg_conv.inner = (void*)(msg & (~1));
21274         msg_conv.is_owned = (msg & 1) || (msg == 0);
21275         msg_conv = ErrorMessage_clone(&msg_conv);
21276         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21277         *ret_copy = ErrorAction_send_error_message(msg_conv);
21278         uint64_t ret_ref = (uint64_t)ret_copy;
21279         return ret_ref;
21280 }
21281
21282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21283         LDKLightningError this_obj_conv;
21284         this_obj_conv.inner = (void*)(this_obj & (~1));
21285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21286         LightningError_free(this_obj_conv);
21287 }
21288
21289 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
21290         LDKLightningError this_ptr_conv;
21291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21292         this_ptr_conv.is_owned = false;
21293         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
21294         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
21295         Str_free(ret_str);
21296         return ret_conv;
21297 }
21298
21299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
21300         LDKLightningError this_ptr_conv;
21301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21302         this_ptr_conv.is_owned = false;
21303         LDKStr val_conv = java_to_owned_str(env, val);
21304         LightningError_set_err(&this_ptr_conv, val_conv);
21305 }
21306
21307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
21308         LDKLightningError this_ptr_conv;
21309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21310         this_ptr_conv.is_owned = false;
21311         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
21312         *ret_copy = LightningError_get_action(&this_ptr_conv);
21313         uint64_t ret_ref = (uint64_t)ret_copy;
21314         return ret_ref;
21315 }
21316
21317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21318         LDKLightningError this_ptr_conv;
21319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21320         this_ptr_conv.is_owned = false;
21321         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
21322         LightningError_set_action(&this_ptr_conv, val_conv);
21323 }
21324
21325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
21326         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
21327         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
21328         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
21329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21331         uint64_t ret_ref = (uint64_t)ret_var.inner;
21332         if (ret_var.is_owned) {
21333                 ret_ref |= 1;
21334         }
21335         return ret_ref;
21336 }
21337
21338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21339         LDKLightningError orig_conv;
21340         orig_conv.inner = (void*)(orig & (~1));
21341         orig_conv.is_owned = false;
21342         LDKLightningError ret_var = LightningError_clone(&orig_conv);
21343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21345         uint64_t ret_ref = (uint64_t)ret_var.inner;
21346         if (ret_var.is_owned) {
21347                 ret_ref |= 1;
21348         }
21349         return ret_ref;
21350 }
21351
21352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21353         LDKCommitmentUpdate this_obj_conv;
21354         this_obj_conv.inner = (void*)(this_obj & (~1));
21355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21356         CommitmentUpdate_free(this_obj_conv);
21357 }
21358
21359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21360         LDKCommitmentUpdate this_ptr_conv;
21361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21362         this_ptr_conv.is_owned = false;
21363         LDKCVec_UpdateAddHTLCZ val_constr;
21364         val_constr.datalen = (*env)->GetArrayLength(env, val);
21365         if (val_constr.datalen > 0)
21366                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21367         else
21368                 val_constr.data = NULL;
21369         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21370         for (size_t p = 0; p < val_constr.datalen; p++) {
21371                 int64_t val_conv_15 = val_vals[p];
21372                 LDKUpdateAddHTLC val_conv_15_conv;
21373                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
21374                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
21375                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
21376                 val_constr.data[p] = val_conv_15_conv;
21377         }
21378         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21379         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
21380 }
21381
21382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21383         LDKCommitmentUpdate this_ptr_conv;
21384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21385         this_ptr_conv.is_owned = false;
21386         LDKCVec_UpdateFulfillHTLCZ val_constr;
21387         val_constr.datalen = (*env)->GetArrayLength(env, val);
21388         if (val_constr.datalen > 0)
21389                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21390         else
21391                 val_constr.data = NULL;
21392         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21393         for (size_t t = 0; t < val_constr.datalen; t++) {
21394                 int64_t val_conv_19 = val_vals[t];
21395                 LDKUpdateFulfillHTLC val_conv_19_conv;
21396                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
21397                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
21398                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
21399                 val_constr.data[t] = val_conv_19_conv;
21400         }
21401         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21402         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
21403 }
21404
21405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
21406         LDKCommitmentUpdate this_ptr_conv;
21407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21408         this_ptr_conv.is_owned = false;
21409         LDKCVec_UpdateFailHTLCZ val_constr;
21410         val_constr.datalen = (*env)->GetArrayLength(env, val);
21411         if (val_constr.datalen > 0)
21412                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21413         else
21414                 val_constr.data = NULL;
21415         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21416         for (size_t q = 0; q < val_constr.datalen; q++) {
21417                 int64_t val_conv_16 = val_vals[q];
21418                 LDKUpdateFailHTLC val_conv_16_conv;
21419                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
21420                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
21421                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
21422                 val_constr.data[q] = val_conv_16_conv;
21423         }
21424         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21425         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
21426 }
21427
21428 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) {
21429         LDKCommitmentUpdate this_ptr_conv;
21430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21431         this_ptr_conv.is_owned = false;
21432         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
21433         val_constr.datalen = (*env)->GetArrayLength(env, val);
21434         if (val_constr.datalen > 0)
21435                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21436         else
21437                 val_constr.data = NULL;
21438         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
21439         for (size_t z = 0; z < val_constr.datalen; z++) {
21440                 int64_t val_conv_25 = val_vals[z];
21441                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
21442                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
21443                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
21444                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
21445                 val_constr.data[z] = val_conv_25_conv;
21446         }
21447         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
21448         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
21449 }
21450
21451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
21452         LDKCommitmentUpdate this_ptr_conv;
21453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21454         this_ptr_conv.is_owned = false;
21455         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
21456         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21457         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21458         uint64_t ret_ref = (uint64_t)ret_var.inner;
21459         if (ret_var.is_owned) {
21460                 ret_ref |= 1;
21461         }
21462         return ret_ref;
21463 }
21464
21465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21466         LDKCommitmentUpdate this_ptr_conv;
21467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21468         this_ptr_conv.is_owned = false;
21469         LDKUpdateFee val_conv;
21470         val_conv.inner = (void*)(val & (~1));
21471         val_conv.is_owned = (val & 1) || (val == 0);
21472         val_conv = UpdateFee_clone(&val_conv);
21473         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
21474 }
21475
21476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
21477         LDKCommitmentUpdate this_ptr_conv;
21478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21479         this_ptr_conv.is_owned = false;
21480         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
21481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21483         uint64_t ret_ref = (uint64_t)ret_var.inner;
21484         if (ret_var.is_owned) {
21485                 ret_ref |= 1;
21486         }
21487         return ret_ref;
21488 }
21489
21490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21491         LDKCommitmentUpdate this_ptr_conv;
21492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21493         this_ptr_conv.is_owned = false;
21494         LDKCommitmentSigned val_conv;
21495         val_conv.inner = (void*)(val & (~1));
21496         val_conv.is_owned = (val & 1) || (val == 0);
21497         val_conv = CommitmentSigned_clone(&val_conv);
21498         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
21499 }
21500
21501 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) {
21502         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
21503         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
21504         if (update_add_htlcs_arg_constr.datalen > 0)
21505                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21506         else
21507                 update_add_htlcs_arg_constr.data = NULL;
21508         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
21509         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
21510                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
21511                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
21512                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
21513                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
21514                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
21515                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
21516         }
21517         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
21518         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
21519         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
21520         if (update_fulfill_htlcs_arg_constr.datalen > 0)
21521                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21522         else
21523                 update_fulfill_htlcs_arg_constr.data = NULL;
21524         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
21525         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
21526                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
21527                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
21528                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
21529                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
21530                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
21531                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
21532         }
21533         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
21534         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
21535         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
21536         if (update_fail_htlcs_arg_constr.datalen > 0)
21537                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21538         else
21539                 update_fail_htlcs_arg_constr.data = NULL;
21540         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
21541         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
21542                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
21543                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
21544                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
21545                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
21546                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
21547                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
21548         }
21549         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
21550         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
21551         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
21552         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
21553                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21554         else
21555                 update_fail_malformed_htlcs_arg_constr.data = NULL;
21556         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
21557         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
21558                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
21559                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
21560                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
21561                 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);
21562                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
21563                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
21564         }
21565         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
21566         LDKUpdateFee update_fee_arg_conv;
21567         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
21568         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
21569         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
21570         LDKCommitmentSigned commitment_signed_arg_conv;
21571         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
21572         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
21573         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
21574         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);
21575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21577         uint64_t ret_ref = (uint64_t)ret_var.inner;
21578         if (ret_var.is_owned) {
21579                 ret_ref |= 1;
21580         }
21581         return ret_ref;
21582 }
21583
21584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21585         LDKCommitmentUpdate orig_conv;
21586         orig_conv.inner = (void*)(orig & (~1));
21587         orig_conv.is_owned = false;
21588         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
21589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21591         uint64_t ret_ref = (uint64_t)ret_var.inner;
21592         if (ret_var.is_owned) {
21593                 ret_ref |= 1;
21594         }
21595         return ret_ref;
21596 }
21597
21598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21599         if ((this_ptr & 1) != 0) return;
21600         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
21601         FREE((void*)this_ptr);
21602         HTLCFailChannelUpdate_free(this_ptr_conv);
21603 }
21604
21605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21606         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
21607         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21608         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
21609         uint64_t ret_ref = (uint64_t)ret_copy;
21610         return ret_ref;
21611 }
21612
21613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
21614         LDKChannelUpdate msg_conv;
21615         msg_conv.inner = (void*)(msg & (~1));
21616         msg_conv.is_owned = (msg & 1) || (msg == 0);
21617         msg_conv = ChannelUpdate_clone(&msg_conv);
21618         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21619         *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv);
21620         uint64_t ret_ref = (uint64_t)ret_copy;
21621         return ret_ref;
21622 }
21623
21624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
21625         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21626         *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent);
21627         uint64_t ret_ref = (uint64_t)ret_copy;
21628         return ret_ref;
21629 }
21630
21631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
21632         LDKPublicKey node_id_ref;
21633         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21634         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21635         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21636         *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent);
21637         uint64_t ret_ref = (uint64_t)ret_copy;
21638         return ret_ref;
21639 }
21640
21641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21642         if ((this_ptr & 1) != 0) return;
21643         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
21644         FREE((void*)this_ptr);
21645         ChannelMessageHandler_free(this_ptr_conv);
21646 }
21647
21648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21649         if ((this_ptr & 1) != 0) return;
21650         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
21651         FREE((void*)this_ptr);
21652         RoutingMessageHandler_free(this_ptr_conv);
21653 }
21654
21655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21656         LDKAcceptChannel obj_conv;
21657         obj_conv.inner = (void*)(obj & (~1));
21658         obj_conv.is_owned = false;
21659         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
21660         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21661         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21662         CVec_u8Z_free(ret_var);
21663         return ret_arr;
21664 }
21665
21666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21667         LDKu8slice ser_ref;
21668         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21669         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21670         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21671         *ret_conv = AcceptChannel_read(ser_ref);
21672         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21673         return (uint64_t)ret_conv;
21674 }
21675
21676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
21677         LDKAnnouncementSignatures obj_conv;
21678         obj_conv.inner = (void*)(obj & (~1));
21679         obj_conv.is_owned = false;
21680         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
21681         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21682         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21683         CVec_u8Z_free(ret_var);
21684         return ret_arr;
21685 }
21686
21687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21688         LDKu8slice ser_ref;
21689         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21690         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21691         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21692         *ret_conv = AnnouncementSignatures_read(ser_ref);
21693         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21694         return (uint64_t)ret_conv;
21695 }
21696
21697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
21698         LDKChannelReestablish obj_conv;
21699         obj_conv.inner = (void*)(obj & (~1));
21700         obj_conv.is_owned = false;
21701         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
21702         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21703         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21704         CVec_u8Z_free(ret_var);
21705         return ret_arr;
21706 }
21707
21708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21709         LDKu8slice ser_ref;
21710         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21711         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21712         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21713         *ret_conv = ChannelReestablish_read(ser_ref);
21714         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21715         return (uint64_t)ret_conv;
21716 }
21717
21718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21719         LDKClosingSigned obj_conv;
21720         obj_conv.inner = (void*)(obj & (~1));
21721         obj_conv.is_owned = false;
21722         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
21723         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21724         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21725         CVec_u8Z_free(ret_var);
21726         return ret_arr;
21727 }
21728
21729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21730         LDKu8slice ser_ref;
21731         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21732         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21733         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21734         *ret_conv = ClosingSigned_read(ser_ref);
21735         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21736         return (uint64_t)ret_conv;
21737 }
21738
21739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21740         LDKClosingSignedFeeRange obj_conv;
21741         obj_conv.inner = (void*)(obj & (~1));
21742         obj_conv.is_owned = false;
21743         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
21744         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21745         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21746         CVec_u8Z_free(ret_var);
21747         return ret_arr;
21748 }
21749
21750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21751         LDKu8slice ser_ref;
21752         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21753         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21754         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21755         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
21756         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21757         return (uint64_t)ret_conv;
21758 }
21759
21760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21761         LDKCommitmentSigned obj_conv;
21762         obj_conv.inner = (void*)(obj & (~1));
21763         obj_conv.is_owned = false;
21764         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
21765         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21766         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21767         CVec_u8Z_free(ret_var);
21768         return ret_arr;
21769 }
21770
21771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21772         LDKu8slice ser_ref;
21773         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21774         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21775         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21776         *ret_conv = CommitmentSigned_read(ser_ref);
21777         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21778         return (uint64_t)ret_conv;
21779 }
21780
21781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
21782         LDKFundingCreated obj_conv;
21783         obj_conv.inner = (void*)(obj & (~1));
21784         obj_conv.is_owned = false;
21785         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
21786         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21787         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21788         CVec_u8Z_free(ret_var);
21789         return ret_arr;
21790 }
21791
21792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21793         LDKu8slice ser_ref;
21794         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21795         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21796         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21797         *ret_conv = FundingCreated_read(ser_ref);
21798         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21799         return (uint64_t)ret_conv;
21800 }
21801
21802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21803         LDKFundingSigned obj_conv;
21804         obj_conv.inner = (void*)(obj & (~1));
21805         obj_conv.is_owned = false;
21806         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
21807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21809         CVec_u8Z_free(ret_var);
21810         return ret_arr;
21811 }
21812
21813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21814         LDKu8slice ser_ref;
21815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21817         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21818         *ret_conv = FundingSigned_read(ser_ref);
21819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21820         return (uint64_t)ret_conv;
21821 }
21822
21823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
21824         LDKFundingLocked obj_conv;
21825         obj_conv.inner = (void*)(obj & (~1));
21826         obj_conv.is_owned = false;
21827         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
21828         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21829         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21830         CVec_u8Z_free(ret_var);
21831         return ret_arr;
21832 }
21833
21834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21835         LDKu8slice ser_ref;
21836         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21837         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21838         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21839         *ret_conv = FundingLocked_read(ser_ref);
21840         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21841         return (uint64_t)ret_conv;
21842 }
21843
21844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
21845         LDKInit obj_conv;
21846         obj_conv.inner = (void*)(obj & (~1));
21847         obj_conv.is_owned = false;
21848         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
21849         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21850         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21851         CVec_u8Z_free(ret_var);
21852         return ret_arr;
21853 }
21854
21855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21856         LDKu8slice ser_ref;
21857         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21858         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21859         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21860         *ret_conv = Init_read(ser_ref);
21861         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21862         return (uint64_t)ret_conv;
21863 }
21864
21865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21866         LDKOpenChannel obj_conv;
21867         obj_conv.inner = (void*)(obj & (~1));
21868         obj_conv.is_owned = false;
21869         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
21870         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21871         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21872         CVec_u8Z_free(ret_var);
21873         return ret_arr;
21874 }
21875
21876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21877         LDKu8slice ser_ref;
21878         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21879         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21880         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21881         *ret_conv = OpenChannel_read(ser_ref);
21882         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21883         return (uint64_t)ret_conv;
21884 }
21885
21886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
21887         LDKRevokeAndACK obj_conv;
21888         obj_conv.inner = (void*)(obj & (~1));
21889         obj_conv.is_owned = false;
21890         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
21891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21893         CVec_u8Z_free(ret_var);
21894         return ret_arr;
21895 }
21896
21897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21898         LDKu8slice ser_ref;
21899         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21900         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21901         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21902         *ret_conv = RevokeAndACK_read(ser_ref);
21903         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21904         return (uint64_t)ret_conv;
21905 }
21906
21907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
21908         LDKShutdown obj_conv;
21909         obj_conv.inner = (void*)(obj & (~1));
21910         obj_conv.is_owned = false;
21911         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
21912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21914         CVec_u8Z_free(ret_var);
21915         return ret_arr;
21916 }
21917
21918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21919         LDKu8slice ser_ref;
21920         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21921         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21922         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21923         *ret_conv = Shutdown_read(ser_ref);
21924         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21925         return (uint64_t)ret_conv;
21926 }
21927
21928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21929         LDKUpdateFailHTLC obj_conv;
21930         obj_conv.inner = (void*)(obj & (~1));
21931         obj_conv.is_owned = false;
21932         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
21933         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21934         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21935         CVec_u8Z_free(ret_var);
21936         return ret_arr;
21937 }
21938
21939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21940         LDKu8slice ser_ref;
21941         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21942         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21943         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21944         *ret_conv = UpdateFailHTLC_read(ser_ref);
21945         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21946         return (uint64_t)ret_conv;
21947 }
21948
21949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21950         LDKUpdateFailMalformedHTLC obj_conv;
21951         obj_conv.inner = (void*)(obj & (~1));
21952         obj_conv.is_owned = false;
21953         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
21954         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21955         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21956         CVec_u8Z_free(ret_var);
21957         return ret_arr;
21958 }
21959
21960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21961         LDKu8slice ser_ref;
21962         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21963         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21964         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21965         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21966         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21967         return (uint64_t)ret_conv;
21968 }
21969
21970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
21971         LDKUpdateFee obj_conv;
21972         obj_conv.inner = (void*)(obj & (~1));
21973         obj_conv.is_owned = false;
21974         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21975         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21976         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21977         CVec_u8Z_free(ret_var);
21978         return ret_arr;
21979 }
21980
21981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21982         LDKu8slice ser_ref;
21983         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21984         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21985         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21986         *ret_conv = UpdateFee_read(ser_ref);
21987         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21988         return (uint64_t)ret_conv;
21989 }
21990
21991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21992         LDKUpdateFulfillHTLC obj_conv;
21993         obj_conv.inner = (void*)(obj & (~1));
21994         obj_conv.is_owned = false;
21995         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21996         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21997         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21998         CVec_u8Z_free(ret_var);
21999         return ret_arr;
22000 }
22001
22002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22003         LDKu8slice ser_ref;
22004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22006         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22007         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
22008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22009         return (uint64_t)ret_conv;
22010 }
22011
22012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
22013         LDKUpdateAddHTLC obj_conv;
22014         obj_conv.inner = (void*)(obj & (~1));
22015         obj_conv.is_owned = false;
22016         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
22017         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22018         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22019         CVec_u8Z_free(ret_var);
22020         return ret_arr;
22021 }
22022
22023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22024         LDKu8slice ser_ref;
22025         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22026         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22027         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22028         *ret_conv = UpdateAddHTLC_read(ser_ref);
22029         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22030         return (uint64_t)ret_conv;
22031 }
22032
22033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
22034         LDKPing obj_conv;
22035         obj_conv.inner = (void*)(obj & (~1));
22036         obj_conv.is_owned = false;
22037         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
22038         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22039         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22040         CVec_u8Z_free(ret_var);
22041         return ret_arr;
22042 }
22043
22044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22045         LDKu8slice ser_ref;
22046         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22047         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22048         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22049         *ret_conv = Ping_read(ser_ref);
22050         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22051         return (uint64_t)ret_conv;
22052 }
22053
22054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
22055         LDKPong obj_conv;
22056         obj_conv.inner = (void*)(obj & (~1));
22057         obj_conv.is_owned = false;
22058         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
22059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22061         CVec_u8Z_free(ret_var);
22062         return ret_arr;
22063 }
22064
22065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22066         LDKu8slice ser_ref;
22067         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22068         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22069         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22070         *ret_conv = Pong_read(ser_ref);
22071         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22072         return (uint64_t)ret_conv;
22073 }
22074
22075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22076         LDKUnsignedChannelAnnouncement obj_conv;
22077         obj_conv.inner = (void*)(obj & (~1));
22078         obj_conv.is_owned = false;
22079         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
22080         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22081         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22082         CVec_u8Z_free(ret_var);
22083         return ret_arr;
22084 }
22085
22086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22087         LDKu8slice ser_ref;
22088         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22089         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22090         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22091         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
22092         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22093         return (uint64_t)ret_conv;
22094 }
22095
22096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22097         LDKChannelAnnouncement obj_conv;
22098         obj_conv.inner = (void*)(obj & (~1));
22099         obj_conv.is_owned = false;
22100         LDKCVec_u8Z ret_var = ChannelAnnouncement_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_ChannelAnnouncement_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_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22112         *ret_conv = ChannelAnnouncement_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_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
22118         LDKUnsignedChannelUpdate obj_conv;
22119         obj_conv.inner = (void*)(obj & (~1));
22120         obj_conv.is_owned = false;
22121         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
22122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22124         CVec_u8Z_free(ret_var);
22125         return ret_arr;
22126 }
22127
22128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22129         LDKu8slice ser_ref;
22130         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22131         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22132         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22133         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
22134         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22135         return (uint64_t)ret_conv;
22136 }
22137
22138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
22139         LDKChannelUpdate obj_conv;
22140         obj_conv.inner = (void*)(obj & (~1));
22141         obj_conv.is_owned = false;
22142         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
22143         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22144         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22145         CVec_u8Z_free(ret_var);
22146         return ret_arr;
22147 }
22148
22149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22150         LDKu8slice ser_ref;
22151         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22152         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22153         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22154         *ret_conv = ChannelUpdate_read(ser_ref);
22155         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22156         return (uint64_t)ret_conv;
22157 }
22158
22159 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
22160         LDKErrorMessage obj_conv;
22161         obj_conv.inner = (void*)(obj & (~1));
22162         obj_conv.is_owned = false;
22163         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
22164         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22165         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22166         CVec_u8Z_free(ret_var);
22167         return ret_arr;
22168 }
22169
22170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22171         LDKu8slice ser_ref;
22172         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22173         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22174         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22175         *ret_conv = ErrorMessage_read(ser_ref);
22176         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22177         return (uint64_t)ret_conv;
22178 }
22179
22180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22181         LDKUnsignedNodeAnnouncement obj_conv;
22182         obj_conv.inner = (void*)(obj & (~1));
22183         obj_conv.is_owned = false;
22184         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
22185         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22186         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22187         CVec_u8Z_free(ret_var);
22188         return ret_arr;
22189 }
22190
22191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22192         LDKu8slice ser_ref;
22193         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22194         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22195         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22196         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
22197         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22198         return (uint64_t)ret_conv;
22199 }
22200
22201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
22202         LDKNodeAnnouncement obj_conv;
22203         obj_conv.inner = (void*)(obj & (~1));
22204         obj_conv.is_owned = false;
22205         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
22206         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22207         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22208         CVec_u8Z_free(ret_var);
22209         return ret_arr;
22210 }
22211
22212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22213         LDKu8slice ser_ref;
22214         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22215         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22216         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22217         *ret_conv = NodeAnnouncement_read(ser_ref);
22218         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22219         return (uint64_t)ret_conv;
22220 }
22221
22222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22223         LDKu8slice ser_ref;
22224         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22225         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22226         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22227         *ret_conv = QueryShortChannelIds_read(ser_ref);
22228         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22229         return (uint64_t)ret_conv;
22230 }
22231
22232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
22233         LDKQueryShortChannelIds obj_conv;
22234         obj_conv.inner = (void*)(obj & (~1));
22235         obj_conv.is_owned = false;
22236         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
22237         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22238         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22239         CVec_u8Z_free(ret_var);
22240         return ret_arr;
22241 }
22242
22243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22244         LDKu8slice ser_ref;
22245         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22246         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22247         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22248         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
22249         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22250         return (uint64_t)ret_conv;
22251 }
22252
22253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
22254         LDKReplyShortChannelIdsEnd obj_conv;
22255         obj_conv.inner = (void*)(obj & (~1));
22256         obj_conv.is_owned = false;
22257         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
22258         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22259         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22260         CVec_u8Z_free(ret_var);
22261         return ret_arr;
22262 }
22263
22264 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
22265         LDKQueryChannelRange this_arg_conv;
22266         this_arg_conv.inner = (void*)(this_arg & (~1));
22267         this_arg_conv.is_owned = false;
22268         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
22269         return ret_val;
22270 }
22271
22272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22273         LDKu8slice ser_ref;
22274         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22275         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22276         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22277         *ret_conv = QueryChannelRange_read(ser_ref);
22278         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22279         return (uint64_t)ret_conv;
22280 }
22281
22282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
22283         LDKQueryChannelRange obj_conv;
22284         obj_conv.inner = (void*)(obj & (~1));
22285         obj_conv.is_owned = false;
22286         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
22287         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22288         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22289         CVec_u8Z_free(ret_var);
22290         return ret_arr;
22291 }
22292
22293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22294         LDKu8slice ser_ref;
22295         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22296         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22297         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22298         *ret_conv = ReplyChannelRange_read(ser_ref);
22299         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22300         return (uint64_t)ret_conv;
22301 }
22302
22303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
22304         LDKReplyChannelRange obj_conv;
22305         obj_conv.inner = (void*)(obj & (~1));
22306         obj_conv.is_owned = false;
22307         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
22308         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22309         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22310         CVec_u8Z_free(ret_var);
22311         return ret_arr;
22312 }
22313
22314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22315         LDKu8slice ser_ref;
22316         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22317         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22318         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22319         *ret_conv = GossipTimestampFilter_read(ser_ref);
22320         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22321         return (uint64_t)ret_conv;
22322 }
22323
22324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
22325         LDKGossipTimestampFilter obj_conv;
22326         obj_conv.inner = (void*)(obj & (~1));
22327         obj_conv.is_owned = false;
22328         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
22329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22331         CVec_u8Z_free(ret_var);
22332         return ret_arr;
22333 }
22334
22335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22336         LDKIgnoringMessageHandler this_obj_conv;
22337         this_obj_conv.inner = (void*)(this_obj & (~1));
22338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22339         IgnoringMessageHandler_free(this_obj_conv);
22340 }
22341
22342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
22343         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
22344         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22345         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22346         uint64_t ret_ref = (uint64_t)ret_var.inner;
22347         if (ret_var.is_owned) {
22348                 ret_ref |= 1;
22349         }
22350         return ret_ref;
22351 }
22352
22353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
22354         LDKIgnoringMessageHandler this_arg_conv;
22355         this_arg_conv.inner = (void*)(this_arg & (~1));
22356         this_arg_conv.is_owned = false;
22357         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22358         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
22359         return (uint64_t)ret;
22360 }
22361
22362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
22363         LDKIgnoringMessageHandler this_arg_conv;
22364         this_arg_conv.inner = (void*)(this_arg & (~1));
22365         this_arg_conv.is_owned = false;
22366         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
22367         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
22368         return (uint64_t)ret;
22369 }
22370
22371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22372         LDKErroringMessageHandler this_obj_conv;
22373         this_obj_conv.inner = (void*)(this_obj & (~1));
22374         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22375         ErroringMessageHandler_free(this_obj_conv);
22376 }
22377
22378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
22379         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
22380         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22381         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22382         uint64_t ret_ref = (uint64_t)ret_var.inner;
22383         if (ret_var.is_owned) {
22384                 ret_ref |= 1;
22385         }
22386         return ret_ref;
22387 }
22388
22389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
22390         LDKErroringMessageHandler this_arg_conv;
22391         this_arg_conv.inner = (void*)(this_arg & (~1));
22392         this_arg_conv.is_owned = false;
22393         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22394         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
22395         return (uint64_t)ret;
22396 }
22397
22398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
22399         LDKErroringMessageHandler this_arg_conv;
22400         this_arg_conv.inner = (void*)(this_arg & (~1));
22401         this_arg_conv.is_owned = false;
22402         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
22403         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
22404         return (uint64_t)ret;
22405 }
22406
22407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22408         LDKMessageHandler this_obj_conv;
22409         this_obj_conv.inner = (void*)(this_obj & (~1));
22410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22411         MessageHandler_free(this_obj_conv);
22412 }
22413
22414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
22415         LDKMessageHandler this_ptr_conv;
22416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22417         this_ptr_conv.is_owned = false;
22418         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
22419         return ret_ret;
22420 }
22421
22422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22423         LDKMessageHandler this_ptr_conv;
22424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22425         this_ptr_conv.is_owned = false;
22426         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
22427         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
22428                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22429                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
22430         }
22431         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
22432 }
22433
22434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
22435         LDKMessageHandler this_ptr_conv;
22436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22437         this_ptr_conv.is_owned = false;
22438         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
22439         return ret_ret;
22440 }
22441
22442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22443         LDKMessageHandler this_ptr_conv;
22444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22445         this_ptr_conv.is_owned = false;
22446         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
22447         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
22448                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22449                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
22450         }
22451         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
22452 }
22453
22454 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) {
22455         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
22456         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
22457                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22458                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
22459         }
22460         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
22461         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
22462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22463                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
22464         }
22465         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
22466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22468         uint64_t ret_ref = (uint64_t)ret_var.inner;
22469         if (ret_var.is_owned) {
22470                 ret_ref |= 1;
22471         }
22472         return ret_ref;
22473 }
22474
22475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22476         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
22477         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
22478         *ret = SocketDescriptor_clone(orig_conv);
22479         return (uint64_t)ret;
22480 }
22481
22482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22483         if ((this_ptr & 1) != 0) return;
22484         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
22485         FREE((void*)this_ptr);
22486         SocketDescriptor_free(this_ptr_conv);
22487 }
22488
22489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22490         LDKPeerHandleError this_obj_conv;
22491         this_obj_conv.inner = (void*)(this_obj & (~1));
22492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22493         PeerHandleError_free(this_obj_conv);
22494 }
22495
22496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
22497         LDKPeerHandleError this_ptr_conv;
22498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22499         this_ptr_conv.is_owned = false;
22500         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
22501         return ret_val;
22502 }
22503
22504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22505         LDKPeerHandleError this_ptr_conv;
22506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22507         this_ptr_conv.is_owned = false;
22508         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
22509 }
22510
22511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
22512         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
22513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22515         uint64_t ret_ref = (uint64_t)ret_var.inner;
22516         if (ret_var.is_owned) {
22517                 ret_ref |= 1;
22518         }
22519         return ret_ref;
22520 }
22521
22522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22523         LDKPeerHandleError orig_conv;
22524         orig_conv.inner = (void*)(orig & (~1));
22525         orig_conv.is_owned = false;
22526         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
22527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22529         uint64_t ret_ref = (uint64_t)ret_var.inner;
22530         if (ret_var.is_owned) {
22531                 ret_ref |= 1;
22532         }
22533         return ret_ref;
22534 }
22535
22536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22537         LDKPeerManager this_obj_conv;
22538         this_obj_conv.inner = (void*)(this_obj & (~1));
22539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22540         PeerManager_free(this_obj_conv);
22541 }
22542
22543 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) {
22544         LDKMessageHandler message_handler_conv;
22545         message_handler_conv.inner = (void*)(message_handler & (~1));
22546         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
22547         // Warning: we need a move here but no clone is available for LDKMessageHandler
22548         LDKSecretKey our_node_secret_ref;
22549         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
22550         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
22551         unsigned char ephemeral_random_data_arr[32];
22552         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
22553         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
22554         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
22555         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22556         if (logger_conv.free == LDKLogger_JCalls_free) {
22557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22558                 LDKLogger_JCalls_cloned(&logger_conv);
22559         }
22560         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
22561         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22562         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22563         uint64_t ret_ref = (uint64_t)ret_var.inner;
22564         if (ret_var.is_owned) {
22565                 ret_ref |= 1;
22566         }
22567         return ret_ref;
22568 }
22569
22570 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
22571         LDKPeerManager this_arg_conv;
22572         this_arg_conv.inner = (void*)(this_arg & (~1));
22573         this_arg_conv.is_owned = false;
22574         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
22575         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22576         ;
22577         for (size_t i = 0; i < ret_var.datalen; i++) {
22578                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
22579                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
22580                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22581         }
22582         FREE(ret_var.data);
22583         return ret_arr;
22584 }
22585
22586 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) {
22587         LDKPeerManager this_arg_conv;
22588         this_arg_conv.inner = (void*)(this_arg & (~1));
22589         this_arg_conv.is_owned = false;
22590         LDKPublicKey their_node_id_ref;
22591         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
22592         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
22593         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22594         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22595                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22596                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22597         }
22598         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22599         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
22600         return (uint64_t)ret_conv;
22601 }
22602
22603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22604         LDKPeerManager this_arg_conv;
22605         this_arg_conv.inner = (void*)(this_arg & (~1));
22606         this_arg_conv.is_owned = false;
22607         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22608         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22609                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22610                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22611         }
22612         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22613         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
22614         return (uint64_t)ret_conv;
22615 }
22616
22617 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) {
22618         LDKPeerManager this_arg_conv;
22619         this_arg_conv.inner = (void*)(this_arg & (~1));
22620         this_arg_conv.is_owned = false;
22621         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22622         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22623         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
22624         return (uint64_t)ret_conv;
22625 }
22626
22627 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) {
22628         LDKPeerManager this_arg_conv;
22629         this_arg_conv.inner = (void*)(this_arg & (~1));
22630         this_arg_conv.is_owned = false;
22631         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
22632         LDKu8slice data_ref;
22633         data_ref.datalen = (*env)->GetArrayLength(env, data);
22634         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
22635         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22636         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
22637         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
22638         return (uint64_t)ret_conv;
22639 }
22640
22641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22642         LDKPeerManager this_arg_conv;
22643         this_arg_conv.inner = (void*)(this_arg & (~1));
22644         this_arg_conv.is_owned = false;
22645         PeerManager_process_events(&this_arg_conv);
22646 }
22647
22648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22649         LDKPeerManager this_arg_conv;
22650         this_arg_conv.inner = (void*)(this_arg & (~1));
22651         this_arg_conv.is_owned = false;
22652         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22653         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
22654 }
22655
22656 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) {
22657         LDKPeerManager this_arg_conv;
22658         this_arg_conv.inner = (void*)(this_arg & (~1));
22659         this_arg_conv.is_owned = false;
22660         LDKPublicKey node_id_ref;
22661         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22662         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22663         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
22664 }
22665
22666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
22667         LDKPeerManager this_arg_conv;
22668         this_arg_conv.inner = (void*)(this_arg & (~1));
22669         this_arg_conv.is_owned = false;
22670         PeerManager_timer_tick_occurred(&this_arg_conv);
22671 }
22672
22673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
22674         unsigned char commitment_seed_arr[32];
22675         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
22676         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
22677         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
22678         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22679         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
22680         return ret_arr;
22681 }
22682
22683 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) {
22684         LDKPublicKey per_commitment_point_ref;
22685         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22686         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22687         unsigned char base_secret_arr[32];
22688         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
22689         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
22690         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
22691         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22692         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
22693         return (uint64_t)ret_conv;
22694 }
22695
22696 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) {
22697         LDKPublicKey per_commitment_point_ref;
22698         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22699         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22700         LDKPublicKey base_point_ref;
22701         CHECK((*env)->GetArrayLength(env, base_point) == 33);
22702         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
22703         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22704         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
22705         return (uint64_t)ret_conv;
22706 }
22707
22708 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) {
22709         unsigned char per_commitment_secret_arr[32];
22710         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
22711         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
22712         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
22713         unsigned char countersignatory_revocation_base_secret_arr[32];
22714         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
22715         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
22716         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
22717         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22718         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
22719         return (uint64_t)ret_conv;
22720 }
22721
22722 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) {
22723         LDKPublicKey per_commitment_point_ref;
22724         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22725         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22726         LDKPublicKey countersignatory_revocation_base_point_ref;
22727         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
22728         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
22729         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22730         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
22731         return (uint64_t)ret_conv;
22732 }
22733
22734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22735         LDKTxCreationKeys this_obj_conv;
22736         this_obj_conv.inner = (void*)(this_obj & (~1));
22737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22738         TxCreationKeys_free(this_obj_conv);
22739 }
22740
22741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22742         LDKTxCreationKeys this_ptr_conv;
22743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22744         this_ptr_conv.is_owned = false;
22745         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
22747         return ret_arr;
22748 }
22749
22750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22751         LDKTxCreationKeys this_ptr_conv;
22752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22753         this_ptr_conv.is_owned = false;
22754         LDKPublicKey val_ref;
22755         CHECK((*env)->GetArrayLength(env, val) == 33);
22756         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22757         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
22758 }
22759
22760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22761         LDKTxCreationKeys this_ptr_conv;
22762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22763         this_ptr_conv.is_owned = false;
22764         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
22766         return ret_arr;
22767 }
22768
22769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22770         LDKTxCreationKeys this_ptr_conv;
22771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22772         this_ptr_conv.is_owned = false;
22773         LDKPublicKey val_ref;
22774         CHECK((*env)->GetArrayLength(env, val) == 33);
22775         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22776         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
22777 }
22778
22779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22780         LDKTxCreationKeys this_ptr_conv;
22781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22782         this_ptr_conv.is_owned = false;
22783         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
22785         return ret_arr;
22786 }
22787
22788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22789         LDKTxCreationKeys this_ptr_conv;
22790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22791         this_ptr_conv.is_owned = false;
22792         LDKPublicKey val_ref;
22793         CHECK((*env)->GetArrayLength(env, val) == 33);
22794         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22795         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
22796 }
22797
22798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22799         LDKTxCreationKeys this_ptr_conv;
22800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22801         this_ptr_conv.is_owned = false;
22802         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22803         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
22804         return ret_arr;
22805 }
22806
22807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22808         LDKTxCreationKeys this_ptr_conv;
22809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22810         this_ptr_conv.is_owned = false;
22811         LDKPublicKey val_ref;
22812         CHECK((*env)->GetArrayLength(env, val) == 33);
22813         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22814         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
22815 }
22816
22817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22818         LDKTxCreationKeys this_ptr_conv;
22819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22820         this_ptr_conv.is_owned = false;
22821         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
22823         return ret_arr;
22824 }
22825
22826 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) {
22827         LDKTxCreationKeys this_ptr_conv;
22828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22829         this_ptr_conv.is_owned = false;
22830         LDKPublicKey val_ref;
22831         CHECK((*env)->GetArrayLength(env, val) == 33);
22832         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22833         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
22834 }
22835
22836 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) {
22837         LDKPublicKey per_commitment_point_arg_ref;
22838         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
22839         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
22840         LDKPublicKey revocation_key_arg_ref;
22841         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
22842         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
22843         LDKPublicKey broadcaster_htlc_key_arg_ref;
22844         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
22845         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
22846         LDKPublicKey countersignatory_htlc_key_arg_ref;
22847         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
22848         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
22849         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
22850         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
22851         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
22852         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);
22853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22855         uint64_t ret_ref = (uint64_t)ret_var.inner;
22856         if (ret_var.is_owned) {
22857                 ret_ref |= 1;
22858         }
22859         return ret_ref;
22860 }
22861
22862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22863         LDKTxCreationKeys orig_conv;
22864         orig_conv.inner = (void*)(orig & (~1));
22865         orig_conv.is_owned = false;
22866         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
22867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22869         uint64_t ret_ref = (uint64_t)ret_var.inner;
22870         if (ret_var.is_owned) {
22871                 ret_ref |= 1;
22872         }
22873         return ret_ref;
22874 }
22875
22876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22877         LDKTxCreationKeys obj_conv;
22878         obj_conv.inner = (void*)(obj & (~1));
22879         obj_conv.is_owned = false;
22880         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
22881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22883         CVec_u8Z_free(ret_var);
22884         return ret_arr;
22885 }
22886
22887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22888         LDKu8slice ser_ref;
22889         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22890         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22891         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
22892         *ret_conv = TxCreationKeys_read(ser_ref);
22893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22894         return (uint64_t)ret_conv;
22895 }
22896
22897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22898         LDKChannelPublicKeys this_obj_conv;
22899         this_obj_conv.inner = (void*)(this_obj & (~1));
22900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22901         ChannelPublicKeys_free(this_obj_conv);
22902 }
22903
22904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22905         LDKChannelPublicKeys this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
22910         return ret_arr;
22911 }
22912
22913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22914         LDKChannelPublicKeys this_ptr_conv;
22915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22916         this_ptr_conv.is_owned = false;
22917         LDKPublicKey val_ref;
22918         CHECK((*env)->GetArrayLength(env, val) == 33);
22919         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22920         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
22921 }
22922
22923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22924         LDKChannelPublicKeys this_ptr_conv;
22925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22926         this_ptr_conv.is_owned = false;
22927         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22928         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
22929         return ret_arr;
22930 }
22931
22932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22933         LDKChannelPublicKeys this_ptr_conv;
22934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22935         this_ptr_conv.is_owned = false;
22936         LDKPublicKey val_ref;
22937         CHECK((*env)->GetArrayLength(env, val) == 33);
22938         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22939         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
22940 }
22941
22942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22943         LDKChannelPublicKeys this_ptr_conv;
22944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22945         this_ptr_conv.is_owned = false;
22946         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
22948         return ret_arr;
22949 }
22950
22951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22952         LDKChannelPublicKeys this_ptr_conv;
22953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22954         this_ptr_conv.is_owned = false;
22955         LDKPublicKey val_ref;
22956         CHECK((*env)->GetArrayLength(env, val) == 33);
22957         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22958         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
22959 }
22960
22961 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22962         LDKChannelPublicKeys this_ptr_conv;
22963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22964         this_ptr_conv.is_owned = false;
22965         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22966         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22967         return ret_arr;
22968 }
22969
22970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22971         LDKChannelPublicKeys this_ptr_conv;
22972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22973         this_ptr_conv.is_owned = false;
22974         LDKPublicKey val_ref;
22975         CHECK((*env)->GetArrayLength(env, val) == 33);
22976         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22977         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22978 }
22979
22980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22981         LDKChannelPublicKeys this_ptr_conv;
22982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22983         this_ptr_conv.is_owned = false;
22984         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22986         return ret_arr;
22987 }
22988
22989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22990         LDKChannelPublicKeys this_ptr_conv;
22991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22992         this_ptr_conv.is_owned = false;
22993         LDKPublicKey val_ref;
22994         CHECK((*env)->GetArrayLength(env, val) == 33);
22995         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22996         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22997 }
22998
22999 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) {
23000         LDKPublicKey funding_pubkey_arg_ref;
23001         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
23002         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
23003         LDKPublicKey revocation_basepoint_arg_ref;
23004         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
23005         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
23006         LDKPublicKey payment_point_arg_ref;
23007         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
23008         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
23009         LDKPublicKey delayed_payment_basepoint_arg_ref;
23010         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
23011         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
23012         LDKPublicKey htlc_basepoint_arg_ref;
23013         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
23014         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
23015         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);
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 int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23026         LDKChannelPublicKeys orig_conv;
23027         orig_conv.inner = (void*)(orig & (~1));
23028         orig_conv.is_owned = false;
23029         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
23030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23032         uint64_t ret_ref = (uint64_t)ret_var.inner;
23033         if (ret_var.is_owned) {
23034                 ret_ref |= 1;
23035         }
23036         return ret_ref;
23037 }
23038
23039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
23040         LDKChannelPublicKeys obj_conv;
23041         obj_conv.inner = (void*)(obj & (~1));
23042         obj_conv.is_owned = false;
23043         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
23044         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23045         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23046         CVec_u8Z_free(ret_var);
23047         return ret_arr;
23048 }
23049
23050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23051         LDKu8slice ser_ref;
23052         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23053         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23054         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
23055         *ret_conv = ChannelPublicKeys_read(ser_ref);
23056         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23057         return (uint64_t)ret_conv;
23058 }
23059
23060 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) {
23061         LDKPublicKey per_commitment_point_ref;
23062         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
23063         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
23064         LDKPublicKey broadcaster_delayed_payment_base_ref;
23065         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
23066         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
23067         LDKPublicKey broadcaster_htlc_base_ref;
23068         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
23069         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
23070         LDKPublicKey countersignatory_revocation_base_ref;
23071         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
23072         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
23073         LDKPublicKey countersignatory_htlc_base_ref;
23074         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
23075         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
23076         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
23077         *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);
23078         return (uint64_t)ret_conv;
23079 }
23080
23081 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) {
23082         LDKPublicKey per_commitment_point_ref;
23083         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
23084         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
23085         LDKChannelPublicKeys broadcaster_keys_conv;
23086         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23087         broadcaster_keys_conv.is_owned = false;
23088         LDKChannelPublicKeys countersignatory_keys_conv;
23089         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23090         countersignatory_keys_conv.is_owned = false;
23091         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
23092         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
23093         return (uint64_t)ret_conv;
23094 }
23095
23096 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) {
23097         LDKPublicKey revocation_key_ref;
23098         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
23099         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
23100         LDKPublicKey broadcaster_delayed_payment_key_ref;
23101         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
23102         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
23103         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
23104         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23105         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23106         CVec_u8Z_free(ret_var);
23107         return ret_arr;
23108 }
23109
23110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23111         LDKHTLCOutputInCommitment this_obj_conv;
23112         this_obj_conv.inner = (void*)(this_obj & (~1));
23113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23114         HTLCOutputInCommitment_free(this_obj_conv);
23115 }
23116
23117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
23118         LDKHTLCOutputInCommitment this_ptr_conv;
23119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23120         this_ptr_conv.is_owned = false;
23121         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
23122         return ret_val;
23123 }
23124
23125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23126         LDKHTLCOutputInCommitment this_ptr_conv;
23127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23128         this_ptr_conv.is_owned = false;
23129         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
23130 }
23131
23132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23133         LDKHTLCOutputInCommitment this_ptr_conv;
23134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23135         this_ptr_conv.is_owned = false;
23136         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
23137         return ret_val;
23138 }
23139
23140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23141         LDKHTLCOutputInCommitment this_ptr_conv;
23142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23143         this_ptr_conv.is_owned = false;
23144         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
23145 }
23146
23147 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
23148         LDKHTLCOutputInCommitment this_ptr_conv;
23149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23150         this_ptr_conv.is_owned = false;
23151         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
23152         return ret_val;
23153 }
23154
23155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23156         LDKHTLCOutputInCommitment this_ptr_conv;
23157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23158         this_ptr_conv.is_owned = false;
23159         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
23160 }
23161
23162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23163         LDKHTLCOutputInCommitment this_ptr_conv;
23164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23165         this_ptr_conv.is_owned = false;
23166         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23167         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
23168         return ret_arr;
23169 }
23170
23171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23172         LDKHTLCOutputInCommitment this_ptr_conv;
23173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23174         this_ptr_conv.is_owned = false;
23175         LDKThirtyTwoBytes val_ref;
23176         CHECK((*env)->GetArrayLength(env, val) == 32);
23177         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23178         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
23179 }
23180
23181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
23182         LDKHTLCOutputInCommitment this_ptr_conv;
23183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23184         this_ptr_conv.is_owned = false;
23185         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
23186         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
23187         uint64_t ret_ref = (uint64_t)ret_copy;
23188         return ret_ref;
23189 }
23190
23191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23192         LDKHTLCOutputInCommitment this_ptr_conv;
23193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23194         this_ptr_conv.is_owned = false;
23195         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
23196         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
23197 }
23198
23199 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) {
23200         LDKThirtyTwoBytes payment_hash_arg_ref;
23201         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
23202         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
23203         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
23204         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
23205         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23206         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23207         uint64_t ret_ref = (uint64_t)ret_var.inner;
23208         if (ret_var.is_owned) {
23209                 ret_ref |= 1;
23210         }
23211         return ret_ref;
23212 }
23213
23214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23215         LDKHTLCOutputInCommitment orig_conv;
23216         orig_conv.inner = (void*)(orig & (~1));
23217         orig_conv.is_owned = false;
23218         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
23219         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23220         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23221         uint64_t ret_ref = (uint64_t)ret_var.inner;
23222         if (ret_var.is_owned) {
23223                 ret_ref |= 1;
23224         }
23225         return ret_ref;
23226 }
23227
23228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
23229         LDKHTLCOutputInCommitment obj_conv;
23230         obj_conv.inner = (void*)(obj & (~1));
23231         obj_conv.is_owned = false;
23232         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
23233         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23234         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23235         CVec_u8Z_free(ret_var);
23236         return ret_arr;
23237 }
23238
23239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23240         LDKu8slice ser_ref;
23241         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23242         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23243         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
23244         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
23245         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23246         return (uint64_t)ret_conv;
23247 }
23248
23249 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
23250         LDKHTLCOutputInCommitment htlc_conv;
23251         htlc_conv.inner = (void*)(htlc & (~1));
23252         htlc_conv.is_owned = false;
23253         LDKTxCreationKeys keys_conv;
23254         keys_conv.inner = (void*)(keys & (~1));
23255         keys_conv.is_owned = false;
23256         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
23257         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23258         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23259         CVec_u8Z_free(ret_var);
23260         return ret_arr;
23261 }
23262
23263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
23264         LDKPublicKey broadcaster_ref;
23265         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
23266         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
23267         LDKPublicKey countersignatory_ref;
23268         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
23269         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
23270         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
23271         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23272         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23273         CVec_u8Z_free(ret_var);
23274         return ret_arr;
23275 }
23276
23277 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) {
23278         unsigned char commitment_txid_arr[32];
23279         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
23280         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
23281         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
23282         LDKHTLCOutputInCommitment htlc_conv;
23283         htlc_conv.inner = (void*)(htlc & (~1));
23284         htlc_conv.is_owned = false;
23285         LDKPublicKey broadcaster_delayed_payment_key_ref;
23286         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
23287         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
23288         LDKPublicKey revocation_key_ref;
23289         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
23290         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
23291         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
23292         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23293         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23294         Transaction_free(ret_var);
23295         return ret_arr;
23296 }
23297
23298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23299         LDKChannelTransactionParameters this_obj_conv;
23300         this_obj_conv.inner = (void*)(this_obj & (~1));
23301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23302         ChannelTransactionParameters_free(this_obj_conv);
23303 }
23304
23305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
23306         LDKChannelTransactionParameters this_ptr_conv;
23307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23308         this_ptr_conv.is_owned = false;
23309         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
23310         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23311         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23312         uint64_t ret_ref = (uint64_t)ret_var.inner;
23313         if (ret_var.is_owned) {
23314                 ret_ref |= 1;
23315         }
23316         return ret_ref;
23317 }
23318
23319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23320         LDKChannelTransactionParameters this_ptr_conv;
23321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23322         this_ptr_conv.is_owned = false;
23323         LDKChannelPublicKeys val_conv;
23324         val_conv.inner = (void*)(val & (~1));
23325         val_conv.is_owned = (val & 1) || (val == 0);
23326         val_conv = ChannelPublicKeys_clone(&val_conv);
23327         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
23328 }
23329
23330 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23331         LDKChannelTransactionParameters this_ptr_conv;
23332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23333         this_ptr_conv.is_owned = false;
23334         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
23335         return ret_val;
23336 }
23337
23338 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) {
23339         LDKChannelTransactionParameters this_ptr_conv;
23340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23341         this_ptr_conv.is_owned = false;
23342         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
23343 }
23344
23345 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
23346         LDKChannelTransactionParameters this_ptr_conv;
23347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23348         this_ptr_conv.is_owned = false;
23349         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
23350         return ret_val;
23351 }
23352
23353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23354         LDKChannelTransactionParameters this_ptr_conv;
23355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23356         this_ptr_conv.is_owned = false;
23357         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
23358 }
23359
23360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
23361         LDKChannelTransactionParameters this_ptr_conv;
23362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23363         this_ptr_conv.is_owned = false;
23364         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
23365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23367         uint64_t ret_ref = (uint64_t)ret_var.inner;
23368         if (ret_var.is_owned) {
23369                 ret_ref |= 1;
23370         }
23371         return ret_ref;
23372 }
23373
23374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23375         LDKChannelTransactionParameters this_ptr_conv;
23376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23377         this_ptr_conv.is_owned = false;
23378         LDKCounterpartyChannelTransactionParameters val_conv;
23379         val_conv.inner = (void*)(val & (~1));
23380         val_conv.is_owned = (val & 1) || (val == 0);
23381         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
23382         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
23383 }
23384
23385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
23386         LDKChannelTransactionParameters this_ptr_conv;
23387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23388         this_ptr_conv.is_owned = false;
23389         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
23390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23392         uint64_t ret_ref = (uint64_t)ret_var.inner;
23393         if (ret_var.is_owned) {
23394                 ret_ref |= 1;
23395         }
23396         return ret_ref;
23397 }
23398
23399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23400         LDKChannelTransactionParameters this_ptr_conv;
23401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23402         this_ptr_conv.is_owned = false;
23403         LDKOutPoint val_conv;
23404         val_conv.inner = (void*)(val & (~1));
23405         val_conv.is_owned = (val & 1) || (val == 0);
23406         val_conv = OutPoint_clone(&val_conv);
23407         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
23408 }
23409
23410 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) {
23411         LDKChannelPublicKeys holder_pubkeys_arg_conv;
23412         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
23413         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
23414         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
23415         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
23416         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
23417         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
23418         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
23419         LDKOutPoint funding_outpoint_arg_conv;
23420         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
23421         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
23422         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
23423         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);
23424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23426         uint64_t ret_ref = (uint64_t)ret_var.inner;
23427         if (ret_var.is_owned) {
23428                 ret_ref |= 1;
23429         }
23430         return ret_ref;
23431 }
23432
23433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23434         LDKChannelTransactionParameters orig_conv;
23435         orig_conv.inner = (void*)(orig & (~1));
23436         orig_conv.is_owned = false;
23437         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_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_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23448         LDKCounterpartyChannelTransactionParameters this_obj_conv;
23449         this_obj_conv.inner = (void*)(this_obj & (~1));
23450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23451         CounterpartyChannelTransactionParameters_free(this_obj_conv);
23452 }
23453
23454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
23455         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23457         this_ptr_conv.is_owned = false;
23458         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
23459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23461         uint64_t ret_ref = (uint64_t)ret_var.inner;
23462         if (ret_var.is_owned) {
23463                 ret_ref |= 1;
23464         }
23465         return ret_ref;
23466 }
23467
23468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23469         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23471         this_ptr_conv.is_owned = false;
23472         LDKChannelPublicKeys val_conv;
23473         val_conv.inner = (void*)(val & (~1));
23474         val_conv.is_owned = (val & 1) || (val == 0);
23475         val_conv = ChannelPublicKeys_clone(&val_conv);
23476         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
23477 }
23478
23479 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23480         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23482         this_ptr_conv.is_owned = false;
23483         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
23484         return ret_val;
23485 }
23486
23487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23488         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
23489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23490         this_ptr_conv.is_owned = false;
23491         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
23492 }
23493
23494 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) {
23495         LDKChannelPublicKeys pubkeys_arg_conv;
23496         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
23497         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
23498         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
23499         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
23500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23502         uint64_t ret_ref = (uint64_t)ret_var.inner;
23503         if (ret_var.is_owned) {
23504                 ret_ref |= 1;
23505         }
23506         return ret_ref;
23507 }
23508
23509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23510         LDKCounterpartyChannelTransactionParameters orig_conv;
23511         orig_conv.inner = (void*)(orig & (~1));
23512         orig_conv.is_owned = false;
23513         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
23514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23516         uint64_t ret_ref = (uint64_t)ret_var.inner;
23517         if (ret_var.is_owned) {
23518                 ret_ref |= 1;
23519         }
23520         return ret_ref;
23521 }
23522
23523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
23524         LDKChannelTransactionParameters this_arg_conv;
23525         this_arg_conv.inner = (void*)(this_arg & (~1));
23526         this_arg_conv.is_owned = false;
23527         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
23528         return ret_val;
23529 }
23530
23531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23532         LDKChannelTransactionParameters this_arg_conv;
23533         this_arg_conv.inner = (void*)(this_arg & (~1));
23534         this_arg_conv.is_owned = false;
23535         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
23536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23538         uint64_t ret_ref = (uint64_t)ret_var.inner;
23539         if (ret_var.is_owned) {
23540                 ret_ref |= 1;
23541         }
23542         return ret_ref;
23543 }
23544
23545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23546         LDKChannelTransactionParameters this_arg_conv;
23547         this_arg_conv.inner = (void*)(this_arg & (~1));
23548         this_arg_conv.is_owned = false;
23549         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23560         LDKCounterpartyChannelTransactionParameters obj_conv;
23561         obj_conv.inner = (void*)(obj & (~1));
23562         obj_conv.is_owned = false;
23563         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
23564         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23565         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23566         CVec_u8Z_free(ret_var);
23567         return ret_arr;
23568 }
23569
23570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23571         LDKu8slice ser_ref;
23572         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23573         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23574         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
23575         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
23576         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23577         return (uint64_t)ret_conv;
23578 }
23579
23580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23581         LDKChannelTransactionParameters obj_conv;
23582         obj_conv.inner = (void*)(obj & (~1));
23583         obj_conv.is_owned = false;
23584         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
23585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23587         CVec_u8Z_free(ret_var);
23588         return ret_arr;
23589 }
23590
23591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23592         LDKu8slice ser_ref;
23593         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23594         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23595         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
23596         *ret_conv = ChannelTransactionParameters_read(ser_ref);
23597         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23598         return (uint64_t)ret_conv;
23599 }
23600
23601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23602         LDKDirectedChannelTransactionParameters this_obj_conv;
23603         this_obj_conv.inner = (void*)(this_obj & (~1));
23604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23605         DirectedChannelTransactionParameters_free(this_obj_conv);
23606 }
23607
23608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23609         LDKDirectedChannelTransactionParameters this_arg_conv;
23610         this_arg_conv.inner = (void*)(this_arg & (~1));
23611         this_arg_conv.is_owned = false;
23612         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
23613         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23614         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23615         uint64_t ret_ref = (uint64_t)ret_var.inner;
23616         if (ret_var.is_owned) {
23617                 ret_ref |= 1;
23618         }
23619         return ret_ref;
23620 }
23621
23622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23623         LDKDirectedChannelTransactionParameters this_arg_conv;
23624         this_arg_conv.inner = (void*)(this_arg & (~1));
23625         this_arg_conv.is_owned = false;
23626         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
23627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23629         uint64_t ret_ref = (uint64_t)ret_var.inner;
23630         if (ret_var.is_owned) {
23631                 ret_ref |= 1;
23632         }
23633         return ret_ref;
23634 }
23635
23636 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23637         LDKDirectedChannelTransactionParameters this_arg_conv;
23638         this_arg_conv.inner = (void*)(this_arg & (~1));
23639         this_arg_conv.is_owned = false;
23640         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
23641         return ret_val;
23642 }
23643
23644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
23645         LDKDirectedChannelTransactionParameters this_arg_conv;
23646         this_arg_conv.inner = (void*)(this_arg & (~1));
23647         this_arg_conv.is_owned = false;
23648         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
23649         return ret_val;
23650 }
23651
23652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
23653         LDKDirectedChannelTransactionParameters this_arg_conv;
23654         this_arg_conv.inner = (void*)(this_arg & (~1));
23655         this_arg_conv.is_owned = false;
23656         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
23657         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23658         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23659         uint64_t ret_ref = (uint64_t)ret_var.inner;
23660         if (ret_var.is_owned) {
23661                 ret_ref |= 1;
23662         }
23663         return ret_ref;
23664 }
23665
23666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23667         LDKHolderCommitmentTransaction this_obj_conv;
23668         this_obj_conv.inner = (void*)(this_obj & (~1));
23669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23670         HolderCommitmentTransaction_free(this_obj_conv);
23671 }
23672
23673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
23674         LDKHolderCommitmentTransaction this_ptr_conv;
23675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23676         this_ptr_conv.is_owned = false;
23677         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23678         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
23679         return ret_arr;
23680 }
23681
23682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23683         LDKHolderCommitmentTransaction this_ptr_conv;
23684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23685         this_ptr_conv.is_owned = false;
23686         LDKSignature val_ref;
23687         CHECK((*env)->GetArrayLength(env, val) == 64);
23688         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23689         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
23690 }
23691
23692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23693         LDKHolderCommitmentTransaction this_ptr_conv;
23694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23695         this_ptr_conv.is_owned = false;
23696         LDKCVec_SignatureZ val_constr;
23697         val_constr.datalen = (*env)->GetArrayLength(env, val);
23698         if (val_constr.datalen > 0)
23699                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23700         else
23701                 val_constr.data = NULL;
23702         for (size_t i = 0; i < val_constr.datalen; i++) {
23703                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
23704                 LDKSignature val_conv_8_ref;
23705                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
23706                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
23707                 val_constr.data[i] = val_conv_8_ref;
23708         }
23709         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
23710 }
23711
23712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23713         LDKHolderCommitmentTransaction orig_conv;
23714         orig_conv.inner = (void*)(orig & (~1));
23715         orig_conv.is_owned = false;
23716         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
23717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23719         uint64_t ret_ref = (uint64_t)ret_var.inner;
23720         if (ret_var.is_owned) {
23721                 ret_ref |= 1;
23722         }
23723         return ret_ref;
23724 }
23725
23726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23727         LDKHolderCommitmentTransaction obj_conv;
23728         obj_conv.inner = (void*)(obj & (~1));
23729         obj_conv.is_owned = false;
23730         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
23731         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23732         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23733         CVec_u8Z_free(ret_var);
23734         return ret_arr;
23735 }
23736
23737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23738         LDKu8slice ser_ref;
23739         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23740         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23741         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
23742         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
23743         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23744         return (uint64_t)ret_conv;
23745 }
23746
23747 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) {
23748         LDKCommitmentTransaction commitment_tx_conv;
23749         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
23750         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
23751         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
23752         LDKSignature counterparty_sig_ref;
23753         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
23754         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
23755         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
23756         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
23757         if (counterparty_htlc_sigs_constr.datalen > 0)
23758                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23759         else
23760                 counterparty_htlc_sigs_constr.data = NULL;
23761         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
23762                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
23763                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
23764                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
23765                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
23766                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
23767         }
23768         LDKPublicKey holder_funding_key_ref;
23769         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
23770         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
23771         LDKPublicKey counterparty_funding_key_ref;
23772         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
23773         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
23774         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
23775         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23776         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23777         uint64_t ret_ref = (uint64_t)ret_var.inner;
23778         if (ret_var.is_owned) {
23779                 ret_ref |= 1;
23780         }
23781         return ret_ref;
23782 }
23783
23784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23785         LDKBuiltCommitmentTransaction this_obj_conv;
23786         this_obj_conv.inner = (void*)(this_obj & (~1));
23787         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23788         BuiltCommitmentTransaction_free(this_obj_conv);
23789 }
23790
23791 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
23792         LDKBuiltCommitmentTransaction this_ptr_conv;
23793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23794         this_ptr_conv.is_owned = false;
23795         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
23796         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23797         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23798         Transaction_free(ret_var);
23799         return ret_arr;
23800 }
23801
23802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23803         LDKBuiltCommitmentTransaction this_ptr_conv;
23804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23805         this_ptr_conv.is_owned = false;
23806         LDKTransaction val_ref;
23807         val_ref.datalen = (*env)->GetArrayLength(env, val);
23808         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
23809         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
23810         val_ref.data_is_owned = true;
23811         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
23812 }
23813
23814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
23815         LDKBuiltCommitmentTransaction this_ptr_conv;
23816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23817         this_ptr_conv.is_owned = false;
23818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
23820         return ret_arr;
23821 }
23822
23823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23824         LDKBuiltCommitmentTransaction this_ptr_conv;
23825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23826         this_ptr_conv.is_owned = false;
23827         LDKThirtyTwoBytes val_ref;
23828         CHECK((*env)->GetArrayLength(env, val) == 32);
23829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23830         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
23831 }
23832
23833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
23834         LDKTransaction transaction_arg_ref;
23835         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
23836         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
23837         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
23838         transaction_arg_ref.data_is_owned = true;
23839         LDKThirtyTwoBytes txid_arg_ref;
23840         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
23841         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
23842         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
23843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23845         uint64_t ret_ref = (uint64_t)ret_var.inner;
23846         if (ret_var.is_owned) {
23847                 ret_ref |= 1;
23848         }
23849         return ret_ref;
23850 }
23851
23852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23853         LDKBuiltCommitmentTransaction orig_conv;
23854         orig_conv.inner = (void*)(orig & (~1));
23855         orig_conv.is_owned = false;
23856         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
23857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23859         uint64_t ret_ref = (uint64_t)ret_var.inner;
23860         if (ret_var.is_owned) {
23861                 ret_ref |= 1;
23862         }
23863         return ret_ref;
23864 }
23865
23866 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23867         LDKBuiltCommitmentTransaction obj_conv;
23868         obj_conv.inner = (void*)(obj & (~1));
23869         obj_conv.is_owned = false;
23870         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
23871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23873         CVec_u8Z_free(ret_var);
23874         return ret_arr;
23875 }
23876
23877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23878         LDKu8slice ser_ref;
23879         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23880         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23881         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
23882         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
23883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23884         return (uint64_t)ret_conv;
23885 }
23886
23887 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) {
23888         LDKBuiltCommitmentTransaction this_arg_conv;
23889         this_arg_conv.inner = (void*)(this_arg & (~1));
23890         this_arg_conv.is_owned = false;
23891         LDKu8slice funding_redeemscript_ref;
23892         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23893         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23894         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23895         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
23896         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23897         return ret_arr;
23898 }
23899
23900 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) {
23901         LDKBuiltCommitmentTransaction this_arg_conv;
23902         this_arg_conv.inner = (void*)(this_arg & (~1));
23903         this_arg_conv.is_owned = false;
23904         unsigned char funding_key_arr[32];
23905         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
23906         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
23907         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
23908         LDKu8slice funding_redeemscript_ref;
23909         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23910         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23911         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
23913         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23914         return ret_arr;
23915 }
23916
23917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23918         LDKCommitmentTransaction this_obj_conv;
23919         this_obj_conv.inner = (void*)(this_obj & (~1));
23920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23921         CommitmentTransaction_free(this_obj_conv);
23922 }
23923
23924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23925         LDKCommitmentTransaction orig_conv;
23926         orig_conv.inner = (void*)(orig & (~1));
23927         orig_conv.is_owned = false;
23928         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
23929         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23930         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23931         uint64_t ret_ref = (uint64_t)ret_var.inner;
23932         if (ret_var.is_owned) {
23933                 ret_ref |= 1;
23934         }
23935         return ret_ref;
23936 }
23937
23938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23939         LDKCommitmentTransaction obj_conv;
23940         obj_conv.inner = (void*)(obj & (~1));
23941         obj_conv.is_owned = false;
23942         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
23943         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23944         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23945         CVec_u8Z_free(ret_var);
23946         return ret_arr;
23947 }
23948
23949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23950         LDKu8slice ser_ref;
23951         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23952         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23953         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
23954         *ret_conv = CommitmentTransaction_read(ser_ref);
23955         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23956         return (uint64_t)ret_conv;
23957 }
23958
23959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
23960         LDKCommitmentTransaction this_arg_conv;
23961         this_arg_conv.inner = (void*)(this_arg & (~1));
23962         this_arg_conv.is_owned = false;
23963         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23964         return ret_val;
23965 }
23966
23967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23968         LDKCommitmentTransaction this_arg_conv;
23969         this_arg_conv.inner = (void*)(this_arg & (~1));
23970         this_arg_conv.is_owned = false;
23971         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23972         return ret_val;
23973 }
23974
23975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23976         LDKCommitmentTransaction this_arg_conv;
23977         this_arg_conv.inner = (void*)(this_arg & (~1));
23978         this_arg_conv.is_owned = false;
23979         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23980         return ret_val;
23981 }
23982
23983 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
23984         LDKCommitmentTransaction this_arg_conv;
23985         this_arg_conv.inner = (void*)(this_arg & (~1));
23986         this_arg_conv.is_owned = false;
23987         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23988         return ret_val;
23989 }
23990
23991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
23992         LDKCommitmentTransaction this_arg_conv;
23993         this_arg_conv.inner = (void*)(this_arg & (~1));
23994         this_arg_conv.is_owned = false;
23995         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23998         uint64_t ret_ref = (uint64_t)ret_var.inner;
23999         if (ret_var.is_owned) {
24000                 ret_ref |= 1;
24001         }
24002         return ret_ref;
24003 }
24004
24005 JNIEXPORT 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) {
24006         LDKCommitmentTransaction this_arg_conv;
24007         this_arg_conv.inner = (void*)(this_arg & (~1));
24008         this_arg_conv.is_owned = false;
24009         LDKDirectedChannelTransactionParameters channel_parameters_conv;
24010         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
24011         channel_parameters_conv.is_owned = false;
24012         LDKChannelPublicKeys broadcaster_keys_conv;
24013         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
24014         broadcaster_keys_conv.is_owned = false;
24015         LDKChannelPublicKeys countersignatory_keys_conv;
24016         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
24017         countersignatory_keys_conv.is_owned = false;
24018         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
24019         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
24020         return (uint64_t)ret_conv;
24021 }
24022
24023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24024         LDKTrustedCommitmentTransaction this_obj_conv;
24025         this_obj_conv.inner = (void*)(this_obj & (~1));
24026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24027         TrustedCommitmentTransaction_free(this_obj_conv);
24028 }
24029
24030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
24031         LDKTrustedCommitmentTransaction this_arg_conv;
24032         this_arg_conv.inner = (void*)(this_arg & (~1));
24033         this_arg_conv.is_owned = false;
24034         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
24036         return ret_arr;
24037 }
24038
24039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
24040         LDKTrustedCommitmentTransaction this_arg_conv;
24041         this_arg_conv.inner = (void*)(this_arg & (~1));
24042         this_arg_conv.is_owned = false;
24043         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
24044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24046         uint64_t ret_ref = (uint64_t)ret_var.inner;
24047         if (ret_var.is_owned) {
24048                 ret_ref |= 1;
24049         }
24050         return ret_ref;
24051 }
24052
24053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
24054         LDKTrustedCommitmentTransaction this_arg_conv;
24055         this_arg_conv.inner = (void*)(this_arg & (~1));
24056         this_arg_conv.is_owned = false;
24057         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
24058         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24059         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24060         uint64_t ret_ref = (uint64_t)ret_var.inner;
24061         if (ret_var.is_owned) {
24062                 ret_ref |= 1;
24063         }
24064         return ret_ref;
24065 }
24066
24067 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) {
24068         LDKTrustedCommitmentTransaction this_arg_conv;
24069         this_arg_conv.inner = (void*)(this_arg & (~1));
24070         this_arg_conv.is_owned = false;
24071         unsigned char htlc_base_key_arr[32];
24072         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
24073         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
24074         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
24075         LDKDirectedChannelTransactionParameters channel_parameters_conv;
24076         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
24077         channel_parameters_conv.is_owned = false;
24078         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
24079         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
24080         return (uint64_t)ret_conv;
24081 }
24082
24083 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) {
24084         LDKPublicKey broadcaster_payment_basepoint_ref;
24085         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
24086         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
24087         LDKPublicKey countersignatory_payment_basepoint_ref;
24088         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
24089         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
24090         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
24091         return ret_val;
24092 }
24093
24094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24095         LDKInitFeatures a_conv;
24096         a_conv.inner = (void*)(a & (~1));
24097         a_conv.is_owned = false;
24098         LDKInitFeatures b_conv;
24099         b_conv.inner = (void*)(b & (~1));
24100         b_conv.is_owned = false;
24101         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
24102         return ret_val;
24103 }
24104
24105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24106         LDKNodeFeatures a_conv;
24107         a_conv.inner = (void*)(a & (~1));
24108         a_conv.is_owned = false;
24109         LDKNodeFeatures b_conv;
24110         b_conv.inner = (void*)(b & (~1));
24111         b_conv.is_owned = false;
24112         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
24113         return ret_val;
24114 }
24115
24116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24117         LDKChannelFeatures a_conv;
24118         a_conv.inner = (void*)(a & (~1));
24119         a_conv.is_owned = false;
24120         LDKChannelFeatures b_conv;
24121         b_conv.inner = (void*)(b & (~1));
24122         b_conv.is_owned = false;
24123         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
24124         return ret_val;
24125 }
24126
24127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24128         LDKInvoiceFeatures a_conv;
24129         a_conv.inner = (void*)(a & (~1));
24130         a_conv.is_owned = false;
24131         LDKInvoiceFeatures b_conv;
24132         b_conv.inner = (void*)(b & (~1));
24133         b_conv.is_owned = false;
24134         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
24135         return ret_val;
24136 }
24137
24138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24139         LDKInitFeatures orig_conv;
24140         orig_conv.inner = (void*)(orig & (~1));
24141         orig_conv.is_owned = false;
24142         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
24143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24145         uint64_t ret_ref = (uint64_t)ret_var.inner;
24146         if (ret_var.is_owned) {
24147                 ret_ref |= 1;
24148         }
24149         return ret_ref;
24150 }
24151
24152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24153         LDKNodeFeatures orig_conv;
24154         orig_conv.inner = (void*)(orig & (~1));
24155         orig_conv.is_owned = false;
24156         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
24157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24159         uint64_t ret_ref = (uint64_t)ret_var.inner;
24160         if (ret_var.is_owned) {
24161                 ret_ref |= 1;
24162         }
24163         return ret_ref;
24164 }
24165
24166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24167         LDKChannelFeatures orig_conv;
24168         orig_conv.inner = (void*)(orig & (~1));
24169         orig_conv.is_owned = false;
24170         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
24171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24173         uint64_t ret_ref = (uint64_t)ret_var.inner;
24174         if (ret_var.is_owned) {
24175                 ret_ref |= 1;
24176         }
24177         return ret_ref;
24178 }
24179
24180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24181         LDKInvoiceFeatures orig_conv;
24182         orig_conv.inner = (void*)(orig & (~1));
24183         orig_conv.is_owned = false;
24184         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
24185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24187         uint64_t ret_ref = (uint64_t)ret_var.inner;
24188         if (ret_var.is_owned) {
24189                 ret_ref |= 1;
24190         }
24191         return ret_ref;
24192 }
24193
24194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24195         LDKInitFeatures this_obj_conv;
24196         this_obj_conv.inner = (void*)(this_obj & (~1));
24197         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24198         InitFeatures_free(this_obj_conv);
24199 }
24200
24201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24202         LDKNodeFeatures this_obj_conv;
24203         this_obj_conv.inner = (void*)(this_obj & (~1));
24204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24205         NodeFeatures_free(this_obj_conv);
24206 }
24207
24208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24209         LDKChannelFeatures this_obj_conv;
24210         this_obj_conv.inner = (void*)(this_obj & (~1));
24211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24212         ChannelFeatures_free(this_obj_conv);
24213 }
24214
24215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24216         LDKInvoiceFeatures this_obj_conv;
24217         this_obj_conv.inner = (void*)(this_obj & (~1));
24218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24219         InvoiceFeatures_free(this_obj_conv);
24220 }
24221
24222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
24223         LDKInitFeatures ret_var = InitFeatures_empty();
24224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24226         uint64_t ret_ref = (uint64_t)ret_var.inner;
24227         if (ret_var.is_owned) {
24228                 ret_ref |= 1;
24229         }
24230         return ret_ref;
24231 }
24232
24233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
24234         LDKInitFeatures ret_var = InitFeatures_known();
24235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24237         uint64_t ret_ref = (uint64_t)ret_var.inner;
24238         if (ret_var.is_owned) {
24239                 ret_ref |= 1;
24240         }
24241         return ret_ref;
24242 }
24243
24244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
24245         LDKNodeFeatures ret_var = NodeFeatures_empty();
24246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24248         uint64_t ret_ref = (uint64_t)ret_var.inner;
24249         if (ret_var.is_owned) {
24250                 ret_ref |= 1;
24251         }
24252         return ret_ref;
24253 }
24254
24255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
24256         LDKNodeFeatures ret_var = NodeFeatures_known();
24257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24259         uint64_t ret_ref = (uint64_t)ret_var.inner;
24260         if (ret_var.is_owned) {
24261                 ret_ref |= 1;
24262         }
24263         return ret_ref;
24264 }
24265
24266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
24267         LDKChannelFeatures ret_var = ChannelFeatures_empty();
24268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24270         uint64_t ret_ref = (uint64_t)ret_var.inner;
24271         if (ret_var.is_owned) {
24272                 ret_ref |= 1;
24273         }
24274         return ret_ref;
24275 }
24276
24277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
24278         LDKChannelFeatures ret_var = ChannelFeatures_known();
24279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24281         uint64_t ret_ref = (uint64_t)ret_var.inner;
24282         if (ret_var.is_owned) {
24283                 ret_ref |= 1;
24284         }
24285         return ret_ref;
24286 }
24287
24288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
24289         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
24290         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24291         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24292         uint64_t ret_ref = (uint64_t)ret_var.inner;
24293         if (ret_var.is_owned) {
24294                 ret_ref |= 1;
24295         }
24296         return ret_ref;
24297 }
24298
24299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
24300         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
24301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24303         uint64_t ret_ref = (uint64_t)ret_var.inner;
24304         if (ret_var.is_owned) {
24305                 ret_ref |= 1;
24306         }
24307         return ret_ref;
24308 }
24309
24310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
24311         LDKInitFeatures this_arg_conv;
24312         this_arg_conv.inner = (void*)(this_arg & (~1));
24313         this_arg_conv.is_owned = false;
24314         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
24315         return ret_val;
24316 }
24317
24318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
24319         LDKNodeFeatures this_arg_conv;
24320         this_arg_conv.inner = (void*)(this_arg & (~1));
24321         this_arg_conv.is_owned = false;
24322         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
24323         return ret_val;
24324 }
24325
24326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
24327         LDKInvoiceFeatures this_arg_conv;
24328         this_arg_conv.inner = (void*)(this_arg & (~1));
24329         this_arg_conv.is_owned = false;
24330         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
24331         return ret_val;
24332 }
24333
24334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24335         LDKInitFeatures obj_conv;
24336         obj_conv.inner = (void*)(obj & (~1));
24337         obj_conv.is_owned = false;
24338         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
24339         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24340         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24341         CVec_u8Z_free(ret_var);
24342         return ret_arr;
24343 }
24344
24345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24346         LDKNodeFeatures obj_conv;
24347         obj_conv.inner = (void*)(obj & (~1));
24348         obj_conv.is_owned = false;
24349         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
24350         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24351         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24352         CVec_u8Z_free(ret_var);
24353         return ret_arr;
24354 }
24355
24356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24357         LDKChannelFeatures obj_conv;
24358         obj_conv.inner = (void*)(obj & (~1));
24359         obj_conv.is_owned = false;
24360         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
24361         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24362         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24363         CVec_u8Z_free(ret_var);
24364         return ret_arr;
24365 }
24366
24367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
24368         LDKInvoiceFeatures obj_conv;
24369         obj_conv.inner = (void*)(obj & (~1));
24370         obj_conv.is_owned = false;
24371         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
24372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24374         CVec_u8Z_free(ret_var);
24375         return ret_arr;
24376 }
24377
24378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24379         LDKu8slice ser_ref;
24380         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24381         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24382         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
24383         *ret_conv = InitFeatures_read(ser_ref);
24384         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24385         return (uint64_t)ret_conv;
24386 }
24387
24388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24389         LDKu8slice ser_ref;
24390         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24391         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24392         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
24393         *ret_conv = NodeFeatures_read(ser_ref);
24394         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24395         return (uint64_t)ret_conv;
24396 }
24397
24398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24399         LDKu8slice ser_ref;
24400         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24401         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24402         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
24403         *ret_conv = ChannelFeatures_read(ser_ref);
24404         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24405         return (uint64_t)ret_conv;
24406 }
24407
24408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24409         LDKu8slice ser_ref;
24410         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24411         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24412         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
24413         *ret_conv = InvoiceFeatures_read(ser_ref);
24414         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24415         return (uint64_t)ret_conv;
24416 }
24417
24418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24419         LDKShutdownScript this_obj_conv;
24420         this_obj_conv.inner = (void*)(this_obj & (~1));
24421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24422         ShutdownScript_free(this_obj_conv);
24423 }
24424
24425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24426         LDKShutdownScript orig_conv;
24427         orig_conv.inner = (void*)(orig & (~1));
24428         orig_conv.is_owned = false;
24429         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
24430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24432         uint64_t ret_ref = (uint64_t)ret_var.inner;
24433         if (ret_var.is_owned) {
24434                 ret_ref |= 1;
24435         }
24436         return ret_ref;
24437 }
24438
24439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24440         LDKInvalidShutdownScript this_obj_conv;
24441         this_obj_conv.inner = (void*)(this_obj & (~1));
24442         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24443         InvalidShutdownScript_free(this_obj_conv);
24444 }
24445
24446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
24447         LDKInvalidShutdownScript this_ptr_conv;
24448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24449         this_ptr_conv.is_owned = false;
24450         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
24451         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24452         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24453         return ret_arr;
24454 }
24455
24456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24457         LDKInvalidShutdownScript this_ptr_conv;
24458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24459         this_ptr_conv.is_owned = false;
24460         LDKCVec_u8Z val_ref;
24461         val_ref.datalen = (*env)->GetArrayLength(env, val);
24462         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
24463         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
24464         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
24465 }
24466
24467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
24468         LDKCVec_u8Z script_arg_ref;
24469         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
24470         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
24471         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
24472         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
24473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24475         uint64_t ret_ref = (uint64_t)ret_var.inner;
24476         if (ret_var.is_owned) {
24477                 ret_ref |= 1;
24478         }
24479         return ret_ref;
24480 }
24481
24482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
24483         LDKShutdownScript obj_conv;
24484         obj_conv.inner = (void*)(obj & (~1));
24485         obj_conv.is_owned = false;
24486         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
24487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24489         CVec_u8Z_free(ret_var);
24490         return ret_arr;
24491 }
24492
24493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24494         LDKu8slice ser_ref;
24495         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24496         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24497         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
24498         *ret_conv = ShutdownScript_read(ser_ref);
24499         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24500         return (uint64_t)ret_conv;
24501 }
24502
24503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2pkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
24504         unsigned char pubkey_hash_arr[20];
24505         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
24506         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
24507         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
24508         LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref);
24509         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24510         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24511         uint64_t ret_ref = (uint64_t)ret_var.inner;
24512         if (ret_var.is_owned) {
24513                 ret_ref |= 1;
24514         }
24515         return ret_ref;
24516 }
24517
24518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2sh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
24519         unsigned char script_hash_arr[20];
24520         CHECK((*env)->GetArrayLength(env, script_hash) == 20);
24521         (*env)->GetByteArrayRegion(env, script_hash, 0, 20, script_hash_arr);
24522         unsigned char (*script_hash_ref)[20] = &script_hash_arr;
24523         LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref);
24524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24526         uint64_t ret_ref = (uint64_t)ret_var.inner;
24527         if (ret_var.is_owned) {
24528                 ret_ref |= 1;
24529         }
24530         return ret_ref;
24531 }
24532
24533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
24534         unsigned char pubkey_hash_arr[20];
24535         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
24536         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
24537         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
24538         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
24539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24541         uint64_t ret_ref = (uint64_t)ret_var.inner;
24542         if (ret_var.is_owned) {
24543                 ret_ref |= 1;
24544         }
24545         return ret_ref;
24546 }
24547
24548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
24549         unsigned char script_hash_arr[32];
24550         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
24551         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
24552         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
24553         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
24554         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24555         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24556         uint64_t ret_ref = (uint64_t)ret_var.inner;
24557         if (ret_var.is_owned) {
24558                 ret_ref |= 1;
24559         }
24560         return ret_ref;
24561 }
24562
24563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
24564         LDKu8slice program_ref;
24565         program_ref.datalen = (*env)->GetArrayLength(env, program);
24566         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
24567         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
24568         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
24569         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
24570         return (uint64_t)ret_conv;
24571 }
24572
24573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
24574         LDKShutdownScript this_arg_conv;
24575         this_arg_conv.inner = (void*)(this_arg & (~1));
24576         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24577         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
24578         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
24579         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24580         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24581         CVec_u8Z_free(ret_var);
24582         return ret_arr;
24583 }
24584
24585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
24586         LDKShutdownScript this_arg_conv;
24587         this_arg_conv.inner = (void*)(this_arg & (~1));
24588         this_arg_conv.is_owned = false;
24589         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24590         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
24591         return ret_arr;
24592 }
24593
24594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
24595         LDKShutdownScript this_arg_conv;
24596         this_arg_conv.inner = (void*)(this_arg & (~1));
24597         this_arg_conv.is_owned = false;
24598         LDKInitFeatures features_conv;
24599         features_conv.inner = (void*)(features & (~1));
24600         features_conv.is_owned = false;
24601         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
24602         return ret_val;
24603 }
24604
24605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24606         LDKRouteHop this_obj_conv;
24607         this_obj_conv.inner = (void*)(this_obj & (~1));
24608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24609         RouteHop_free(this_obj_conv);
24610 }
24611
24612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24613         LDKRouteHop this_ptr_conv;
24614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24615         this_ptr_conv.is_owned = false;
24616         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24617         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
24618         return ret_arr;
24619 }
24620
24621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24622         LDKRouteHop this_ptr_conv;
24623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24624         this_ptr_conv.is_owned = false;
24625         LDKPublicKey val_ref;
24626         CHECK((*env)->GetArrayLength(env, val) == 33);
24627         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24628         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
24629 }
24630
24631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24632         LDKRouteHop this_ptr_conv;
24633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24634         this_ptr_conv.is_owned = false;
24635         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
24636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24638         uint64_t ret_ref = (uint64_t)ret_var.inner;
24639         if (ret_var.is_owned) {
24640                 ret_ref |= 1;
24641         }
24642         return ret_ref;
24643 }
24644
24645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24646         LDKRouteHop this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         LDKNodeFeatures val_conv;
24650         val_conv.inner = (void*)(val & (~1));
24651         val_conv.is_owned = (val & 1) || (val == 0);
24652         val_conv = NodeFeatures_clone(&val_conv);
24653         RouteHop_set_node_features(&this_ptr_conv, val_conv);
24654 }
24655
24656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24657         LDKRouteHop this_ptr_conv;
24658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24659         this_ptr_conv.is_owned = false;
24660         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
24661         return ret_val;
24662 }
24663
24664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24665         LDKRouteHop this_ptr_conv;
24666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24667         this_ptr_conv.is_owned = false;
24668         RouteHop_set_short_channel_id(&this_ptr_conv, val);
24669 }
24670
24671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24672         LDKRouteHop this_ptr_conv;
24673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24674         this_ptr_conv.is_owned = false;
24675         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
24676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24678         uint64_t ret_ref = (uint64_t)ret_var.inner;
24679         if (ret_var.is_owned) {
24680                 ret_ref |= 1;
24681         }
24682         return ret_ref;
24683 }
24684
24685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24686         LDKRouteHop this_ptr_conv;
24687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24688         this_ptr_conv.is_owned = false;
24689         LDKChannelFeatures val_conv;
24690         val_conv.inner = (void*)(val & (~1));
24691         val_conv.is_owned = (val & 1) || (val == 0);
24692         val_conv = ChannelFeatures_clone(&val_conv);
24693         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
24694 }
24695
24696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24697         LDKRouteHop this_ptr_conv;
24698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24699         this_ptr_conv.is_owned = false;
24700         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
24701         return ret_val;
24702 }
24703
24704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24705         LDKRouteHop this_ptr_conv;
24706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24707         this_ptr_conv.is_owned = false;
24708         RouteHop_set_fee_msat(&this_ptr_conv, val);
24709 }
24710
24711 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24712         LDKRouteHop this_ptr_conv;
24713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24714         this_ptr_conv.is_owned = false;
24715         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
24716         return ret_val;
24717 }
24718
24719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24720         LDKRouteHop this_ptr_conv;
24721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24722         this_ptr_conv.is_owned = false;
24723         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
24724 }
24725
24726 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) {
24727         LDKPublicKey pubkey_arg_ref;
24728         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
24729         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
24730         LDKNodeFeatures node_features_arg_conv;
24731         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
24732         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
24733         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
24734         LDKChannelFeatures channel_features_arg_conv;
24735         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
24736         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
24737         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
24738         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);
24739         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24740         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24741         uint64_t ret_ref = (uint64_t)ret_var.inner;
24742         if (ret_var.is_owned) {
24743                 ret_ref |= 1;
24744         }
24745         return ret_ref;
24746 }
24747
24748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24749         LDKRouteHop orig_conv;
24750         orig_conv.inner = (void*)(orig & (~1));
24751         orig_conv.is_owned = false;
24752         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
24753         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24754         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24755         uint64_t ret_ref = (uint64_t)ret_var.inner;
24756         if (ret_var.is_owned) {
24757                 ret_ref |= 1;
24758         }
24759         return ret_ref;
24760 }
24761
24762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
24763         LDKRouteHop obj_conv;
24764         obj_conv.inner = (void*)(obj & (~1));
24765         obj_conv.is_owned = false;
24766         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
24767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24769         CVec_u8Z_free(ret_var);
24770         return ret_arr;
24771 }
24772
24773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24774         LDKu8slice ser_ref;
24775         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24776         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24777         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
24778         *ret_conv = RouteHop_read(ser_ref);
24779         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24780         return (uint64_t)ret_conv;
24781 }
24782
24783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24784         LDKRoute this_obj_conv;
24785         this_obj_conv.inner = (void*)(this_obj & (~1));
24786         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24787         Route_free(this_obj_conv);
24788 }
24789
24790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
24791         LDKRoute this_ptr_conv;
24792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24793         this_ptr_conv.is_owned = false;
24794         LDKCVec_CVec_RouteHopZZ val_constr;
24795         val_constr.datalen = (*env)->GetArrayLength(env, val);
24796         if (val_constr.datalen > 0)
24797                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24798         else
24799                 val_constr.data = NULL;
24800         for (size_t m = 0; m < val_constr.datalen; m++) {
24801                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
24802                 LDKCVec_RouteHopZ val_conv_12_constr;
24803                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
24804                 if (val_conv_12_constr.datalen > 0)
24805                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24806                 else
24807                         val_conv_12_constr.data = NULL;
24808                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
24809                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
24810                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
24811                         LDKRouteHop val_conv_12_conv_10_conv;
24812                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
24813                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
24814                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
24815                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
24816                 }
24817                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
24818                 val_constr.data[m] = val_conv_12_constr;
24819         }
24820         Route_set_paths(&this_ptr_conv, val_constr);
24821 }
24822
24823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
24824         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
24825         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
24826         if (paths_arg_constr.datalen > 0)
24827                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24828         else
24829                 paths_arg_constr.data = NULL;
24830         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
24831                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
24832                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
24833                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
24834                 if (paths_arg_conv_12_constr.datalen > 0)
24835                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24836                 else
24837                         paths_arg_conv_12_constr.data = NULL;
24838                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
24839                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
24840                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
24841                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
24842                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
24843                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
24844                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
24845                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
24846                 }
24847                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
24848                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
24849         }
24850         LDKRoute ret_var = Route_new(paths_arg_constr);
24851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24853         uint64_t ret_ref = (uint64_t)ret_var.inner;
24854         if (ret_var.is_owned) {
24855                 ret_ref |= 1;
24856         }
24857         return ret_ref;
24858 }
24859
24860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24861         LDKRoute orig_conv;
24862         orig_conv.inner = (void*)(orig & (~1));
24863         orig_conv.is_owned = false;
24864         LDKRoute ret_var = Route_clone(&orig_conv);
24865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24867         uint64_t ret_ref = (uint64_t)ret_var.inner;
24868         if (ret_var.is_owned) {
24869                 ret_ref |= 1;
24870         }
24871         return ret_ref;
24872 }
24873
24874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
24875         LDKRoute obj_conv;
24876         obj_conv.inner = (void*)(obj & (~1));
24877         obj_conv.is_owned = false;
24878         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
24879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24881         CVec_u8Z_free(ret_var);
24882         return ret_arr;
24883 }
24884
24885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24886         LDKu8slice ser_ref;
24887         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24888         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24889         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
24890         *ret_conv = Route_read(ser_ref);
24891         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24892         return (uint64_t)ret_conv;
24893 }
24894
24895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24896         LDKRouteHint this_obj_conv;
24897         this_obj_conv.inner = (void*)(this_obj & (~1));
24898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24899         RouteHint_free(this_obj_conv);
24900 }
24901
24902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24903         LDKRouteHint a_conv;
24904         a_conv.inner = (void*)(a & (~1));
24905         a_conv.is_owned = false;
24906         LDKRouteHint b_conv;
24907         b_conv.inner = (void*)(b & (~1));
24908         b_conv.is_owned = false;
24909         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
24910         return ret_val;
24911 }
24912
24913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24914         LDKRouteHint orig_conv;
24915         orig_conv.inner = (void*)(orig & (~1));
24916         orig_conv.is_owned = false;
24917         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
24918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24920         uint64_t ret_ref = (uint64_t)ret_var.inner;
24921         if (ret_var.is_owned) {
24922                 ret_ref |= 1;
24923         }
24924         return ret_ref;
24925 }
24926
24927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24928         LDKRouteHintHop this_obj_conv;
24929         this_obj_conv.inner = (void*)(this_obj & (~1));
24930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24931         RouteHintHop_free(this_obj_conv);
24932 }
24933
24934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24935         LDKRouteHintHop this_ptr_conv;
24936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24937         this_ptr_conv.is_owned = false;
24938         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
24940         return ret_arr;
24941 }
24942
24943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24944         LDKRouteHintHop this_ptr_conv;
24945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24946         this_ptr_conv.is_owned = false;
24947         LDKPublicKey val_ref;
24948         CHECK((*env)->GetArrayLength(env, val) == 33);
24949         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24950         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
24951 }
24952
24953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24954         LDKRouteHintHop this_ptr_conv;
24955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24956         this_ptr_conv.is_owned = false;
24957         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
24958         return ret_val;
24959 }
24960
24961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24962         LDKRouteHintHop this_ptr_conv;
24963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24964         this_ptr_conv.is_owned = false;
24965         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
24966 }
24967
24968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24969         LDKRouteHintHop this_ptr_conv;
24970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24971         this_ptr_conv.is_owned = false;
24972         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24983         LDKRouteHintHop this_ptr_conv;
24984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24985         this_ptr_conv.is_owned = false;
24986         LDKRoutingFees val_conv;
24987         val_conv.inner = (void*)(val & (~1));
24988         val_conv.is_owned = (val & 1) || (val == 0);
24989         val_conv = RoutingFees_clone(&val_conv);
24990         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
24991 }
24992
24993 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24994         LDKRouteHintHop this_ptr_conv;
24995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24996         this_ptr_conv.is_owned = false;
24997         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
24998         return ret_val;
24999 }
25000
25001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25002         LDKRouteHintHop this_ptr_conv;
25003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25004         this_ptr_conv.is_owned = false;
25005         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
25006 }
25007
25008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25009         LDKRouteHintHop this_ptr_conv;
25010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25011         this_ptr_conv.is_owned = false;
25012         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25013         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
25014         uint64_t ret_ref = (uint64_t)ret_copy;
25015         return ret_ref;
25016 }
25017
25018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25019         LDKRouteHintHop this_ptr_conv;
25020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25021         this_ptr_conv.is_owned = false;
25022         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25023         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
25024 }
25025
25026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25027         LDKRouteHintHop this_ptr_conv;
25028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25029         this_ptr_conv.is_owned = false;
25030         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25031         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
25032         uint64_t ret_ref = (uint64_t)ret_copy;
25033         return ret_ref;
25034 }
25035
25036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25037         LDKRouteHintHop this_ptr_conv;
25038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25039         this_ptr_conv.is_owned = false;
25040         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25041         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
25042 }
25043
25044 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) {
25045         LDKPublicKey src_node_id_arg_ref;
25046         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
25047         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
25048         LDKRoutingFees fees_arg_conv;
25049         fees_arg_conv.inner = (void*)(fees_arg & (~1));
25050         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
25051         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
25052         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
25053         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
25054         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);
25055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25057         uint64_t ret_ref = (uint64_t)ret_var.inner;
25058         if (ret_var.is_owned) {
25059                 ret_ref |= 1;
25060         }
25061         return ret_ref;
25062 }
25063
25064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25065         LDKRouteHintHop a_conv;
25066         a_conv.inner = (void*)(a & (~1));
25067         a_conv.is_owned = false;
25068         LDKRouteHintHop b_conv;
25069         b_conv.inner = (void*)(b & (~1));
25070         b_conv.is_owned = false;
25071         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
25072         return ret_val;
25073 }
25074
25075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25076         LDKRouteHintHop orig_conv;
25077         orig_conv.inner = (void*)(orig & (~1));
25078         orig_conv.is_owned = false;
25079         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
25080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25082         uint64_t ret_ref = (uint64_t)ret_var.inner;
25083         if (ret_var.is_owned) {
25084                 ret_ref |= 1;
25085         }
25086         return ret_ref;
25087 }
25088
25089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) {
25090         LDKPublicKey our_node_id_ref;
25091         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
25092         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
25093         LDKNetworkGraph network_conv;
25094         network_conv.inner = (void*)(network & (~1));
25095         network_conv.is_owned = false;
25096         LDKPublicKey payee_ref;
25097         CHECK((*env)->GetArrayLength(env, payee) == 33);
25098         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
25099         LDKCVec_ChannelDetailsZ first_hops_constr;
25100         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
25101         if (first_hops != NULL) {
25102                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
25103                 if (first_hops_constr.datalen > 0)
25104                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25105                 else
25106                         first_hops_constr.data = NULL;
25107                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
25108                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
25109                         int64_t first_hops_conv_16 = first_hops_vals[q];
25110                         LDKChannelDetails first_hops_conv_16_conv;
25111                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
25112                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
25113                         first_hops_constr.data[q] = first_hops_conv_16_conv;
25114                 }
25115                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
25116                 first_hops_ptr = &first_hops_constr;
25117         }
25118         LDKCVec_RouteHintZ last_hops_constr;
25119         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
25120         if (last_hops_constr.datalen > 0)
25121                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
25122         else
25123                 last_hops_constr.data = NULL;
25124         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
25125         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
25126                 int64_t last_hops_conv_11 = last_hops_vals[l];
25127                 LDKRouteHint last_hops_conv_11_conv;
25128                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
25129                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
25130                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
25131                 last_hops_constr.data[l] = last_hops_conv_11_conv;
25132         }
25133         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
25134         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25135         if (logger_conv.free == LDKLogger_JCalls_free) {
25136                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25137                 LDKLogger_JCalls_cloned(&logger_conv);
25138         }
25139         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
25140         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
25141         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
25142         return (uint64_t)ret_conv;
25143 }
25144
25145 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) {
25146         LDKPublicKey our_node_id_ref;
25147         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
25148         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
25149         LDKNetworkGraph network_conv;
25150         network_conv.inner = (void*)(network & (~1));
25151         network_conv.is_owned = false;
25152         LDKPublicKey payee_ref;
25153         CHECK((*env)->GetArrayLength(env, payee) == 33);
25154         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
25155         LDKInvoiceFeatures payee_features_conv;
25156         payee_features_conv.inner = (void*)(payee_features & (~1));
25157         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
25158         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
25159         LDKCVec_ChannelDetailsZ first_hops_constr;
25160         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
25161         if (first_hops != NULL) {
25162                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
25163                 if (first_hops_constr.datalen > 0)
25164                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25165                 else
25166                         first_hops_constr.data = NULL;
25167                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
25168                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
25169                         int64_t first_hops_conv_16 = first_hops_vals[q];
25170                         LDKChannelDetails first_hops_conv_16_conv;
25171                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
25172                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
25173                         first_hops_constr.data[q] = first_hops_conv_16_conv;
25174                 }
25175                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
25176                 first_hops_ptr = &first_hops_constr;
25177         }
25178         LDKCVec_RouteHintZ last_hops_constr;
25179         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
25180         if (last_hops_constr.datalen > 0)
25181                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
25182         else
25183                 last_hops_constr.data = NULL;
25184         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
25185         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
25186                 int64_t last_hops_conv_11 = last_hops_vals[l];
25187                 LDKRouteHint last_hops_conv_11_conv;
25188                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
25189                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
25190                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
25191                 last_hops_constr.data[l] = last_hops_conv_11_conv;
25192         }
25193         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
25194         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25195         if (logger_conv.free == LDKLogger_JCalls_free) {
25196                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25197                 LDKLogger_JCalls_cloned(&logger_conv);
25198         }
25199         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
25200         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
25201         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
25202         return (uint64_t)ret_conv;
25203 }
25204
25205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25206         LDKNetworkGraph this_obj_conv;
25207         this_obj_conv.inner = (void*)(this_obj & (~1));
25208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25209         NetworkGraph_free(this_obj_conv);
25210 }
25211
25212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25213         LDKNetworkGraph orig_conv;
25214         orig_conv.inner = (void*)(orig & (~1));
25215         orig_conv.is_owned = false;
25216         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
25217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25219         uint64_t ret_ref = (uint64_t)ret_var.inner;
25220         if (ret_var.is_owned) {
25221                 ret_ref |= 1;
25222         }
25223         return ret_ref;
25224 }
25225
25226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25227         LDKLockedNetworkGraph this_obj_conv;
25228         this_obj_conv.inner = (void*)(this_obj & (~1));
25229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25230         LockedNetworkGraph_free(this_obj_conv);
25231 }
25232
25233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25234         LDKNetGraphMsgHandler this_obj_conv;
25235         this_obj_conv.inner = (void*)(this_obj & (~1));
25236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25237         NetGraphMsgHandler_free(this_obj_conv);
25238 }
25239
25240 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) {
25241         LDKThirtyTwoBytes genesis_hash_ref;
25242         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
25243         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
25244         LDKAccess *chain_access_conv_ptr = NULL;
25245         if (chain_access != 0) {
25246                 LDKAccess chain_access_conv;
25247                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25248                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25249                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25250                         LDKAccess_JCalls_cloned(&chain_access_conv);
25251                 }
25252                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25253                 *chain_access_conv_ptr = chain_access_conv;
25254         }
25255         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25256         if (logger_conv.free == LDKLogger_JCalls_free) {
25257                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25258                 LDKLogger_JCalls_cloned(&logger_conv);
25259         }
25260         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
25261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25263         uint64_t ret_ref = (uint64_t)ret_var.inner;
25264         if (ret_var.is_owned) {
25265                 ret_ref |= 1;
25266         }
25267         return ret_ref;
25268 }
25269
25270 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) {
25271         LDKAccess *chain_access_conv_ptr = NULL;
25272         if (chain_access != 0) {
25273                 LDKAccess chain_access_conv;
25274                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25275                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25276                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25277                         LDKAccess_JCalls_cloned(&chain_access_conv);
25278                 }
25279                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25280                 *chain_access_conv_ptr = chain_access_conv;
25281         }
25282         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25283         if (logger_conv.free == LDKLogger_JCalls_free) {
25284                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25285                 LDKLogger_JCalls_cloned(&logger_conv);
25286         }
25287         LDKNetworkGraph network_graph_conv;
25288         network_graph_conv.inner = (void*)(network_graph & (~1));
25289         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
25290         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
25291         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
25292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25294         uint64_t ret_ref = (uint64_t)ret_var.inner;
25295         if (ret_var.is_owned) {
25296                 ret_ref |= 1;
25297         }
25298         return ret_ref;
25299 }
25300
25301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
25302         LDKNetGraphMsgHandler this_arg_conv;
25303         this_arg_conv.inner = (void*)(this_arg & (~1));
25304         this_arg_conv.is_owned = false;
25305         LDKAccess *chain_access_conv_ptr = NULL;
25306         if (chain_access != 0) {
25307                 LDKAccess chain_access_conv;
25308                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25309                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25310                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25311                         LDKAccess_JCalls_cloned(&chain_access_conv);
25312                 }
25313                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25314                 *chain_access_conv_ptr = chain_access_conv;
25315         }
25316         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
25317 }
25318
25319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
25320         LDKNetGraphMsgHandler this_arg_conv;
25321         this_arg_conv.inner = (void*)(this_arg & (~1));
25322         this_arg_conv.is_owned = false;
25323         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
25324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25326         uint64_t ret_ref = (uint64_t)ret_var.inner;
25327         if (ret_var.is_owned) {
25328                 ret_ref |= 1;
25329         }
25330         return ret_ref;
25331 }
25332
25333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
25334         LDKLockedNetworkGraph this_arg_conv;
25335         this_arg_conv.inner = (void*)(this_arg & (~1));
25336         this_arg_conv.is_owned = false;
25337         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
25338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25340         uint64_t ret_ref = (uint64_t)ret_var.inner;
25341         if (ret_var.is_owned) {
25342                 ret_ref |= 1;
25343         }
25344         return ret_ref;
25345 }
25346
25347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25348         LDKNetGraphMsgHandler this_arg_conv;
25349         this_arg_conv.inner = (void*)(this_arg & (~1));
25350         this_arg_conv.is_owned = false;
25351         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
25352         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
25353         return (uint64_t)ret;
25354 }
25355
25356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25357         LDKNetGraphMsgHandler this_arg_conv;
25358         this_arg_conv.inner = (void*)(this_arg & (~1));
25359         this_arg_conv.is_owned = false;
25360         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25361         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
25362         return (uint64_t)ret;
25363 }
25364
25365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25366         LDKDirectionalChannelInfo this_obj_conv;
25367         this_obj_conv.inner = (void*)(this_obj & (~1));
25368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25369         DirectionalChannelInfo_free(this_obj_conv);
25370 }
25371
25372 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
25373         LDKDirectionalChannelInfo this_ptr_conv;
25374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25375         this_ptr_conv.is_owned = false;
25376         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
25377         return ret_val;
25378 }
25379
25380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25381         LDKDirectionalChannelInfo this_ptr_conv;
25382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25383         this_ptr_conv.is_owned = false;
25384         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
25385 }
25386
25387 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
25388         LDKDirectionalChannelInfo this_ptr_conv;
25389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25390         this_ptr_conv.is_owned = false;
25391         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
25392         return ret_val;
25393 }
25394
25395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25396         LDKDirectionalChannelInfo this_ptr_conv;
25397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25398         this_ptr_conv.is_owned = false;
25399         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
25400 }
25401
25402 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
25403         LDKDirectionalChannelInfo this_ptr_conv;
25404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25405         this_ptr_conv.is_owned = false;
25406         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
25407         return ret_val;
25408 }
25409
25410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25411         LDKDirectionalChannelInfo this_ptr_conv;
25412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25413         this_ptr_conv.is_owned = false;
25414         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25415 }
25416
25417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25418         LDKDirectionalChannelInfo this_ptr_conv;
25419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25420         this_ptr_conv.is_owned = false;
25421         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
25422         return ret_val;
25423 }
25424
25425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25426         LDKDirectionalChannelInfo this_ptr_conv;
25427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25428         this_ptr_conv.is_owned = false;
25429         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
25430 }
25431
25432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25433         LDKDirectionalChannelInfo this_ptr_conv;
25434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25435         this_ptr_conv.is_owned = false;
25436         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25437         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
25438         uint64_t ret_ref = (uint64_t)ret_copy;
25439         return ret_ref;
25440 }
25441
25442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25443         LDKDirectionalChannelInfo this_ptr_conv;
25444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25445         this_ptr_conv.is_owned = false;
25446         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25447         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
25448 }
25449
25450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
25451         LDKDirectionalChannelInfo this_ptr_conv;
25452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25453         this_ptr_conv.is_owned = false;
25454         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
25455         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25456         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25457         uint64_t ret_ref = (uint64_t)ret_var.inner;
25458         if (ret_var.is_owned) {
25459                 ret_ref |= 1;
25460         }
25461         return ret_ref;
25462 }
25463
25464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25465         LDKDirectionalChannelInfo this_ptr_conv;
25466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25467         this_ptr_conv.is_owned = false;
25468         LDKRoutingFees val_conv;
25469         val_conv.inner = (void*)(val & (~1));
25470         val_conv.is_owned = (val & 1) || (val == 0);
25471         val_conv = RoutingFees_clone(&val_conv);
25472         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
25473 }
25474
25475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25476         LDKDirectionalChannelInfo this_ptr_conv;
25477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25478         this_ptr_conv.is_owned = false;
25479         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
25480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25482         uint64_t ret_ref = (uint64_t)ret_var.inner;
25483         if (ret_var.is_owned) {
25484                 ret_ref |= 1;
25485         }
25486         return ret_ref;
25487 }
25488
25489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25490         LDKDirectionalChannelInfo this_ptr_conv;
25491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25492         this_ptr_conv.is_owned = false;
25493         LDKChannelUpdate val_conv;
25494         val_conv.inner = (void*)(val & (~1));
25495         val_conv.is_owned = (val & 1) || (val == 0);
25496         val_conv = ChannelUpdate_clone(&val_conv);
25497         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
25498 }
25499
25500 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) {
25501         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
25502         LDKRoutingFees fees_arg_conv;
25503         fees_arg_conv.inner = (void*)(fees_arg & (~1));
25504         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
25505         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
25506         LDKChannelUpdate last_update_message_arg_conv;
25507         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
25508         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
25509         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
25510         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);
25511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25513         uint64_t ret_ref = (uint64_t)ret_var.inner;
25514         if (ret_var.is_owned) {
25515                 ret_ref |= 1;
25516         }
25517         return ret_ref;
25518 }
25519
25520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25521         LDKDirectionalChannelInfo orig_conv;
25522         orig_conv.inner = (void*)(orig & (~1));
25523         orig_conv.is_owned = false;
25524         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
25525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25527         uint64_t ret_ref = (uint64_t)ret_var.inner;
25528         if (ret_var.is_owned) {
25529                 ret_ref |= 1;
25530         }
25531         return ret_ref;
25532 }
25533
25534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25535         LDKDirectionalChannelInfo obj_conv;
25536         obj_conv.inner = (void*)(obj & (~1));
25537         obj_conv.is_owned = false;
25538         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
25539         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25540         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25541         CVec_u8Z_free(ret_var);
25542         return ret_arr;
25543 }
25544
25545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25546         LDKu8slice ser_ref;
25547         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25548         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25549         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
25550         *ret_conv = DirectionalChannelInfo_read(ser_ref);
25551         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25552         return (uint64_t)ret_conv;
25553 }
25554
25555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25556         LDKChannelInfo this_obj_conv;
25557         this_obj_conv.inner = (void*)(this_obj & (~1));
25558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25559         ChannelInfo_free(this_obj_conv);
25560 }
25561
25562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25563         LDKChannelInfo this_ptr_conv;
25564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25565         this_ptr_conv.is_owned = false;
25566         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
25567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25569         uint64_t ret_ref = (uint64_t)ret_var.inner;
25570         if (ret_var.is_owned) {
25571                 ret_ref |= 1;
25572         }
25573         return ret_ref;
25574 }
25575
25576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25577         LDKChannelInfo this_ptr_conv;
25578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25579         this_ptr_conv.is_owned = false;
25580         LDKChannelFeatures val_conv;
25581         val_conv.inner = (void*)(val & (~1));
25582         val_conv.is_owned = (val & 1) || (val == 0);
25583         val_conv = ChannelFeatures_clone(&val_conv);
25584         ChannelInfo_set_features(&this_ptr_conv, val_conv);
25585 }
25586
25587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
25588         LDKChannelInfo this_ptr_conv;
25589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25590         this_ptr_conv.is_owned = false;
25591         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
25593         return ret_arr;
25594 }
25595
25596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25597         LDKChannelInfo this_ptr_conv;
25598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25599         this_ptr_conv.is_owned = false;
25600         LDKPublicKey val_ref;
25601         CHECK((*env)->GetArrayLength(env, val) == 33);
25602         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25603         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
25604 }
25605
25606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
25607         LDKChannelInfo this_ptr_conv;
25608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25609         this_ptr_conv.is_owned = false;
25610         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
25611         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25612         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25613         uint64_t ret_ref = (uint64_t)ret_var.inner;
25614         if (ret_var.is_owned) {
25615                 ret_ref |= 1;
25616         }
25617         return ret_ref;
25618 }
25619
25620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25621         LDKChannelInfo this_ptr_conv;
25622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25623         this_ptr_conv.is_owned = false;
25624         LDKDirectionalChannelInfo val_conv;
25625         val_conv.inner = (void*)(val & (~1));
25626         val_conv.is_owned = (val & 1) || (val == 0);
25627         val_conv = DirectionalChannelInfo_clone(&val_conv);
25628         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
25629 }
25630
25631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
25632         LDKChannelInfo this_ptr_conv;
25633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25634         this_ptr_conv.is_owned = false;
25635         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25636         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
25637         return ret_arr;
25638 }
25639
25640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25641         LDKChannelInfo this_ptr_conv;
25642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25643         this_ptr_conv.is_owned = false;
25644         LDKPublicKey val_ref;
25645         CHECK((*env)->GetArrayLength(env, val) == 33);
25646         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25647         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
25648 }
25649
25650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
25651         LDKChannelInfo this_ptr_conv;
25652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25653         this_ptr_conv.is_owned = false;
25654         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
25655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25657         uint64_t ret_ref = (uint64_t)ret_var.inner;
25658         if (ret_var.is_owned) {
25659                 ret_ref |= 1;
25660         }
25661         return ret_ref;
25662 }
25663
25664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25665         LDKChannelInfo this_ptr_conv;
25666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25667         this_ptr_conv.is_owned = false;
25668         LDKDirectionalChannelInfo val_conv;
25669         val_conv.inner = (void*)(val & (~1));
25670         val_conv.is_owned = (val & 1) || (val == 0);
25671         val_conv = DirectionalChannelInfo_clone(&val_conv);
25672         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
25673 }
25674
25675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
25676         LDKChannelInfo this_ptr_conv;
25677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25678         this_ptr_conv.is_owned = false;
25679         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25680         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
25681         uint64_t ret_ref = (uint64_t)ret_copy;
25682         return ret_ref;
25683 }
25684
25685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25686         LDKChannelInfo this_ptr_conv;
25687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25688         this_ptr_conv.is_owned = false;
25689         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25690         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
25691 }
25692
25693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25694         LDKChannelInfo this_ptr_conv;
25695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25696         this_ptr_conv.is_owned = false;
25697         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
25698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25700         uint64_t ret_ref = (uint64_t)ret_var.inner;
25701         if (ret_var.is_owned) {
25702                 ret_ref |= 1;
25703         }
25704         return ret_ref;
25705 }
25706
25707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25708         LDKChannelInfo this_ptr_conv;
25709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25710         this_ptr_conv.is_owned = false;
25711         LDKChannelAnnouncement val_conv;
25712         val_conv.inner = (void*)(val & (~1));
25713         val_conv.is_owned = (val & 1) || (val == 0);
25714         val_conv = ChannelAnnouncement_clone(&val_conv);
25715         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
25716 }
25717
25718 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) {
25719         LDKChannelFeatures features_arg_conv;
25720         features_arg_conv.inner = (void*)(features_arg & (~1));
25721         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25722         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
25723         LDKPublicKey node_one_arg_ref;
25724         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
25725         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
25726         LDKDirectionalChannelInfo one_to_two_arg_conv;
25727         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
25728         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
25729         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
25730         LDKPublicKey node_two_arg_ref;
25731         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
25732         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
25733         LDKDirectionalChannelInfo two_to_one_arg_conv;
25734         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
25735         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
25736         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
25737         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
25738         LDKChannelAnnouncement announcement_message_arg_conv;
25739         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
25740         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
25741         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
25742         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);
25743         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25744         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25745         uint64_t ret_ref = (uint64_t)ret_var.inner;
25746         if (ret_var.is_owned) {
25747                 ret_ref |= 1;
25748         }
25749         return ret_ref;
25750 }
25751
25752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25753         LDKChannelInfo orig_conv;
25754         orig_conv.inner = (void*)(orig & (~1));
25755         orig_conv.is_owned = false;
25756         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
25757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25759         uint64_t ret_ref = (uint64_t)ret_var.inner;
25760         if (ret_var.is_owned) {
25761                 ret_ref |= 1;
25762         }
25763         return ret_ref;
25764 }
25765
25766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25767         LDKChannelInfo obj_conv;
25768         obj_conv.inner = (void*)(obj & (~1));
25769         obj_conv.is_owned = false;
25770         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
25771         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25772         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25773         CVec_u8Z_free(ret_var);
25774         return ret_arr;
25775 }
25776
25777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25778         LDKu8slice ser_ref;
25779         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25780         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25781         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
25782         *ret_conv = ChannelInfo_read(ser_ref);
25783         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25784         return (uint64_t)ret_conv;
25785 }
25786
25787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25788         LDKRoutingFees this_obj_conv;
25789         this_obj_conv.inner = (void*)(this_obj & (~1));
25790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25791         RoutingFees_free(this_obj_conv);
25792 }
25793
25794 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25795         LDKRoutingFees this_ptr_conv;
25796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25797         this_ptr_conv.is_owned = false;
25798         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
25799         return ret_val;
25800 }
25801
25802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25803         LDKRoutingFees this_ptr_conv;
25804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25805         this_ptr_conv.is_owned = false;
25806         RoutingFees_set_base_msat(&this_ptr_conv, val);
25807 }
25808
25809 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25810         LDKRoutingFees this_ptr_conv;
25811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25812         this_ptr_conv.is_owned = false;
25813         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
25814         return ret_val;
25815 }
25816
25817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25818         LDKRoutingFees this_ptr_conv;
25819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25820         this_ptr_conv.is_owned = false;
25821         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
25822 }
25823
25824 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) {
25825         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
25826         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25827         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25828         uint64_t ret_ref = (uint64_t)ret_var.inner;
25829         if (ret_var.is_owned) {
25830                 ret_ref |= 1;
25831         }
25832         return ret_ref;
25833 }
25834
25835 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25836         LDKRoutingFees a_conv;
25837         a_conv.inner = (void*)(a & (~1));
25838         a_conv.is_owned = false;
25839         LDKRoutingFees b_conv;
25840         b_conv.inner = (void*)(b & (~1));
25841         b_conv.is_owned = false;
25842         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
25843         return ret_val;
25844 }
25845
25846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25847         LDKRoutingFees orig_conv;
25848         orig_conv.inner = (void*)(orig & (~1));
25849         orig_conv.is_owned = false;
25850         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
25851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25853         uint64_t ret_ref = (uint64_t)ret_var.inner;
25854         if (ret_var.is_owned) {
25855                 ret_ref |= 1;
25856         }
25857         return ret_ref;
25858 }
25859
25860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
25861         LDKRoutingFees obj_conv;
25862         obj_conv.inner = (void*)(obj & (~1));
25863         obj_conv.is_owned = false;
25864         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
25865         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25866         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25867         CVec_u8Z_free(ret_var);
25868         return ret_arr;
25869 }
25870
25871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25872         LDKu8slice ser_ref;
25873         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25874         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25875         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
25876         *ret_conv = RoutingFees_read(ser_ref);
25877         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25878         return (uint64_t)ret_conv;
25879 }
25880
25881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25882         LDKNodeAnnouncementInfo this_obj_conv;
25883         this_obj_conv.inner = (void*)(this_obj & (~1));
25884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25885         NodeAnnouncementInfo_free(this_obj_conv);
25886 }
25887
25888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25889         LDKNodeAnnouncementInfo this_ptr_conv;
25890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25891         this_ptr_conv.is_owned = false;
25892         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
25893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25895         uint64_t ret_ref = (uint64_t)ret_var.inner;
25896         if (ret_var.is_owned) {
25897                 ret_ref |= 1;
25898         }
25899         return ret_ref;
25900 }
25901
25902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25903         LDKNodeAnnouncementInfo this_ptr_conv;
25904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25905         this_ptr_conv.is_owned = false;
25906         LDKNodeFeatures val_conv;
25907         val_conv.inner = (void*)(val & (~1));
25908         val_conv.is_owned = (val & 1) || (val == 0);
25909         val_conv = NodeFeatures_clone(&val_conv);
25910         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
25911 }
25912
25913 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
25914         LDKNodeAnnouncementInfo this_ptr_conv;
25915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25916         this_ptr_conv.is_owned = false;
25917         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
25918         return ret_val;
25919 }
25920
25921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25922         LDKNodeAnnouncementInfo this_ptr_conv;
25923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25924         this_ptr_conv.is_owned = false;
25925         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
25926 }
25927
25928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
25929         LDKNodeAnnouncementInfo this_ptr_conv;
25930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25931         this_ptr_conv.is_owned = false;
25932         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
25933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
25934         return ret_arr;
25935 }
25936
25937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25938         LDKNodeAnnouncementInfo this_ptr_conv;
25939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25940         this_ptr_conv.is_owned = false;
25941         LDKThreeBytes val_ref;
25942         CHECK((*env)->GetArrayLength(env, val) == 3);
25943         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
25944         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
25945 }
25946
25947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
25948         LDKNodeAnnouncementInfo this_ptr_conv;
25949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25950         this_ptr_conv.is_owned = false;
25951         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
25953         return ret_arr;
25954 }
25955
25956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25957         LDKNodeAnnouncementInfo this_ptr_conv;
25958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25959         this_ptr_conv.is_owned = false;
25960         LDKThirtyTwoBytes val_ref;
25961         CHECK((*env)->GetArrayLength(env, val) == 32);
25962         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25963         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
25964 }
25965
25966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25967         LDKNodeAnnouncementInfo this_ptr_conv;
25968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25969         this_ptr_conv.is_owned = false;
25970         LDKCVec_NetAddressZ val_constr;
25971         val_constr.datalen = (*env)->GetArrayLength(env, val);
25972         if (val_constr.datalen > 0)
25973                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25974         else
25975                 val_constr.data = NULL;
25976         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25977         for (size_t m = 0; m < val_constr.datalen; m++) {
25978                 int64_t val_conv_12 = val_vals[m];
25979                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
25980                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25981                 val_constr.data[m] = val_conv_12_conv;
25982         }
25983         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25984         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
25985 }
25986
25987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25988         LDKNodeAnnouncementInfo this_ptr_conv;
25989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25990         this_ptr_conv.is_owned = false;
25991         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
25992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25994         uint64_t ret_ref = (uint64_t)ret_var.inner;
25995         if (ret_var.is_owned) {
25996                 ret_ref |= 1;
25997         }
25998         return ret_ref;
25999 }
26000
26001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26002         LDKNodeAnnouncementInfo this_ptr_conv;
26003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26004         this_ptr_conv.is_owned = false;
26005         LDKNodeAnnouncement val_conv;
26006         val_conv.inner = (void*)(val & (~1));
26007         val_conv.is_owned = (val & 1) || (val == 0);
26008         val_conv = NodeAnnouncement_clone(&val_conv);
26009         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
26010 }
26011
26012 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) {
26013         LDKNodeFeatures features_arg_conv;
26014         features_arg_conv.inner = (void*)(features_arg & (~1));
26015         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26016         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
26017         LDKThreeBytes rgb_arg_ref;
26018         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
26019         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
26020         LDKThirtyTwoBytes alias_arg_ref;
26021         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
26022         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
26023         LDKCVec_NetAddressZ addresses_arg_constr;
26024         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
26025         if (addresses_arg_constr.datalen > 0)
26026                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26027         else
26028                 addresses_arg_constr.data = NULL;
26029         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
26030         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
26031                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
26032                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
26033                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
26034         }
26035         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
26036         LDKNodeAnnouncement announcement_message_arg_conv;
26037         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
26038         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
26039         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
26040         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
26041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26043         uint64_t ret_ref = (uint64_t)ret_var.inner;
26044         if (ret_var.is_owned) {
26045                 ret_ref |= 1;
26046         }
26047         return ret_ref;
26048 }
26049
26050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26051         LDKNodeAnnouncementInfo orig_conv;
26052         orig_conv.inner = (void*)(orig & (~1));
26053         orig_conv.is_owned = false;
26054         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
26055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26057         uint64_t ret_ref = (uint64_t)ret_var.inner;
26058         if (ret_var.is_owned) {
26059                 ret_ref |= 1;
26060         }
26061         return ret_ref;
26062 }
26063
26064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
26065         LDKNodeAnnouncementInfo obj_conv;
26066         obj_conv.inner = (void*)(obj & (~1));
26067         obj_conv.is_owned = false;
26068         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
26069         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26070         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26071         CVec_u8Z_free(ret_var);
26072         return ret_arr;
26073 }
26074
26075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26076         LDKu8slice ser_ref;
26077         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26078         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26079         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
26080         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
26081         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26082         return (uint64_t)ret_conv;
26083 }
26084
26085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26086         LDKNodeInfo this_obj_conv;
26087         this_obj_conv.inner = (void*)(this_obj & (~1));
26088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26089         NodeInfo_free(this_obj_conv);
26090 }
26091
26092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
26093         LDKNodeInfo this_ptr_conv;
26094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26095         this_ptr_conv.is_owned = false;
26096         LDKCVec_u64Z val_constr;
26097         val_constr.datalen = (*env)->GetArrayLength(env, val);
26098         if (val_constr.datalen > 0)
26099                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26100         else
26101                 val_constr.data = NULL;
26102         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
26103         for (size_t g = 0; g < val_constr.datalen; g++) {
26104                 int64_t val_conv_6 = val_vals[g];
26105                 val_constr.data[g] = val_conv_6;
26106         }
26107         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
26108         NodeInfo_set_channels(&this_ptr_conv, val_constr);
26109 }
26110
26111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
26112         LDKNodeInfo this_ptr_conv;
26113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26114         this_ptr_conv.is_owned = false;
26115         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
26116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26118         uint64_t ret_ref = (uint64_t)ret_var.inner;
26119         if (ret_var.is_owned) {
26120                 ret_ref |= 1;
26121         }
26122         return ret_ref;
26123 }
26124
26125 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) {
26126         LDKNodeInfo this_ptr_conv;
26127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26128         this_ptr_conv.is_owned = false;
26129         LDKRoutingFees val_conv;
26130         val_conv.inner = (void*)(val & (~1));
26131         val_conv.is_owned = (val & 1) || (val == 0);
26132         val_conv = RoutingFees_clone(&val_conv);
26133         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
26134 }
26135
26136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
26137         LDKNodeInfo this_ptr_conv;
26138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26139         this_ptr_conv.is_owned = false;
26140         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
26141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26143         uint64_t ret_ref = (uint64_t)ret_var.inner;
26144         if (ret_var.is_owned) {
26145                 ret_ref |= 1;
26146         }
26147         return ret_ref;
26148 }
26149
26150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26151         LDKNodeInfo this_ptr_conv;
26152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26153         this_ptr_conv.is_owned = false;
26154         LDKNodeAnnouncementInfo val_conv;
26155         val_conv.inner = (void*)(val & (~1));
26156         val_conv.is_owned = (val & 1) || (val == 0);
26157         val_conv = NodeAnnouncementInfo_clone(&val_conv);
26158         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
26159 }
26160
26161 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) {
26162         LDKCVec_u64Z channels_arg_constr;
26163         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
26164         if (channels_arg_constr.datalen > 0)
26165                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26166         else
26167                 channels_arg_constr.data = NULL;
26168         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
26169         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
26170                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
26171                 channels_arg_constr.data[g] = channels_arg_conv_6;
26172         }
26173         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
26174         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
26175         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
26176         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
26177         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
26178         LDKNodeAnnouncementInfo announcement_info_arg_conv;
26179         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
26180         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
26181         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
26182         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
26183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26185         uint64_t ret_ref = (uint64_t)ret_var.inner;
26186         if (ret_var.is_owned) {
26187                 ret_ref |= 1;
26188         }
26189         return ret_ref;
26190 }
26191
26192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26193         LDKNodeInfo orig_conv;
26194         orig_conv.inner = (void*)(orig & (~1));
26195         orig_conv.is_owned = false;
26196         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
26197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26199         uint64_t ret_ref = (uint64_t)ret_var.inner;
26200         if (ret_var.is_owned) {
26201                 ret_ref |= 1;
26202         }
26203         return ret_ref;
26204 }
26205
26206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
26207         LDKNodeInfo obj_conv;
26208         obj_conv.inner = (void*)(obj & (~1));
26209         obj_conv.is_owned = false;
26210         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
26211         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26212         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26213         CVec_u8Z_free(ret_var);
26214         return ret_arr;
26215 }
26216
26217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26218         LDKu8slice ser_ref;
26219         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26220         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26221         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
26222         *ret_conv = NodeInfo_read(ser_ref);
26223         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26224         return (uint64_t)ret_conv;
26225 }
26226
26227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
26228         LDKNetworkGraph obj_conv;
26229         obj_conv.inner = (void*)(obj & (~1));
26230         obj_conv.is_owned = false;
26231         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
26232         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26233         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26234         CVec_u8Z_free(ret_var);
26235         return ret_arr;
26236 }
26237
26238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26239         LDKu8slice ser_ref;
26240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26242         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
26243         *ret_conv = NetworkGraph_read(ser_ref);
26244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26245         return (uint64_t)ret_conv;
26246 }
26247
26248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
26249         LDKThirtyTwoBytes genesis_hash_ref;
26250         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
26251         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
26252         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
26253         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26254         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26255         uint64_t ret_ref = (uint64_t)ret_var.inner;
26256         if (ret_var.is_owned) {
26257                 ret_ref |= 1;
26258         }
26259         return ret_ref;
26260 }
26261
26262 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) {
26263         LDKNetworkGraph this_arg_conv;
26264         this_arg_conv.inner = (void*)(this_arg & (~1));
26265         this_arg_conv.is_owned = false;
26266         LDKNodeAnnouncement msg_conv;
26267         msg_conv.inner = (void*)(msg & (~1));
26268         msg_conv.is_owned = false;
26269         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26270         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
26271         return (uint64_t)ret_conv;
26272 }
26273
26274 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) {
26275         LDKNetworkGraph this_arg_conv;
26276         this_arg_conv.inner = (void*)(this_arg & (~1));
26277         this_arg_conv.is_owned = false;
26278         LDKUnsignedNodeAnnouncement msg_conv;
26279         msg_conv.inner = (void*)(msg & (~1));
26280         msg_conv.is_owned = false;
26281         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26282         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
26283         return (uint64_t)ret_conv;
26284 }
26285
26286 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) {
26287         LDKNetworkGraph this_arg_conv;
26288         this_arg_conv.inner = (void*)(this_arg & (~1));
26289         this_arg_conv.is_owned = false;
26290         LDKChannelAnnouncement msg_conv;
26291         msg_conv.inner = (void*)(msg & (~1));
26292         msg_conv.is_owned = false;
26293         LDKAccess *chain_access_conv_ptr = NULL;
26294         if (chain_access != 0) {
26295                 LDKAccess chain_access_conv;
26296                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
26297                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
26298                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26299                         LDKAccess_JCalls_cloned(&chain_access_conv);
26300                 }
26301                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
26302                 *chain_access_conv_ptr = chain_access_conv;
26303         }
26304         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26305         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
26306         return (uint64_t)ret_conv;
26307 }
26308
26309 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) {
26310         LDKNetworkGraph this_arg_conv;
26311         this_arg_conv.inner = (void*)(this_arg & (~1));
26312         this_arg_conv.is_owned = false;
26313         LDKUnsignedChannelAnnouncement msg_conv;
26314         msg_conv.inner = (void*)(msg & (~1));
26315         msg_conv.is_owned = false;
26316         LDKAccess *chain_access_conv_ptr = NULL;
26317         if (chain_access != 0) {
26318                 LDKAccess chain_access_conv;
26319                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
26320                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
26321                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26322                         LDKAccess_JCalls_cloned(&chain_access_conv);
26323                 }
26324                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
26325                 *chain_access_conv_ptr = chain_access_conv;
26326         }
26327         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26328         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
26329         return (uint64_t)ret_conv;
26330 }
26331
26332 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) {
26333         LDKNetworkGraph this_arg_conv;
26334         this_arg_conv.inner = (void*)(this_arg & (~1));
26335         this_arg_conv.is_owned = false;
26336         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
26337 }
26338
26339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
26340         LDKNetworkGraph this_arg_conv;
26341         this_arg_conv.inner = (void*)(this_arg & (~1));
26342         this_arg_conv.is_owned = false;
26343         LDKChannelUpdate msg_conv;
26344         msg_conv.inner = (void*)(msg & (~1));
26345         msg_conv.is_owned = false;
26346         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26347         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
26348         return (uint64_t)ret_conv;
26349 }
26350
26351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
26352         LDKNetworkGraph this_arg_conv;
26353         this_arg_conv.inner = (void*)(this_arg & (~1));
26354         this_arg_conv.is_owned = false;
26355         LDKUnsignedChannelUpdate msg_conv;
26356         msg_conv.inner = (void*)(msg & (~1));
26357         msg_conv.is_owned = false;
26358         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
26359         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
26360         return (uint64_t)ret_conv;
26361 }
26362
26363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26364         LDKFilesystemPersister this_obj_conv;
26365         this_obj_conv.inner = (void*)(this_obj & (~1));
26366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26367         FilesystemPersister_free(this_obj_conv);
26368 }
26369
26370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
26371         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
26372         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
26373         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26374         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26375         uint64_t ret_ref = (uint64_t)ret_var.inner;
26376         if (ret_var.is_owned) {
26377                 ret_ref |= 1;
26378         }
26379         return ret_ref;
26380 }
26381
26382 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
26383         LDKFilesystemPersister this_arg_conv;
26384         this_arg_conv.inner = (void*)(this_arg & (~1));
26385         this_arg_conv.is_owned = false;
26386         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
26387         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26388         Str_free(ret_str);
26389         return ret_conv;
26390 }
26391
26392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
26393         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
26394         LDKChannelManager manager_conv;
26395         manager_conv.inner = (void*)(manager & (~1));
26396         manager_conv.is_owned = false;
26397         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26398         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
26399         return (uint64_t)ret_conv;
26400 }
26401
26402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
26403         LDKFilesystemPersister this_arg_conv;
26404         this_arg_conv.inner = (void*)(this_arg & (~1));
26405         this_arg_conv.is_owned = false;
26406         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26407         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26408                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26409                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26410         }
26411         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
26412         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
26413         return (uint64_t)ret_conv;
26414 }
26415
26416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
26417         LDKFilesystemPersister this_arg_conv;
26418         this_arg_conv.inner = (void*)(this_arg & (~1));
26419         this_arg_conv.is_owned = false;
26420         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
26421         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
26422         return (uint64_t)ret;
26423 }
26424
26425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26426         LDKBackgroundProcessor this_obj_conv;
26427         this_obj_conv.inner = (void*)(this_obj & (~1));
26428         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26429         BackgroundProcessor_free(this_obj_conv);
26430 }
26431
26432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26433         if ((this_ptr & 1) != 0) return;
26434         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
26435         FREE((void*)this_ptr);
26436         ChannelManagerPersister_free(this_ptr_conv);
26437 }
26438
26439 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) {
26440         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
26441         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
26442                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26443                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
26444         }
26445         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
26446         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
26447                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26448                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
26449         }
26450         LDKChainMonitor chain_monitor_conv;
26451         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
26452         chain_monitor_conv.is_owned = false;
26453         LDKChannelManager channel_manager_conv;
26454         channel_manager_conv.inner = (void*)(channel_manager & (~1));
26455         channel_manager_conv.is_owned = false;
26456         LDKPeerManager peer_manager_conv;
26457         peer_manager_conv.inner = (void*)(peer_manager & (~1));
26458         peer_manager_conv.is_owned = false;
26459         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
26460         if (logger_conv.free == LDKLogger_JCalls_free) {
26461                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26462                 LDKLogger_JCalls_cloned(&logger_conv);
26463         }
26464         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
26465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26467         uint64_t ret_ref = (uint64_t)ret_var.inner;
26468         if (ret_var.is_owned) {
26469                 ret_ref |= 1;
26470         }
26471         return ret_ref;
26472 }
26473
26474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
26475         LDKBackgroundProcessor this_arg_conv;
26476         this_arg_conv.inner = (void*)(this_arg & (~1));
26477         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26478         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
26479         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26480         *ret_conv = BackgroundProcessor_join(this_arg_conv);
26481         return (uint64_t)ret_conv;
26482 }
26483
26484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
26485         LDKBackgroundProcessor this_arg_conv;
26486         this_arg_conv.inner = (void*)(this_arg & (~1));
26487         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26488         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
26489         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26490         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
26491         return (uint64_t)ret_conv;
26492 }
26493
26494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
26495         check_platform();
26496 }
26497
26498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26499         LDKInvoice this_obj_conv;
26500         this_obj_conv.inner = (void*)(this_obj & (~1));
26501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26502         Invoice_free(this_obj_conv);
26503 }
26504
26505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26506         LDKInvoice a_conv;
26507         a_conv.inner = (void*)(a & (~1));
26508         a_conv.is_owned = false;
26509         LDKInvoice b_conv;
26510         b_conv.inner = (void*)(b & (~1));
26511         b_conv.is_owned = false;
26512         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
26513         return ret_val;
26514 }
26515
26516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26517         LDKInvoice orig_conv;
26518         orig_conv.inner = (void*)(orig & (~1));
26519         orig_conv.is_owned = false;
26520         LDKInvoice ret_var = Invoice_clone(&orig_conv);
26521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26523         uint64_t ret_ref = (uint64_t)ret_var.inner;
26524         if (ret_var.is_owned) {
26525                 ret_ref |= 1;
26526         }
26527         return ret_ref;
26528 }
26529
26530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26531         LDKSignedRawInvoice this_obj_conv;
26532         this_obj_conv.inner = (void*)(this_obj & (~1));
26533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26534         SignedRawInvoice_free(this_obj_conv);
26535 }
26536
26537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26538         LDKSignedRawInvoice a_conv;
26539         a_conv.inner = (void*)(a & (~1));
26540         a_conv.is_owned = false;
26541         LDKSignedRawInvoice b_conv;
26542         b_conv.inner = (void*)(b & (~1));
26543         b_conv.is_owned = false;
26544         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
26545         return ret_val;
26546 }
26547
26548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26549         LDKSignedRawInvoice orig_conv;
26550         orig_conv.inner = (void*)(orig & (~1));
26551         orig_conv.is_owned = false;
26552         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
26553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26555         uint64_t ret_ref = (uint64_t)ret_var.inner;
26556         if (ret_var.is_owned) {
26557                 ret_ref |= 1;
26558         }
26559         return ret_ref;
26560 }
26561
26562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26563         LDKRawInvoice this_obj_conv;
26564         this_obj_conv.inner = (void*)(this_obj & (~1));
26565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26566         RawInvoice_free(this_obj_conv);
26567 }
26568
26569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
26570         LDKRawInvoice this_ptr_conv;
26571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26572         this_ptr_conv.is_owned = false;
26573         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
26574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26576         uint64_t ret_ref = (uint64_t)ret_var.inner;
26577         if (ret_var.is_owned) {
26578                 ret_ref |= 1;
26579         }
26580         return ret_ref;
26581 }
26582
26583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26584         LDKRawInvoice this_ptr_conv;
26585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26586         this_ptr_conv.is_owned = false;
26587         LDKRawDataPart val_conv;
26588         val_conv.inner = (void*)(val & (~1));
26589         val_conv.is_owned = (val & 1) || (val == 0);
26590         val_conv = RawDataPart_clone(&val_conv);
26591         RawInvoice_set_data(&this_ptr_conv, val_conv);
26592 }
26593
26594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26595         LDKRawInvoice a_conv;
26596         a_conv.inner = (void*)(a & (~1));
26597         a_conv.is_owned = false;
26598         LDKRawInvoice b_conv;
26599         b_conv.inner = (void*)(b & (~1));
26600         b_conv.is_owned = false;
26601         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
26602         return ret_val;
26603 }
26604
26605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26606         LDKRawInvoice orig_conv;
26607         orig_conv.inner = (void*)(orig & (~1));
26608         orig_conv.is_owned = false;
26609         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
26610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26612         uint64_t ret_ref = (uint64_t)ret_var.inner;
26613         if (ret_var.is_owned) {
26614                 ret_ref |= 1;
26615         }
26616         return ret_ref;
26617 }
26618
26619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26620         LDKRawDataPart this_obj_conv;
26621         this_obj_conv.inner = (void*)(this_obj & (~1));
26622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26623         RawDataPart_free(this_obj_conv);
26624 }
26625
26626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
26627         LDKRawDataPart this_ptr_conv;
26628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26629         this_ptr_conv.is_owned = false;
26630         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
26631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26633         uint64_t ret_ref = (uint64_t)ret_var.inner;
26634         if (ret_var.is_owned) {
26635                 ret_ref |= 1;
26636         }
26637         return ret_ref;
26638 }
26639
26640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26641         LDKRawDataPart this_ptr_conv;
26642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26643         this_ptr_conv.is_owned = false;
26644         LDKPositiveTimestamp val_conv;
26645         val_conv.inner = (void*)(val & (~1));
26646         val_conv.is_owned = (val & 1) || (val == 0);
26647         val_conv = PositiveTimestamp_clone(&val_conv);
26648         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
26649 }
26650
26651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26652         LDKRawDataPart a_conv;
26653         a_conv.inner = (void*)(a & (~1));
26654         a_conv.is_owned = false;
26655         LDKRawDataPart b_conv;
26656         b_conv.inner = (void*)(b & (~1));
26657         b_conv.is_owned = false;
26658         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
26659         return ret_val;
26660 }
26661
26662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26663         LDKRawDataPart orig_conv;
26664         orig_conv.inner = (void*)(orig & (~1));
26665         orig_conv.is_owned = false;
26666         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
26667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26669         uint64_t ret_ref = (uint64_t)ret_var.inner;
26670         if (ret_var.is_owned) {
26671                 ret_ref |= 1;
26672         }
26673         return ret_ref;
26674 }
26675
26676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26677         LDKPositiveTimestamp this_obj_conv;
26678         this_obj_conv.inner = (void*)(this_obj & (~1));
26679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26680         PositiveTimestamp_free(this_obj_conv);
26681 }
26682
26683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26684         LDKPositiveTimestamp a_conv;
26685         a_conv.inner = (void*)(a & (~1));
26686         a_conv.is_owned = false;
26687         LDKPositiveTimestamp b_conv;
26688         b_conv.inner = (void*)(b & (~1));
26689         b_conv.is_owned = false;
26690         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
26691         return ret_val;
26692 }
26693
26694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26695         LDKPositiveTimestamp orig_conv;
26696         orig_conv.inner = (void*)(orig & (~1));
26697         orig_conv.is_owned = false;
26698         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
26699         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26700         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26701         uint64_t ret_ref = (uint64_t)ret_var.inner;
26702         if (ret_var.is_owned) {
26703                 ret_ref |= 1;
26704         }
26705         return ret_ref;
26706 }
26707
26708 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26709         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
26710         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
26711         return ret_conv;
26712 }
26713
26714 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
26715         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
26716         return ret_conv;
26717 }
26718
26719 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
26720         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
26721         return ret_conv;
26722 }
26723
26724 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
26725         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
26726         return ret_conv;
26727 }
26728
26729 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
26730         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
26731         return ret_conv;
26732 }
26733
26734 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26735         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
26736         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
26737         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
26738         return ret_val;
26739 }
26740
26741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
26742         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
26743         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
26744         return ret_val;
26745 }
26746
26747 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26748         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
26749         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
26750         return ret_conv;
26751 }
26752
26753 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
26754         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
26755         return ret_conv;
26756 }
26757
26758 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
26759         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
26760         return ret_conv;
26761 }
26762
26763 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
26764         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
26765         return ret_conv;
26766 }
26767
26768 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
26769         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
26770         return ret_conv;
26771 }
26772
26773 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
26774         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
26775         return ret_conv;
26776 }
26777
26778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26779         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
26780         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
26781         jboolean ret_val = Currency_eq(a_conv, b_conv);
26782         return ret_val;
26783 }
26784
26785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26786         LDKSha256 this_obj_conv;
26787         this_obj_conv.inner = (void*)(this_obj & (~1));
26788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26789         Sha256_free(this_obj_conv);
26790 }
26791
26792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26793         LDKSha256 a_conv;
26794         a_conv.inner = (void*)(a & (~1));
26795         a_conv.is_owned = false;
26796         LDKSha256 b_conv;
26797         b_conv.inner = (void*)(b & (~1));
26798         b_conv.is_owned = false;
26799         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
26800         return ret_val;
26801 }
26802
26803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26804         LDKSha256 orig_conv;
26805         orig_conv.inner = (void*)(orig & (~1));
26806         orig_conv.is_owned = false;
26807         LDKSha256 ret_var = Sha256_clone(&orig_conv);
26808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26810         uint64_t ret_ref = (uint64_t)ret_var.inner;
26811         if (ret_var.is_owned) {
26812                 ret_ref |= 1;
26813         }
26814         return ret_ref;
26815 }
26816
26817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26818         LDKDescription this_obj_conv;
26819         this_obj_conv.inner = (void*)(this_obj & (~1));
26820         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26821         Description_free(this_obj_conv);
26822 }
26823
26824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26825         LDKDescription a_conv;
26826         a_conv.inner = (void*)(a & (~1));
26827         a_conv.is_owned = false;
26828         LDKDescription b_conv;
26829         b_conv.inner = (void*)(b & (~1));
26830         b_conv.is_owned = false;
26831         jboolean ret_val = Description_eq(&a_conv, &b_conv);
26832         return ret_val;
26833 }
26834
26835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26836         LDKDescription orig_conv;
26837         orig_conv.inner = (void*)(orig & (~1));
26838         orig_conv.is_owned = false;
26839         LDKDescription ret_var = Description_clone(&orig_conv);
26840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26842         uint64_t ret_ref = (uint64_t)ret_var.inner;
26843         if (ret_var.is_owned) {
26844                 ret_ref |= 1;
26845         }
26846         return ret_ref;
26847 }
26848
26849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26850         LDKPayeePubKey this_obj_conv;
26851         this_obj_conv.inner = (void*)(this_obj & (~1));
26852         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26853         PayeePubKey_free(this_obj_conv);
26854 }
26855
26856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26857         LDKPayeePubKey a_conv;
26858         a_conv.inner = (void*)(a & (~1));
26859         a_conv.is_owned = false;
26860         LDKPayeePubKey b_conv;
26861         b_conv.inner = (void*)(b & (~1));
26862         b_conv.is_owned = false;
26863         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
26864         return ret_val;
26865 }
26866
26867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26868         LDKPayeePubKey orig_conv;
26869         orig_conv.inner = (void*)(orig & (~1));
26870         orig_conv.is_owned = false;
26871         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
26872         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26873         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26874         uint64_t ret_ref = (uint64_t)ret_var.inner;
26875         if (ret_var.is_owned) {
26876                 ret_ref |= 1;
26877         }
26878         return ret_ref;
26879 }
26880
26881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26882         LDKExpiryTime this_obj_conv;
26883         this_obj_conv.inner = (void*)(this_obj & (~1));
26884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26885         ExpiryTime_free(this_obj_conv);
26886 }
26887
26888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26889         LDKExpiryTime a_conv;
26890         a_conv.inner = (void*)(a & (~1));
26891         a_conv.is_owned = false;
26892         LDKExpiryTime b_conv;
26893         b_conv.inner = (void*)(b & (~1));
26894         b_conv.is_owned = false;
26895         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
26896         return ret_val;
26897 }
26898
26899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26900         LDKExpiryTime orig_conv;
26901         orig_conv.inner = (void*)(orig & (~1));
26902         orig_conv.is_owned = false;
26903         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
26904         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26905         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26906         uint64_t ret_ref = (uint64_t)ret_var.inner;
26907         if (ret_var.is_owned) {
26908                 ret_ref |= 1;
26909         }
26910         return ret_ref;
26911 }
26912
26913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26914         LDKMinFinalCltvExpiry this_obj_conv;
26915         this_obj_conv.inner = (void*)(this_obj & (~1));
26916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26917         MinFinalCltvExpiry_free(this_obj_conv);
26918 }
26919
26920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26921         LDKMinFinalCltvExpiry a_conv;
26922         a_conv.inner = (void*)(a & (~1));
26923         a_conv.is_owned = false;
26924         LDKMinFinalCltvExpiry b_conv;
26925         b_conv.inner = (void*)(b & (~1));
26926         b_conv.is_owned = false;
26927         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
26928         return ret_val;
26929 }
26930
26931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26932         LDKMinFinalCltvExpiry orig_conv;
26933         orig_conv.inner = (void*)(orig & (~1));
26934         orig_conv.is_owned = false;
26935         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
26936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26938         uint64_t ret_ref = (uint64_t)ret_var.inner;
26939         if (ret_var.is_owned) {
26940                 ret_ref |= 1;
26941         }
26942         return ret_ref;
26943 }
26944
26945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26946         if ((this_ptr & 1) != 0) return;
26947         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
26948         FREE((void*)this_ptr);
26949         Fallback_free(this_ptr_conv);
26950 }
26951
26952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26953         LDKFallback* orig_conv = (LDKFallback*)orig;
26954         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26955         *ret_copy = Fallback_clone(orig_conv);
26956         uint64_t ret_ref = (uint64_t)ret_copy;
26957         return ret_ref;
26958 }
26959
26960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
26961         
26962         LDKCVec_u8Z program_ref;
26963         program_ref.datalen = (*env)->GetArrayLength(env, program);
26964         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
26965         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
26966         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26967         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
26968         uint64_t ret_ref = (uint64_t)ret_copy;
26969         return ret_ref;
26970 }
26971
26972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26973         LDKTwentyBytes a_ref;
26974         CHECK((*env)->GetArrayLength(env, a) == 20);
26975         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26976         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26977         *ret_copy = Fallback_pub_key_hash(a_ref);
26978         uint64_t ret_ref = (uint64_t)ret_copy;
26979         return ret_ref;
26980 }
26981
26982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26983         LDKTwentyBytes a_ref;
26984         CHECK((*env)->GetArrayLength(env, a) == 20);
26985         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26986         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26987         *ret_copy = Fallback_script_hash(a_ref);
26988         uint64_t ret_ref = (uint64_t)ret_copy;
26989         return ret_ref;
26990 }
26991
26992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26993         LDKFallback* a_conv = (LDKFallback*)a;
26994         LDKFallback* b_conv = (LDKFallback*)b;
26995         jboolean ret_val = Fallback_eq(a_conv, b_conv);
26996         return ret_val;
26997 }
26998
26999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27000         LDKInvoiceSignature this_obj_conv;
27001         this_obj_conv.inner = (void*)(this_obj & (~1));
27002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27003         InvoiceSignature_free(this_obj_conv);
27004 }
27005
27006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27007         LDKInvoiceSignature a_conv;
27008         a_conv.inner = (void*)(a & (~1));
27009         a_conv.is_owned = false;
27010         LDKInvoiceSignature b_conv;
27011         b_conv.inner = (void*)(b & (~1));
27012         b_conv.is_owned = false;
27013         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
27014         return ret_val;
27015 }
27016
27017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27018         LDKInvoiceSignature orig_conv;
27019         orig_conv.inner = (void*)(orig & (~1));
27020         orig_conv.is_owned = false;
27021         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
27022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27024         uint64_t ret_ref = (uint64_t)ret_var.inner;
27025         if (ret_var.is_owned) {
27026                 ret_ref |= 1;
27027         }
27028         return ret_ref;
27029 }
27030
27031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27032         LDKPrivateRoute this_obj_conv;
27033         this_obj_conv.inner = (void*)(this_obj & (~1));
27034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27035         PrivateRoute_free(this_obj_conv);
27036 }
27037
27038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27039         LDKPrivateRoute a_conv;
27040         a_conv.inner = (void*)(a & (~1));
27041         a_conv.is_owned = false;
27042         LDKPrivateRoute b_conv;
27043         b_conv.inner = (void*)(b & (~1));
27044         b_conv.is_owned = false;
27045         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
27046         return ret_val;
27047 }
27048
27049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27050         LDKPrivateRoute orig_conv;
27051         orig_conv.inner = (void*)(orig & (~1));
27052         orig_conv.is_owned = false;
27053         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
27054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27056         uint64_t ret_ref = (uint64_t)ret_var.inner;
27057         if (ret_var.is_owned) {
27058                 ret_ref |= 1;
27059         }
27060         return ret_ref;
27061 }
27062
27063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
27064         LDKSignedRawInvoice this_arg_conv;
27065         this_arg_conv.inner = (void*)(this_arg & (~1));
27066         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27067         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
27068         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
27069         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
27070         return (uint64_t)ret_ref;
27071 }
27072
27073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
27074         LDKSignedRawInvoice this_arg_conv;
27075         this_arg_conv.inner = (void*)(this_arg & (~1));
27076         this_arg_conv.is_owned = false;
27077         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
27078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27080         uint64_t ret_ref = (uint64_t)ret_var.inner;
27081         if (ret_var.is_owned) {
27082                 ret_ref |= 1;
27083         }
27084         return ret_ref;
27085 }
27086
27087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27088         LDKSignedRawInvoice this_arg_conv;
27089         this_arg_conv.inner = (void*)(this_arg & (~1));
27090         this_arg_conv.is_owned = false;
27091         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27092         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
27093         return ret_arr;
27094 }
27095
27096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
27097         LDKSignedRawInvoice this_arg_conv;
27098         this_arg_conv.inner = (void*)(this_arg & (~1));
27099         this_arg_conv.is_owned = false;
27100         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
27101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27103         uint64_t ret_ref = (uint64_t)ret_var.inner;
27104         if (ret_var.is_owned) {
27105                 ret_ref |= 1;
27106         }
27107         return ret_ref;
27108 }
27109
27110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27111         LDKSignedRawInvoice this_arg_conv;
27112         this_arg_conv.inner = (void*)(this_arg & (~1));
27113         this_arg_conv.is_owned = false;
27114         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
27115         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
27116         return (uint64_t)ret_conv;
27117 }
27118
27119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
27120         LDKSignedRawInvoice this_arg_conv;
27121         this_arg_conv.inner = (void*)(this_arg & (~1));
27122         this_arg_conv.is_owned = false;
27123         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
27124         return ret_val;
27125 }
27126
27127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27128         LDKRawInvoice this_arg_conv;
27129         this_arg_conv.inner = (void*)(this_arg & (~1));
27130         this_arg_conv.is_owned = false;
27131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
27133         return ret_arr;
27134 }
27135
27136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27137         LDKRawInvoice this_arg_conv;
27138         this_arg_conv.inner = (void*)(this_arg & (~1));
27139         this_arg_conv.is_owned = false;
27140         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
27141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27143         uint64_t ret_ref = (uint64_t)ret_var.inner;
27144         if (ret_var.is_owned) {
27145                 ret_ref |= 1;
27146         }
27147         return ret_ref;
27148 }
27149
27150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
27151         LDKRawInvoice this_arg_conv;
27152         this_arg_conv.inner = (void*)(this_arg & (~1));
27153         this_arg_conv.is_owned = false;
27154         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
27155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27157         uint64_t ret_ref = (uint64_t)ret_var.inner;
27158         if (ret_var.is_owned) {
27159                 ret_ref |= 1;
27160         }
27161         return ret_ref;
27162 }
27163
27164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27165         LDKRawInvoice this_arg_conv;
27166         this_arg_conv.inner = (void*)(this_arg & (~1));
27167         this_arg_conv.is_owned = false;
27168         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
27169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27171         uint64_t ret_ref = (uint64_t)ret_var.inner;
27172         if (ret_var.is_owned) {
27173                 ret_ref |= 1;
27174         }
27175         return ret_ref;
27176 }
27177
27178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27179         LDKRawInvoice this_arg_conv;
27180         this_arg_conv.inner = (void*)(this_arg & (~1));
27181         this_arg_conv.is_owned = false;
27182         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
27183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27185         uint64_t ret_ref = (uint64_t)ret_var.inner;
27186         if (ret_var.is_owned) {
27187                 ret_ref |= 1;
27188         }
27189         return ret_ref;
27190 }
27191
27192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
27193         LDKRawInvoice this_arg_conv;
27194         this_arg_conv.inner = (void*)(this_arg & (~1));
27195         this_arg_conv.is_owned = false;
27196         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
27197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27199         uint64_t ret_ref = (uint64_t)ret_var.inner;
27200         if (ret_var.is_owned) {
27201                 ret_ref |= 1;
27202         }
27203         return ret_ref;
27204 }
27205
27206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
27207         LDKRawInvoice this_arg_conv;
27208         this_arg_conv.inner = (void*)(this_arg & (~1));
27209         this_arg_conv.is_owned = false;
27210         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
27211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27213         uint64_t ret_ref = (uint64_t)ret_var.inner;
27214         if (ret_var.is_owned) {
27215                 ret_ref |= 1;
27216         }
27217         return ret_ref;
27218 }
27219
27220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27221         LDKRawInvoice this_arg_conv;
27222         this_arg_conv.inner = (void*)(this_arg & (~1));
27223         this_arg_conv.is_owned = false;
27224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
27226         return ret_arr;
27227 }
27228
27229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
27230         LDKRawInvoice this_arg_conv;
27231         this_arg_conv.inner = (void*)(this_arg & (~1));
27232         this_arg_conv.is_owned = false;
27233         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
27234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27236         uint64_t ret_ref = (uint64_t)ret_var.inner;
27237         if (ret_var.is_owned) {
27238                 ret_ref |= 1;
27239         }
27240         return ret_ref;
27241 }
27242
27243 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
27244         LDKRawInvoice this_arg_conv;
27245         this_arg_conv.inner = (void*)(this_arg & (~1));
27246         this_arg_conv.is_owned = false;
27247         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
27248         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27249         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27250         for (size_t o = 0; o < ret_var.datalen; o++) {
27251                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
27252                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27253                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27254                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
27255                 if (ret_conv_14_var.is_owned) {
27256                         ret_conv_14_ref |= 1;
27257                 }
27258                 ret_arr_ptr[o] = ret_conv_14_ref;
27259         }
27260         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27261         FREE(ret_var.data);
27262         return ret_arr;
27263 }
27264
27265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
27266         LDKRawInvoice this_arg_conv;
27267         this_arg_conv.inner = (void*)(this_arg & (~1));
27268         this_arg_conv.is_owned = false;
27269         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27270         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
27271         uint64_t ret_ref = (uint64_t)ret_copy;
27272         return ret_ref;
27273 }
27274
27275 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
27276         LDKRawInvoice this_arg_conv;
27277         this_arg_conv.inner = (void*)(this_arg & (~1));
27278         this_arg_conv.is_owned = false;
27279         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
27280         return ret_conv;
27281 }
27282
27283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
27284         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
27285         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
27286         return (uint64_t)ret_conv;
27287 }
27288
27289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
27290         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
27291         *ret_conv = PositiveTimestamp_from_system_time(time);
27292         return (uint64_t)ret_conv;
27293 }
27294
27295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
27296         LDKPositiveTimestamp this_arg_conv;
27297         this_arg_conv.inner = (void*)(this_arg & (~1));
27298         this_arg_conv.is_owned = false;
27299         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
27300         return ret_val;
27301 }
27302
27303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
27304         LDKPositiveTimestamp this_arg_conv;
27305         this_arg_conv.inner = (void*)(this_arg & (~1));
27306         this_arg_conv.is_owned = false;
27307         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
27308         return ret_val;
27309 }
27310
27311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
27312         LDKInvoice this_arg_conv;
27313         this_arg_conv.inner = (void*)(this_arg & (~1));
27314         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27315         this_arg_conv = Invoice_clone(&this_arg_conv);
27316         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
27317         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27318         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27319         uint64_t ret_ref = (uint64_t)ret_var.inner;
27320         if (ret_var.is_owned) {
27321                 ret_ref |= 1;
27322         }
27323         return ret_ref;
27324 }
27325
27326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
27327         LDKInvoice this_arg_conv;
27328         this_arg_conv.inner = (void*)(this_arg & (~1));
27329         this_arg_conv.is_owned = false;
27330         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
27331         *ret_conv = Invoice_check_signature(&this_arg_conv);
27332         return (uint64_t)ret_conv;
27333 }
27334
27335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
27336         LDKSignedRawInvoice signed_invoice_conv;
27337         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
27338         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
27339         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
27340         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
27341         *ret_conv = Invoice_from_signed(signed_invoice_conv);
27342         return (uint64_t)ret_conv;
27343 }
27344
27345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
27346         LDKInvoice this_arg_conv;
27347         this_arg_conv.inner = (void*)(this_arg & (~1));
27348         this_arg_conv.is_owned = false;
27349         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
27350         return ret_val;
27351 }
27352
27353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27354         LDKInvoice this_arg_conv;
27355         this_arg_conv.inner = (void*)(this_arg & (~1));
27356         this_arg_conv.is_owned = false;
27357         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
27359         return ret_arr;
27360 }
27361
27362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27363         LDKInvoice this_arg_conv;
27364         this_arg_conv.inner = (void*)(this_arg & (~1));
27365         this_arg_conv.is_owned = false;
27366         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27367         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
27368         return ret_arr;
27369 }
27370
27371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
27372         LDKInvoice this_arg_conv;
27373         this_arg_conv.inner = (void*)(this_arg & (~1));
27374         this_arg_conv.is_owned = false;
27375         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
27377         return ret_arr;
27378 }
27379
27380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
27381         LDKInvoice this_arg_conv;
27382         this_arg_conv.inner = (void*)(this_arg & (~1));
27383         this_arg_conv.is_owned = false;
27384         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
27385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27387         uint64_t ret_ref = (uint64_t)ret_var.inner;
27388         if (ret_var.is_owned) {
27389                 ret_ref |= 1;
27390         }
27391         return ret_ref;
27392 }
27393
27394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
27395         LDKInvoice this_arg_conv;
27396         this_arg_conv.inner = (void*)(this_arg & (~1));
27397         this_arg_conv.is_owned = false;
27398         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27399         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
27400         return ret_arr;
27401 }
27402
27403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
27404         LDKInvoice this_arg_conv;
27405         this_arg_conv.inner = (void*)(this_arg & (~1));
27406         this_arg_conv.is_owned = false;
27407         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
27408         return ret_val;
27409 }
27410
27411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
27412         LDKInvoice this_arg_conv;
27413         this_arg_conv.inner = (void*)(this_arg & (~1));
27414         this_arg_conv.is_owned = false;
27415         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
27416         return ret_val;
27417 }
27418
27419 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
27420         LDKInvoice this_arg_conv;
27421         this_arg_conv.inner = (void*)(this_arg & (~1));
27422         this_arg_conv.is_owned = false;
27423         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
27424         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27425         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27426         for (size_t o = 0; o < ret_var.datalen; o++) {
27427                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
27428                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27429                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27430                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
27431                 if (ret_conv_14_var.is_owned) {
27432                         ret_conv_14_ref |= 1;
27433                 }
27434                 ret_arr_ptr[o] = ret_conv_14_ref;
27435         }
27436         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27437         FREE(ret_var.data);
27438         return ret_arr;
27439 }
27440
27441 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
27442         LDKInvoice this_arg_conv;
27443         this_arg_conv.inner = (void*)(this_arg & (~1));
27444         this_arg_conv.is_owned = false;
27445         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
27446         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27447         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27448         for (size_t l = 0; l < ret_var.datalen; l++) {
27449                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
27450                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27451                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27452                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
27453                 if (ret_conv_11_var.is_owned) {
27454                         ret_conv_11_ref |= 1;
27455                 }
27456                 ret_arr_ptr[l] = ret_conv_11_ref;
27457         }
27458         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27459         FREE(ret_var.data);
27460         return ret_arr;
27461 }
27462
27463 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
27464         LDKInvoice this_arg_conv;
27465         this_arg_conv.inner = (void*)(this_arg & (~1));
27466         this_arg_conv.is_owned = false;
27467         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
27468         return ret_conv;
27469 }
27470
27471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
27472         LDKInvoice this_arg_conv;
27473         this_arg_conv.inner = (void*)(this_arg & (~1));
27474         this_arg_conv.is_owned = false;
27475         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27476         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
27477         uint64_t ret_ref = (uint64_t)ret_copy;
27478         return ret_ref;
27479 }
27480
27481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
27482         LDKStr description_conv = java_to_owned_str(env, description);
27483         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
27484         *ret_conv = Description_new(description_conv);
27485         return (uint64_t)ret_conv;
27486 }
27487
27488 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
27489         LDKDescription this_arg_conv;
27490         this_arg_conv.inner = (void*)(this_arg & (~1));
27491         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27492         this_arg_conv = Description_clone(&this_arg_conv);
27493         LDKStr ret_str = Description_into_inner(this_arg_conv);
27494         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27495         Str_free(ret_str);
27496         return ret_conv;
27497 }
27498
27499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
27500         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
27501         *ret_conv = ExpiryTime_from_seconds(seconds);
27502         return (uint64_t)ret_conv;
27503 }
27504
27505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
27506         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
27507         *ret_conv = ExpiryTime_from_duration(duration);
27508         return (uint64_t)ret_conv;
27509 }
27510
27511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
27512         LDKExpiryTime this_arg_conv;
27513         this_arg_conv.inner = (void*)(this_arg & (~1));
27514         this_arg_conv.is_owned = false;
27515         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
27516         return ret_val;
27517 }
27518
27519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
27520         LDKExpiryTime this_arg_conv;
27521         this_arg_conv.inner = (void*)(this_arg & (~1));
27522         this_arg_conv.is_owned = false;
27523         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
27524         return ret_val;
27525 }
27526
27527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
27528         LDKRouteHint hops_conv;
27529         hops_conv.inner = (void*)(hops & (~1));
27530         hops_conv.is_owned = (hops & 1) || (hops == 0);
27531         hops_conv = RouteHint_clone(&hops_conv);
27532         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
27533         *ret_conv = PrivateRoute_new(hops_conv);
27534         return (uint64_t)ret_conv;
27535 }
27536
27537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
27538         LDKPrivateRoute this_arg_conv;
27539         this_arg_conv.inner = (void*)(this_arg & (~1));
27540         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27541         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
27542         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
27543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27545         uint64_t ret_ref = (uint64_t)ret_var.inner;
27546         if (ret_var.is_owned) {
27547                 ret_ref |= 1;
27548         }
27549         return ret_ref;
27550 }
27551
27552 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27553         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
27554         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
27555         return ret_conv;
27556 }
27557
27558 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
27559         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
27560         return ret_conv;
27561 }
27562
27563 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
27564         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
27565         return ret_conv;
27566 }
27567
27568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
27569         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
27570         return ret_conv;
27571 }
27572
27573 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
27574         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
27575         return ret_conv;
27576 }
27577
27578 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27579         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
27580         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
27581         jboolean ret_val = CreationError_eq(a_conv, b_conv);
27582         return ret_val;
27583 }
27584
27585 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27586         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
27587         LDKStr ret_str = CreationError_to_str(o_conv);
27588         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27589         Str_free(ret_str);
27590         return ret_conv;
27591 }
27592
27593 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27594         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
27595         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
27596         return ret_conv;
27597 }
27598
27599 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
27600         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
27601         return ret_conv;
27602 }
27603
27604 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
27605         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
27606         return ret_conv;
27607 }
27608
27609 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
27610         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
27611         return ret_conv;
27612 }
27613
27614 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
27615         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
27616         return ret_conv;
27617 }
27618
27619 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
27620         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
27621         return ret_conv;
27622 }
27623
27624 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
27625         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
27626         return ret_conv;
27627 }
27628
27629 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
27630         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
27631         return ret_conv;
27632 }
27633
27634 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
27635         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
27636         return ret_conv;
27637 }
27638
27639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27640         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
27641         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
27642         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
27643         return ret_val;
27644 }
27645
27646 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27647         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
27648         LDKStr ret_str = SemanticError_to_str(o_conv);
27649         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27650         Str_free(ret_str);
27651         return ret_conv;
27652 }
27653
27654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27655         if ((this_ptr & 1) != 0) return;
27656         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
27657         FREE((void*)this_ptr);
27658         SignOrCreationError_free(this_ptr_conv);
27659 }
27660
27661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27662         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
27663         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27664         *ret_copy = SignOrCreationError_clone(orig_conv);
27665         uint64_t ret_ref = (uint64_t)ret_copy;
27666         return ret_ref;
27667 }
27668
27669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
27670         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27671         *ret_copy = SignOrCreationError_sign_error();
27672         uint64_t ret_ref = (uint64_t)ret_copy;
27673         return ret_ref;
27674 }
27675
27676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
27677         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
27678         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27679         *ret_copy = SignOrCreationError_creation_error(a_conv);
27680         uint64_t ret_ref = (uint64_t)ret_copy;
27681         return ret_ref;
27682 }
27683
27684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27685         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
27686         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
27687         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
27688         return ret_val;
27689 }
27690
27691 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27692         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
27693         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
27694         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27695         Str_free(ret_str);
27696         return ret_conv;
27697 }
27698
27699 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) {
27700         LDKChannelManager channelmanager_conv;
27701         channelmanager_conv.inner = (void*)(channelmanager & (~1));
27702         channelmanager_conv.is_owned = false;
27703         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
27704         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27705                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27706                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27707         }
27708         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
27709         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
27710         LDKStr description_conv = java_to_owned_str(env, description);
27711         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
27712         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
27713         return (uint64_t)ret_conv;
27714 }
27715
27716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
27717         LDKStr s_conv = java_to_owned_str(env, s);
27718         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
27719         *ret_conv = SiPrefix_from_str(s_conv);
27720         return (uint64_t)ret_conv;
27721 }
27722
27723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
27724         LDKStr s_conv = java_to_owned_str(env, s);
27725         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
27726         *ret_conv = Invoice_from_str(s_conv);
27727         return (uint64_t)ret_conv;
27728 }
27729
27730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
27731         LDKStr s_conv = java_to_owned_str(env, s);
27732         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
27733         *ret_conv = SignedRawInvoice_from_str(s_conv);
27734         return (uint64_t)ret_conv;
27735 }
27736
27737 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27738         LDKInvoice o_conv;
27739         o_conv.inner = (void*)(o & (~1));
27740         o_conv.is_owned = false;
27741         LDKStr ret_str = Invoice_to_str(&o_conv);
27742         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27743         Str_free(ret_str);
27744         return ret_conv;
27745 }
27746
27747 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27748         LDKSignedRawInvoice o_conv;
27749         o_conv.inner = (void*)(o & (~1));
27750         o_conv.is_owned = false;
27751         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
27752         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27753         Str_free(ret_str);
27754         return ret_conv;
27755 }
27756
27757 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27758         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
27759         LDKStr ret_str = Currency_to_str(o_conv);
27760         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27761         Str_free(ret_str);
27762         return ret_conv;
27763 }
27764
27765 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27766         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
27767         LDKStr ret_str = SiPrefix_to_str(o_conv);
27768         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27769         Str_free(ret_str);
27770         return ret_conv;
27771 }
27772